projective texturing

Started by
0 comments, last by Farfadet 16 years, 11 months ago
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?
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

This topic is closed to new replies.

Advertisement