Sign in to follow this  
muhkuh

shadow mapping with directional light

Recommended Posts

muhkuh    163
Hello it's me again, I try to implement shadow mapping with a directional light source. When rendering from the light's point of view I set up the combined model-view-projection matrix as a rotation to the lights direction multiplied be an orthogonal projection matrix. If I undestood this right I have got a fixed direction of the light's view frustum and it's width, height, z-near and z-far are given by the dimensions of the geometry visible from the camera's view frustum. But what about the rotation of the light's view frustum around it's view direction? Does it make any difference where the "up" vector of the light's view frustum points to as long as projective texturing when rendering from the camera's view is set up right or is there a prefered way to set the "up" vector? Markus

Share this post


Link to post
Share on other sites
Yann L    1802
Quote:
Original post by muhkuh
But what about the rotation of the light's view frustum around it's view direction? Does it make any difference where the "up" vector of the light's view frustum points to as long as projective texturing when rendering from the camera's view is set up right or is there a prefered way to set the "up" vector?

Theoretically, it doesn't matter, as long as the RTT camera matrix matches the projection matrix. But in practice, things are a little different as the shadowmap doesn't have infinite precision. It's not so much the roll of the light projection that is important (it will modify the orientation of shadowmap texels as projected on the scene), but the temporal consistency of it. If you don't keep that in mind, you'll get temporal aliasing when the light changes orientation, which creates very ugly artifacts.

Think about it: if your light orientation changes, the orientation of the projected shadowmap texels will very likely change as well (assuming the relative rotation of the light projection matrix changes). If the map had inifinite resolution, that wouldn't be a problem. But the lower the map resolution, the more you will actually see this effect: slowly turning texels without shadowmap filtering, and weird flickering and light/shadow bleeding if using PCF. The usual trick to alleviate the problem (beside increasing the map resolution), is to adjust the roll (ie. the up vector) of the light projection in such a way, that the projected texel orientation stays more or less constant when the light moves.

Trapezoidal shadowmapping is an interesting approach you might want to consider.

Share this post


Link to post
Share on other sites
muhkuh    163
Another question somewhat related to that:

I had the idea to make the light's vieport as small as possible to get as more resolution out of my lightmap. As I already do culling yet I thought I could just cull out unnecessary gemometry before and get some kind of bounding box I can use for creating the light's viewport.

Until now I recursivly divided into patches and culled out invisible stuff on the way. This way culling and rendering must have happened kinda parallel. Building up the visibility information before rendering and using it later seems to be slower. Do you have any suggestions?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this