# TexGen and Texture Matrix Question

I am working on a volume rendering problem using 3D texture and trying to using glTexGen
and TEXTURE matrix to generate the s, t, r texture cooridnate.

I understand how the TexGen works, but not sure how the texture matrix will effect the generation of the s,t,r.

For example, if the input vertex is(x, y, z, 1); after apply the the xPlane, the
s coordinate will be x.
How will the Texture matrix effect the s coordinates?

float xPlane[] ={1.0f, 0.0f, 0.0f, 0.0f};
float yPlane[] ={0.0f, 1.0f, 0.0f, 0.0f};
float zPlane[] ={0.0f, 0.0f, 1.0f, 0.0f};

glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);

// …
// Here work on TEXTURE matrix
// …

glTexGenfv(GL_S, GL_OBJECT_PLANE, xPlane);
glTexGenfv(GL_T, GL_OBJECT_PLANE, yPlane);
glTexGenfv(GL_R, GL_OBJECT_PLANE, zPlane);

glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);

The texture coordinate is multiplied by the matrix. This means you can apply rotate operations etc to transform the texture after generation.

Here is another OpenGL thread discussing exactly this. I posted some detailed explanations & code to this thread, it’s very on topic for you so read it carefully.
http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/006597.html

There are some broken URLs in that thread, my explanations are still available here:
http://www.sgi.com/software/performer/brew/volume.html

Thanks alot!