Results 1 to 2 of 2

Thread: sampling from a non-existing texture

  1. #1
    Member Contributor
    Join Date
    Jul 2018

    sampling from a non-existing texture


    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"
            "layout (location = 0) out vec4 color;\n"
            "uniform sampler2D output_image;\n"
            "void main(void)\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"

    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
    Senior Member Regular Contributor
    Join Date
    May 2013
    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

Similar Threads

  1. Replacing an existing texture with a new one
    By Benzino in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 08-18-2011, 07:06 AM
  2. Sampling from a 2D texture as it would be 3D
    By Ingrater in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 11-27-2010, 09:54 AM
  3. inaccurate texture sampling
    By mokafolio in forum OpenGL: GLSL
    Replies: 5
    Last Post: 02-25-2010, 08:44 AM
  4. opengl texture sampling
    By michagl in forum OpenGL: Advanced Coding
    Replies: 30
    Last Post: 04-05-2005, 03:49 PM
  5. gluBuild2DMidmaps and existing Texture-Object
    By DaViper in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 04-11-2001, 03:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean