View Full Version : Texture matrices in GLSL
How can the fixed-function equivalent of texture matrices be implemented in GLSL? I was under the impression that having in the vertex shader a
gl_TexCoord = gl_TextureMatrix*glMultiTexCoord0;would be enough, but apparently it isn't (texture gets stretched very differently on the mesh when the shader is active)... what am I missing?
05-18-2004, 08:43 AM
Should just work the way you use it, except that glMultiTexCoord0 needs to be gl_MultiTexCoord0.
If you haven't changed the matrix with
there should be the identity matrix in it
- Does the shader work if you replace this with glLoadIdentity()?
- Does it work if you just don't multiple with the matrix at all.
If you suspect a driver bug, update the drivers.
Thanks for confirming the point!
After assuming this part as being right, and much head scratching on the rest, I finally found what was wrong: I was using the texture matrix for reflection purposes, thus with a projective part.
Apparently the drivers automatically take that into account when the texture matrix is used directly, but when using a vertex shader (or doing the transformation "manually" CPU-side) you have to perform the division by the projective component explicitly (or use texture2DProj in the fragment shader).
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.