Using texture matrices for other purposes?

I am having a problem with the use of matrices.

I need to add a matrix to a set of shaders in a program I’m working on but due to the program structure I can’t define a new uniform because I have no control over the use of shaders. They can get swapped at any point so I have no means to ensure that a uniform matrix I set remains valid until it gets eventually used. This program needs to work with extension-less GL 2.0 so I can use no uniform buffers or other newer features.

The only way I see to solve this dilemma is to use one of the built in matrices and the only ones available to me are gl_TextureMatrix[4] - gl_TextureMatrix[7].

I have used gl_TextureMatrix[7] now and on my Geforce 8600GT card all seems to work fine.
Can I expect any trouble with such a non-conventional setup? The program never uses texture units 4 and above so they will always be inactive.

You can use the built-in texture matrices for whatever you want if you use shaders. Just make sure other shaders don’t expect anything special from it (e.g. in the fragment shader).

Anyway, texture matrices no longer have any fixed function behavior if you use shaders as the only thing they are used for in traditional opengl is that the texture coordinates are transformed used them. But this fixed function processing is completely replaced by the vertex shader.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.