Jump to content
  • Advertisement
Sign in to follow this  
luca-deltodesco

OpenGL projective texturing

This topic is 4069 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

im having some trouble with projective texturing on models that have transformations applied to them: here is a screenshot showing the problem: http://img168.imageshack.us/my.php?image=shadowmapfv8.jpg you can see where the spot light has been placed+direction from the lighting and shadow projected onto the walls. the walls simply have their vertices defined relative to the origin, the torus on the other hand, has a rotation applied to it, which is causing the projective texturing of shadow map to go off quite badly, as you can see, the shadowing on the torus is completely wrong. basicly, i have a function camTransform that applies the transformations to the modelview matrix so as to view the scene from the cameras position in its direction. here is the segment of the vertex shader dealing with calculating the projected texture coordinates: float4x4 sca; sca[0] = float4(0.5,0,0,0.5); sca[1] = float4(0,0.5,0,0.5); sca[2] = float4(0,0,0.5,0.5); sca[3] = float4(0,0,0,1); ligcoord = mul(sca,mul(lproj,position)); lproj is the modelview projection matrix for the light, position is the world coordinate of the vertex how would i modify this to take into account extra transformations applied to the modelview matrix? i tried doing: ligcoord = mul(sca,mul(lproj,mul(modelviewmatrix,position))); where modelviewmatrix is the modelview matrix from opengl that im using to rotate surface normals on the torus, but it seems to just make things worse, possibly since the modelview matrix also contains the camera transformations?

Share this post


Link to post
Share on other sites
Advertisement
If you have an object with local axis's, defined by a quaternion Q (in the case of your torus, just a rotation matrix), a point V of the object can be described in world axis by V' = Q.V. Your (world) modelview matrix M transforms world coordinates to screen coordinates, so finally V''=M.Q.V , this means that you must use the "local" modelview matrix M.Q for rendering your object. If I understand correctly, you're using the object's modelview matrix instead of Q, and yes, this includes camera transformations, and yes, it is wrong to do so. What you must do is store your extra transformations in a quaternion (Q) and use that instead of modelviewmatrix

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!