Texture matrix, texture space and so forth...

I am currently working on some Cg programs for bump mapping. I noticed that I need a matrix to transform object space to texture space, and the texture matrix SHOULD be the ideal solution. There are plenty of tutorials out there which detail creating a matrix to convert coordinates to texture space, thus proving to me (without having to check for myself) that the texture matrix (or inverse, inv-xpose for that matter) just doesn’t work. I’m wondering a number of things:

  1. Why does OpenGL make such poor useage of the texture matrix?

  2. Why does the OpenGL Programmer’s Guide only mention the texture matrix once in passing?

  3. Can I modify my engine to use the texture matrix, or is there some underlying details which make it impossible or hard?

When you do bumpmaps and mention texturespace i think you need the texturespace per vertex, and thus the texture matrix will not help there, unless you have some other trick that i dont know about, or you might have modelview dependent normalmaps.

why its not mentioned more? well it does the same things as the modelview, but with texture coords… think you learn more by plating with them, and well quite a few tricks does use them ( projected textures mainly)

the texture matrix is easy to use, both in the fixedpipeline and with vertexprograms, just go ahead…

??? How you gotta use texture matrix to generate texture space?
You need texture space to correctly apply normals, stored in the bumpmap. As you work with Cg I assume you know what does texture space is. Texture space is used to transform light vector - or polygon normals. Texture matrix transforms texture coordinates. There is no connection between them.

Texture matrix is used widely(!) to create projective textures, to animate environment etc.

When I apply textures to an object, instead of manipulating textures per vertex using the standard texture manipulation functions, I stick in some identity value (using auto texture coord generation with vectors s = (1,0,0) and t=(0,1,0) for example) and manipulate textures via the texture matrix directly, I could then use the texture matrix inverse to get texture space from object space. I may be way off here, but I figure it’s worth a shot.

Now, I am using automatic texture coord generation wherever I can, so I suppose it won’t be that hard to make this conversion. If I were to plug in individual UVs for each vertex, I can see doing this could be hard.

[This message has been edited by 147-2 (edited 04-09-2003).]

Yes, but you want to compute the texture-space coordinate axes (normal, tangent, and binormal vectors) at the per-vertex level, not the per-pixel level. The most straightforward way to do this is using a vertex shader.

The texture matrix can be used for a variety of things, such as projective texture mapping (e.g. for shadow maps). I wouldn’t consider GL making poor use of it. The texture matrix is just a matrix that can be used/abused just like any other matrix (e.g. modelview / projection).

Eric

Put another way, the matrix you use to transform the light direction into tangent space changes per-vertex. You use the normal, binormal, and tangent vectors of a vertex as a matrix to transform the light direction. Since the texture matrix cannot change between glBegin/glEnd, or during glDraw* calls (or glCallList), then it won’t be of particular use in this instance.