texelFetch problem


#version 150

in ivec2 A0;
out vec3 C;
uniform sampler2DRect I;

void main()
{
...
C = texelFetch(I, A0).rgb;      // doesn't work
C = texture(I, vec2(A0)).rgb;   // works
}

Check the “works” and “doesn’t work” lines :slight_smile:
Any idea why?

I think I remember having had problems like that, because integers should be as “flat in/out ivec*” when given from one shader stage to another, the AMD compiler gave a warning about that. If don’t want flat shading, try passing it as vec2 and converting it to ivec in that shader stage.
I can’t find it in the GLSL 1.5 spec right now, but i found the following: “Varying variables can now be (unsigned) integers. If declared as such, they have to be flat shaded.” in the EXT_gpu_shader_4 spec.
Just give it a shot :slight_smile:

Are u r passing the attribute using


glVertexAttribIPointer

for integer types (ivec*). Note there is an I in there.

C = texelFetch(I, A0, 0).rgb; // works

read the spec!

@FlorianR flat gives an error. it’s the default with ints;
@morbeen I was using that already;
@Chris Lux no it doesn’t. Not with rect samplers.

It’s working now. I’m not sure that it was… probably something else was causing the error.

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