I'm currently in the Process of making a simple little shaodw mapping ystem for Ogre3d. I'm currently stuck at Mapping the Shadow map texture to the object for depth comparison because I have no idea how to generate the required Projection Matrix that alows me to get the 2D UV coordinates for the Shadowtexture from the 3d Coordinates from the current fragment. So how can I generate the Projection Matrix from the Position, Direction, Fov/Angle and Frustum of the Ligth/Light Camera?
Asked
Active
Viewed 1,171 times
2
-
pretend the light is a camera then do as you would, spotlights are the easiest to get the matrix from – ratchet freak Jan 02 '15 at 18:05
-
Yeah but I have no idea how to do that. I know how to get viewport ond Projectionmatrix from a camera, but I need the lightprojection matrix, which is apperantly kinda a mixture of both. – user2706035 Jan 03 '15 at 12:46
-
1It really is similar to the way you set up your camera initially. For instance, if you used `gluPerspective` and `gluLookAt` for your camera, you can do the same for the spotlight: `gluPerspective(15, 1.0, near, far)` creates the projection matrix for a spot with a beam arc of 15 degrees, and `gluLookAt(fromX, fromY, fromX, toX, toY, toZ, 0, 1, 0)` creates a view matrix that should work fine to start. Multiply these together the same way you would a view and projection matrix for a camera. – Justin Jan 05 '15 at 14:09
-
2@Justin Please post your answer as an actual answer. – Andreas Haferburg Jan 23 '15 at 17:37