projecting shadow map into view space

Started by
1 comment, last by karx11erx 17 years, 11 months ago
Hi, I am rather clueless about 3D math, and even reading all the theory 10 times over leaves me clueless on how to apply it, so I am asking here. I want to project shadow maps (which are 2D depth textures) into view space. The software I am trying to add shadow maps to doesn't use the OpenGL view transformations, but does all the coordinate transformations itself using 3x3 matrices. To render a scene, the initial vertex coordinates of all geometry in the level (walls, objects, etc) are transformed to values that make everything appear at the proper places and distance as seen from a viewer (which can be a lightsource). OpenGL does the same with the translate and rotate commands, but I cannot use them in my app (an old 3D shooter - Descent 2). Each shadow map has been rendered from some 3D point using such a projection matrix. So I am having a position LP and the projection matrix LM for the light source, and I am having a position VP and a projection matrix VM for the scene viewer. How do I compute the translation matrix for the shadow map so that it is properly rendered into the scene as seen from the viewer? Maybe I have explained too much at some places and too little at others. This stuff is just a little beyond me, so please forgive me and ask back if necessary. There's people who can write the necessary stuff down in a minute - I'd have to torment my head for hours and days and ... Thx for every help. :)
_________karx11erxVisit my Descent site or see my case mod.
Advertisement
You don't really transform the shadow map into view space, you transform world space pixels into shadow space. A lot of the transformations can easily be built without any OpenGL helper functions (gluLookAt, gluPerspective, glFrustum) but you either have to know how they work, or just know of a few decent reference pages that show you how to build them [smile] The only hitch is that Descent 2 separates rotations and translations, so you need to combine them into a 4x4 homogeneous transformation for the shaders.

The DirectX ShadowMap sample contains a brief description of the shadow mapping process, as well as all the transformations you need to perform. The basic idea is that when you render the scene, you output two vertex coordinates - one in perspective view space, and one in perspective light space. The first one is used for standard rendering, and the second one is used for shadow map lookup. You also output a standard view space (non-perspective) normal that can be used in both standard lighting equations and to shadow points that aren't within a light cone.

It's also possible to create directional lights instead of point lights. Simply don't apply the perspective transformation for the light space. I hear the aliasing is a little better for directional lights (i.e. the sun).
Thank you for the broad and general reply.
_________karx11erxVisit my Descent site or see my case mod.

This topic is closed to new replies.

Advertisement