Jump to content
  • Advertisement
Sign in to follow this  
capedica

Shadow Mapping texture matrix

This topic is 4797 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i need a little help, i've realized shadow mapping without shaders and now i'd like to try with shaders too but i've a problem with calculating texture matrix. This is the code i used in fixed method: textureMatrix= MultMatrix(lightProjectionMatrix,biasMatrix); textureMatrix = MultMatrix(lightViewMatrix,textureMatrix); glActiveTextureARB(2); //Bind & enable shadow map texture glEnable(GL_TEXTURE_2D); //glBindTexture(GL_TEXTURE_2D,texID); SetActiveTexture(emptyTex); //Set up texture coordinate generation. glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); glTexGenfv(GL_S, GL_EYE_PLANE, [textureMatrix[0],textureMatrix[4],textureMatrix[8],textureMatrix[12]]); glEnable(GL_TEXTURE_GEN_S); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); glTexGenfv(GL_T, GL_EYE_PLANE,[textureMatrix[1],textureMatrix[5],textureMatrix[9],textureMatrix[13]] ); glEnable(GL_TEXTURE_GEN_T); glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); glTexGenfv(GL_R, GL_EYE_PLANE, [textureMatrix[2],textureMatrix[6],textureMatrix[10],textureMatrix[14]]); glEnable(GL_TEXTURE_GEN_R); glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); glTexGenfv(GL_Q, GL_EYE_PLANE, [textureMatrix[3],textureMatrix[7],textureMatrix[11],textureMatrix[15]]); glEnable(GL_TEXTURE_GEN_Q); How can i calculate tangent matrix for using inside a shader? or, which are the analogous operations of these? Thank you very much.

Share this post


Link to post
Share on other sites
Advertisement
I'm not an ogl user so here is a projection matrix from a eye's pov.

// projected texture needs to be offset so that the projection is emitting from the center of the texture
TexMatrix.Translation(0.5f, 0.5f, 0.0f);

// normalize by lights radius
TexMatrix._11 = 0.5f / LightRadius.x;
TexMatrix._22 = 0.5f / LightRadius.y;
TexMatrix._33 = 0.5f / LightRadius.z;

// lights world -> texture space
TexMatrix *= ProjectionMatrix(of projector) * ViewMatrx(of projector) * inverseEyeMatrx(of your view matrix)


I can go into each of these matrices in more detail if ya need.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!