Hi,
I am getting nuts trying to get a simple fragment shader to work. I am trying to use the texelFetch function, but no luck.
I am creating a 1D texture, min.filter = linear, mag.filter = linear.
I then call glTexImage1D:
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA8UI, sizeInPixels, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, <data>);
I am making sure my data is populated with 0xFF byte values everywhere, eg.:
char *data = [...];
data[0] = 255;
data[1] = 255;
data[2] = 255;
data[3] = 255;
[...]
Now my fragment shader.
The uniform is correctly bound as a usampler2D in my code.
#version 150 compatibility
#extension GL_EXT_gpu_shader4 : enable
uniform usampler1D tex;
void main(void)
{
uvec4 val = texelFetch(tex, 0, 0);
if (val.r == 255u)
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); // red
else
gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); // green
}
The result is always green!
Thanks,
Fred



