Shadow maps using the z-buffer

Ostsol

New member
I've read several resources on creating shadow maps using the z-buffer, but in every single one of them, I run into a wall. I understand all of the steps they explain except for one.

Ok, first I'm supposed to render the scene from the light's perspective without any textures (so as to save on fillrate), masking out colours and therefore only writing to the depth buffer. Next I'm supposed to render the scene from the camera's perspective and compare the position of each fragment to it's position in the depth map in order to determine if the fragment is in shadow or not. The problem is that the fragment's position has to be transformed to the light's perspective. How the heck am I supposed to do this?
 
Use a camera position texgen.

Set up a texture transformation matrix to convert from camera space to light projection space. (*)

Use projective texturing to do the perpective division per pixel.

* This is actally more tricky as you have no way to apply the viewport transformation after the perspective division - so you have to cook up the conversion matrix, so you end up in light's "screen" (viewport) space.

Hope, this helps.
 
I found it easiest to start off with getting a projective texture working right.
Since the all the transforms needed are exactly the same, its easy to change from projecting the texture, to comparing for shadowing with a small fragment shader change.
 
Thanks for the replies. School started again, so time's down the toilet, but I'll try out your suggestions.

I do already have projective texturing working, BTW.
 
Back
Top