Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Texture matrices in GLSL

  1. #1
    Intern Contributor
    Join Date
    Jul 2002
    Posts
    66

    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

    Code :
    gl_TexCoord[0] = gl_TextureMatrix[0]*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?

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,453

    Re: Texture matrices in GLSL

    Should just work the way you use it, except that glMultiTexCoord0 needs to be gl_MultiTexCoord0.

    If you haven't changed the matrix with
    something like
    glActiveTexture(GL_TEXTURE0);
    glLoadMatrixf(myTextureMatrix);
    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.

  3. #3
    Intern Contributor
    Join Date
    Jul 2002
    Posts
    66

    Re: Texture matrices in GLSL

    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).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •