Sign in to follow this  
codpp

opengl shadow mapping

Recommended Posts

codpp    146

I'm currently learning how to do shadow mapping from online tutorials. As far as I know, this technique involves 

two passes from shader. The first one is from light's view, and store the final image into a depth texture, in which

all pixels are actually just floating point of depth. The second pass is from camera's view using normal method.

 

The part I don't understand is why the technique compares these two final images with their depth values. Since

the cameras' angles (camera's and light's) are different, how can they be compared? 

Share this post


Link to post
Share on other sites
NumberXaero    2624

During the second pass the depths are created from projecting the vertices into lights pov, then the comparision is made.

So say theres some point A, and the light can see it (so the depth lands in the shadow map). Behind it theres another point B, and the camera can see it, but the light cant (say the triangle A belongs to is blocking B from being seen in the lights pov).

When B is projected into the lights pov in the second pass, it generates a second depth, larger (further away) then the one stored by A, B must be in shadow, because its behind A, B depth is larger for the lights pov (say the triangle A belongs to casts a shadow on B).

Without getting too complicated and drawing pictures thats the best I can do.

Edited by NumberXaero

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