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

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’.

I referred to this page
http://www.opengl.org/sdk/docs/manglsl/xhtml/texelFetch.xml
in which gvec4 texelFetch(gsampler1DArray sampler, ivec2 P, int lod); takes 3 params.


in vec2 v_texCoord;

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


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


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

[QUOTE=debonair;1240835]I referred to this page
http://www.opengl.org/sdk/docs/manglsl/xhtml/texelFetch.xml
in which gvec4 texelFetch(gsampler1DArray sampler, ivec2 P, int lod); takes 3 params.[/QUOTE]

You need the overload for ‘gsamplerBuffer’ not ‘gsampler1DArray’.
The page you linked has the same delaration for it as one quoted by me.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.