Automatic texture coordinates

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);

        glTexGenfv(GL_S, GL_EYE_PLANE, params);
        glTexGenfv(GL_T, GL_EYE_PLANE, params);
        glTexGenfv(GL_R, GL_EYE_PLANE, params);
        // 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 :frowning: . Anyone knows what the problem might be?
Thanks in advance.

In the first case, assuming texture matrix is identity and modelview matrix is identity:

texcoord.s = plane.z * eye_space_vertex.z;
texcoord.t = plane.z * eye_space_vertex.z;
texcoord.r = plane.z * eye_space_vertex.z;

In the second case, custom texture matrix and modelview matrix is identity:

texcoord.s = 0.0;
texcoord.t = 0.0;
texcoord.r = plane.x *eye_space_vertex.x + plane.y *eye_space_vertex.y +plane.z *eye_space_vertex.z + plane.w *eye_space_vertex.w;

so these two are quite different.

Got it! Thanks.