Hi,
I want to compute the colors for every face of a mesh. I save these colors into a texture and then in the glsl I get the colour.
When I try this, I get different behaviour in different graphic cards. In some ones the result it’s ok and on others it’s wrong.
In both the texture coordinates are the same. Any idea?
OpenGL code creating the texture:
glDeleteTextures(1, &mPolygonalSaliencyTexture);
glGenTextures(1, &mPolygonalSaliencyTexture);
glBindTexture(GL_TEXTURE_2D, mPolygonalSaliencyTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, mPolygonalTexturesSize, mPolygonalTexturesSize, 0, GL_RGB, GL_FLOAT, &floatColors[0]);
GLSL code to get the values:
#extension GL_EXT_gpu_shader4 : enable
uniform sampler2D saliencyTexture;
...
vec2 textCoord = vec2( ((gl_PrimitiveID + offset) % polygonalTexturesSize), ((gl_PrimitiveID + offset) / polygonalTexturesSize) );
textCoord /= float(polygonalTexturesSize);
returnColor = vec4(texture(saliencyTexture, textCoord).xyz, 1.0f);