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.
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…
Yep, it’s just a regular matrix, you can put whatever data you want in it.
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
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?
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).
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.