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 5 of 5

Thread: texture buffer shader fails to compile

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    129

    texture buffer shader fails to compile

    Hi,
    I am trying to implement texture buffer in my code but my shader gives failure while compilation .
    My shader is :

    #extension EXT_gpu_shader4 : enable
    in vec2 v_texCoord;
    uniform samplerBuffer s_texture;
    out vec4 Color;
    void main()
    {
    Color = texelFetch(s_texture,v_texCoord,0);
    }

    The errors are:
    Fragment shader failed to compile with the following errors:
    ERROR: 0:8: error(#202) No matching overloaded function found texelFetch
    ERROR: 0:8: error(#160) Cannot convert from 'const float' to 'out 4-component vector of float'
    ERROR: error(#273) 2 compilation errors. No code generated


    Please correct me ...



    Regards,
    Roshan

  2. #2
    Member Regular Contributor
    Join Date
    Apr 2009
    Posts
    258
    Consider signature of texelFetch of texture buffer

    gvec4 texelFetch (gsamplerBuffer sampler, int P)
    It only takes sampler and a single integer coordinate, you are feeding it vec2 coordinate and additional '0'.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    129
    I referred to this page
    http://www.opengl.org/sdk/docs/mangl...texelFetch.xml
    in which gvec4 texelFetch(gsampler1DArray sampler, ivec2 P, int lod); takes 3 params.

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    941
    Code :
    in vec2 v_texCoord;

    This is a float vector. texelFetches take integer texture coordinates.

    Code :
    Color = texelFetch(s_texture,ivec2(v_texCoord),0);

    will technically work. However, since float tex coords are in the range [0, 1] you won't fetch the correct texels. You need

    Code :
    ivec2 iTexCoord = ivec2(v_texCoord) * ivec2(textureWidth, textureHeight);

  5. #5
    Member Regular Contributor
    Join Date
    Apr 2009
    Posts
    258
    Quote Originally Posted by debonair View Post
    I referred to this page
    http://www.opengl.org/sdk/docs/mangl...texelFetch.xml
    in which gvec4 texelFetch(gsampler1DArray sampler, ivec2 P, int lod); takes 3 params.
    You need the overload for 'gsamplerBuffer' not 'gsampler1DArray'.
    The page you linked has the same delaration for it as one quoted by me.

Posting Permissions

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