Sign in to follow this  
b_thangvn

Shadow map with direct light ?

Recommended Posts

Hi guys, So I finally want to have shadow in my demo and decide to implement it using shadow map. However, I have trouble figuring out how to implement shadow map with direct light. The general process to my understanding is: 1) Render the scene from the light perspective -> shadow map in a buffer 2) Perform rendering, and compare the depth of current pixel with value read out from shadow map to perform shadow shading. For spot light there are demos so I can understand step 1 because a spot light has a definitive world position, hence we can construct its world-view-projection matrix. But the direct light ( like the sun ), we won't have a position for it. We usually only have direction where the light comes from. So how do you render shadow map for direct light? Thanks in advance for all the help.

Share this post


Link to post
Share on other sites
Construct a bounding box around the camera's frustum, then place the light's position on the edge of this bounding-volume (away from the center in the opposite direction to the light). The light's projection matrix will be ortho instead of perspective.

Because this shadow map will cover a huge area though, you usually get low-quality results. To combat this, often PSSM is used.

Share this post


Link to post
Share on other sites
Usually you calculate the shadow view volume in a way, that it will enclose the camera view volume, so you only shadow what you see. But you have to stretch it in the direction to the light, so you have to make sure all possible occluders are inside the volume.

I hope that's clear.

EDIT: PWNED!

Share this post


Link to post
Share on other sites
Hi guys,

Thanks for helping.

@ Hodgman:

It's interesting when you bring up PSSM because I've been looking at the PSSM articles in GPU Gems 3 and also at several CSM in ShaderX series. I also look through the CSM demo from NVIDIA OpenGL SDK. However, all the splitting view frustum is kinda out of my understanding right now :(. I just want to have a shadow map first, then I will dive into the splitting frustum scheme.

So with that said, all the articles doesn't show me how to construct a bounding volume. I would greatly appreciate if you can point me to some resources :) ?

@ szecs:

You didn't see it coming did you :D ? It's interesting because I just watch your youtube demo a few days ago, but I didn't know it's you at the time. Great job on that.

Share this post


Link to post
Share on other sites
Thanks!

other thread

It fits the camera view frustum perfectly, although I've heard an other way: Get the bounding sphere of the camera view frustum, and fit the light view volume on that. That way you can reduce the shadow edge flickering caused by the texels.

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