# S,T, R & Q planes. How do they work?

Hi

I’m currently looking at the automatic texture generation function glGenTex in openGL. I am a little puzzled by it. Could someone please explain what the S, T, R, Q planes are, what they do, and how to set them up? I’ve seen some examples using this function, but they all just enter the indentity matrix as the s,t,r,q matrix. I realise, that they have a similar function to the homogenous coordinates X,Y,Z and W, but I haven’t understood the function completely. So if someone could explain it to me or point me to a site that does, I would appreciate it. Thank you.
Also, when is it appropriate to use the GenTex function? What do professionals do?

Anders

The TexGen planes specify the origin and scale of your generated texture coordinates.

A plane has the equation Ax + By + Cz + D = 0. Substituting a point for (x, y, z) gives you the distance of that point to the plane. When you specify the TexGen planes, what you give to the GL are A, B, C and D. OpenGL then uses your vertex coordinates to fill in x, y and z, and then outputs Ax + By + Cz + D as your final texture coordinate. It does this for S, T, R and Q.

You could also think of this as a dot product (although it doesn’t really help), or you could consider the combination of the four TexGen planes to be a matrix that is applied to your vertex coordinates to produce texcoords.

Important to remember here is that if you use EYE_LINEAR TexGen, the planes are multiplied by the inverse modelview matrix right after you specify them.

– Tom

I like to think of the plane equation as a normal of the plane with the 4th parameter being the displacement from the origin along the normal. It’s quite intuitive then to work with the numbers.