I am using automatic texture generation for rendering some geometry. The texture coordinates are generated based on the eye space position of the incoming vertex.
vec4f params(0, 0, 1, 0);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGenfv(GL_S, GL_EYE_PLANE, params);
glTexGenfv(GL_T, GL_EYE_PLANE, params);
glTexGenfv(GL_R, GL_EYE_PLANE, params);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
// do rendering here
Notice that the plane is (0, 0, 1, 0). Everything works fine. The plane is multiplied with inverse model view matrix and the resulting plane is multiplied with incoming eye space vertex to generate a 3d texture coordinate.
However, i tried getting the same job done using texture matrix, in which case i pass (1, 1, 1, 1) as the plane equation but set a texture matrix in which only index 33 (third row third column) was set to 1.0 and the rest of matrix was zeroed out. This should theoretically produce the same result once the matrix is multiplied with the generated texture coordinates if it follows the following procedure:
plane’ = plane * mv_inverse
texcoord = plane’ * eye_space_vertex
texcoord’ = texture_matrix * texcoord
Use texcoord’ as 3d texture coordinates
But, sadly, it doesn’t . Anyone knows what the problem might be?
Thanks in advance.