Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: sampling from a non-existing texture

  1. #1
    Intern Contributor
    Join Date
    Oct 2012
    Posts
    52

    sampling from a non-existing texture

    Hi

    I have a shader in which i use the texture() function to lookup from a non-existing sampler. I expected that I should get errors from complingmy shader. But it compiles clean.

    Code :
    static const char render_fs[] =
            "#version 430 core\n"
            "\n"
            "layout (location = 0) out vec4 color;\n"
            "\n"
            "uniform sampler2D output_image;\n"
            "\n"
            "void main(void)\n"
            "{\n"
            "    color = texture(output_image1, vec2(gl_FragCoord.xy) / vec2(textureSize(output_image, 0)));\n"
    		" if(color.r  < 0.0) {color=vec4(1.0,0.0,0.0,1.0);} else{color=vec4(0.0,1.0,0.0,0.0);}\n"
            "}\n";

    Note: I am sampling from output_image1 instead of output_image.output_image1 is an intentional typo.

    Also, if it compiles and links cleanly, I would have expected it to go to the else part of the test color.r < 0.0 , since color would be undefined. (Really, I should be getting an error since how on earth can you be trying to access .r from an undefined color. Or am i returning some default value if the texture being sampled is undefined/errornous??)

    It appears that I get a white color render instead of erroring out or a green screen ( color assigned from the else part).

  2. #2
    Intern Contributor
    Join Date
    May 2013
    Posts
    69
    On Radeon 7870 with Catalyst 13.4
    Code :
    ERROR: 0:9: error(#143) Undeclared identifier: output_image1
    ERROR: 0:9: error(#202) No matching overloaded function found: texture
    WARNING: 0:9: warning(#402) Implicit truncation of vector from size: 1 to size: 4
    ERROR: error(#273) 2 compilation errors.  No code generate

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •