PDA

View Full Version : matrix from gl to glsl



andreasMank
05-10-2004, 11:05 PM
.. i'm using gl_TextureMatrix[0] to catch a matrix from gl .. its working pretty well, but the index correnponds on the bound texture .. thats sucks .. any ideas ???

andreasMank
05-10-2004, 11:59 PM
ok .. i'm using gl_modelviewmatrix .. a little bit stupid .. but it works ..

PanzerSchreck
05-11-2004, 12:46 AM
Is it so hard to take a look at the glsl-specs? There are plenty of matrices predefined (although there could be some more like in ARB_VP/ARB_FP) :
mat4 gl_ModelViewMatrix mat4 gl_ModelViewMatrix mat4 gl_ProjectionMatrix mat4 gl_ModelViewProjectionMatrix mat3 gl_NormalMatrix mat4 gl_TextureMatrix[gl_MaxTextureCoordsARB]
P.S. : Why is using gl_ModelViewMatrix stupid?

andreasMank
05-11-2004, 03:05 AM
because i'm using a two pass shader and need the matrix in both passes. when i'm using the modelMatrix i have to pop after my first pass for drawing my scenen .. if i could store in textureMatrix and haven't this problems .. but i'm not sure, how i can maniuplate the index of gl_TextureMatrix[0] ..

is the index equal to the bound name of the bound texture ??

.. to write to the textureMatrix i'm just calling glMatrixMode(GL_TEXTURE); how do i know the right index for gl_TextureMatrix[] and gl_MultiTexCoord0 in my shader?? oi read a lot about textures in the read, orange and blue book, but i didn't found the answer ..

bobvodka
05-11-2004, 07:46 AM
textures in GLSL dont refer to 'texture objects' but 'texture units', so if you bind a texture object to texture unit 0 and change its matrix then gl_TextureMatrix[0] refers to the matrix of that texture unit
You know what texture it refers to because you bound the texture to that texture unit before calling the shader.