View Full Version : gl_TextureMatrix

04-29-2007, 04:19 PM
I just had a small question about gl_TextureMatrix built-in variable. Is this valid only when the texture is bound? Or can I willy nilly set values in these matrices when I want to with the assurance the data will be available at all times?

I suppose what I'm doing is using this as a global variable so I don't have to go through all my glsl programs to set a uniform. I just load one matrix with my special sauce.

Will the ati or nvidia driver treat this differently?

I think it works but then again I'm not so sure.

Thanks in advance. :)

04-29-2007, 04:38 PM
he texture matrices aren't implementation specific. They have no decencies to the bound textures.
You can use texture matrices like the projection or modelview matrix...

04-30-2007, 12:46 PM
Yep, it's just a regular matrix, you can put whatever data you want in it.

05-03-2007, 06:40 PM
Generally,TextureMatrix is the Indentity Matrix. If people want to project texture from some position such as lightpos, the may store the ModelViewProjection matrix in TextureMatrix,then in VertexShader directly multiply by gl_Vertex

05-04-2007, 05:59 PM
I got to get this cleared up, is there a texture matrix per texture unit? or is there only one texture matrix? And if there is only one I am assuming then, if you modify it with unit 3 it affected what you may have done with it in unit 0?


05-05-2007, 01:30 AM
Originally posted by Mars_9999:
I got to get this cleared up, is there a texture matrix per texture unit? or is there only one texture matrix?Each texture unit that is not image only has its own texture matrix.

05-07-2007, 04:57 AM
Right, which is explained in the OpenGL specs on glActiveTexture().

To find out what's the number of available texture matrices you need to look at some GL_MAX_* values.

For the fixed function pipeline using texture units and direct mapping between texture units and texture coordinate arrays that's GL_MAX_TEXTURE_UNITS (normally 4).

For the programmable pipeline which uses texture image units there can be more texture image units (GL_MAX_TEXTURE_IMAGE_UNITS, e.g. 16) than texture coordinate attributes (GL_MAX_TEXTURE_COORDS, 8).