Texture Coordinate generation

Hi everyone,

I own the OpenGL orange book about GLSL, and reading about texture coordinate generation, I really can’t figure out what does this code, and why:

gl_TexCoord[0].s = dot( gl_Vertex, gl_ObjectPlaneS[0] );
gl_TexCoord[0].t = dot( gl_Vertex, gl_ObjectPlaneT[0] );
gl_TexCoord[0].p = dot( gl_Vertex, gl_ObjectPlaneR[0] );
gl_TexCoord[0].q = dot( gl_Vertex, gl_ObjectPlaneQ[0] );

Where should I look to understand it? I own the Real Time Rendering 2nd Edition book, but it does’t help me understand this code!
Have you any suggestion?
What’s the difference between that code and something like:
gl_TexCoord[0] = gl_MultiTexCoord0;


Thank you in advance!

If you had googled for “texture coordinate generation”, you would have see several thousand sources explaining this in detail. For instance, Nvidia has a presentation on this topic.

The above code simply takes the gl_Vertex and basically multiplies it with a matrix which is stored in the gl_ObjectPlane* variables (hence the 4 dot produts) to generate a texture coordinate. This is exactly what the fixed function pipeline would do if you had texture coordinate generation enabled and did’t use shaders.

[ www.trenki.net | vector_math (3d math library) | software renderer ]

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.