Sign in to follow this  
MrSparkle

How to compute a light frustum for shadow mapping?

Recommended Posts

Hi, I'm looking for a good method to compute an optimal light frustum for creating shadow maps. I have a very large outdoor scene with only one directional sunlight. Thus, I need to create a projection matrix for the light source which fits to the currently visible objects and potential shadow casters. Because I would use the Matrix.OrthoLH() function (C# + Managed DirectX), I need to calculate the following parameters: - Width - Height - zNearPlane - zfarPlane I think that I also have to virtually adjust the position of the light source, because the shadow distribution of a directional light only depends on its direction. I'm not sure if one can do this, but in some cases it could also be more effective to rotate the projection plane, that is, to rotate the camera around its LookAt-Axis to reduce the necessary Width and Height values. Does anybody know a good algorithm to do this in an effective way? Thank you very much, Christian

Share this post


Link to post
Share on other sites
If you know an algorithm that is not suitable for directional lights but for spotlights, please let me know.

Any help appreciated!

Christian

Share this post


Link to post
Share on other sites
I build a light oriented bounding box around the view frustum and then extend it quite a bit in the -Z direction. For Shadow Mapping, X and Y are the texture base axises and Z is the light direction. View distance is 1000 meters here, I extend the light frustum by 500 meters. 200 meters proved to be too low in certain special spots where a big cliff behind the viewer casted shadow on the scene. You don't loose shadow resolution by this, only performance and depth precision.

Bye, Thomas

Share this post


Link to post
Share on other sites
Do you optimize the light frustum in any way?

I read about computing a bounding rectangle in this article. They propose an algorithm called "Rotating Calipers" to create an optimal bounding rectangle which fits close to all visible objects. This prevents wasting space in the shadow map. But this approach seems to need lots of performance, if you have to re-adjust the light's frustum every frame.

Has anyone implemented the Rotating Calipers algorithm, or another method to optimize the light frustum?

Share this post


Link to post
Share on other sites
... create a frustum for the view frustum part that should be in shadow. Transform this part in light space. From the point of the view of the light use the extrema to build up a box that is used as an orthographic light frustum.

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