Eye Linear Texgen Update

An important detail about the use of the GL_EYE_LINEAR texgen function is when the coefficients are set.

        glTexGenfv(GL_S, GL_EYE_PLANE, SplaneCoefficients);
        glTexGenfv(GL_T, GL_EYE_PLANE, TplaneCoefficients);

The current ModelView transformation is applied to the coefficients.

If they are set once, when no transformations are loaded, then the texture coordinates are generated in "eye coordinates". When the camera moves, the texture coordinates generated for a particular point will change, and the texture appears to swim across the object.

If the coefficients are set each frame, after the camera transformation has been loaded, then the texgen will effectively operate in "world coordinates". The coordinates generated for vertices will depend on their position in world coordinates - that affected by all ModelView transformations except for those of the camera. The texture will stay fixed on objects as the camera moves; it will still move across the surface of moving objects.

        camera.apply();
        glTexGenfv(GL_S, GL_EYE_PLANE, SplaneCoefficients);
        glTexGenfv(GL_T, GL_EYE_PLANE, TplaneCoefficients);

Example: eyelinear.cpp




next