Jump to content
  • Advertisement
Sign in to follow this  
McZ

shadow maps question

This topic is 4965 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been reading alot of different tutorials and stuff here on this forum, but one thing I havn't understand yet is if I need one depthmap for each light that cast shadows? but then I need to activate all of them at the same time when doing the test against the depthmap?

Share this post


Link to post
Share on other sites
Advertisement
Yes, you need a separate depth map for each lightsource. When rendering the shadowed geometry, you perform as many tests as there are lights, and somehow combine the results. I said "somehow", because different people use different methods, it's more often than not an artistic decision. The physically most correct way is to add the light contribution of all sources together, each one multiplied with the shadow comparison factor of its depth map.

1) Start by rendering each light to its individual depth surface

2) Bind each surface to a separate texture (imaging) unit.

3) Set up a depth compare for each unit, making sure that the generated projected texture coordinates for each unit match the one of the respective lightsource.

4) Use the following equation per pixel:

c(final_light) = c(light0) * depthCompareResult(0) + c(light1) * depthCompareResult(1) + ...

5) Multiply the c(final_light) with whatever diffuse texture or colour you might need.

Share this post


Link to post
Share on other sites
I have a question relating to Shadow maps.. I think I sort of understand how the process of setting up the depth map works, but what I dont understand is the rendering process.. (basically) how does the texture create these shadows on the screen, and do you use a textured quad in front of the camera? I know a quad is involved somehow, but.. I just don't see how it all fits together at the moment. Maybe someone could direct me to a nice explanation of shadow mapping.

Share this post


Link to post
Share on other sites
A couple of shadow map links:

nVidia paper

Paul's Projects tutorial

To provide a bit of answer to your question Mikey, shadow mapping makes use of projective texturing, to project the shadow map onto the geometry into the scene. Using this you can easily figure out which texel in the shadow map applies to the particular part of the geometry you are rendering, and thus know if it is in shadow or not WRT the light source.

-Mezz

Share this post


Link to post
Share on other sites
The depth map is projected onto the shadow receivers, so the uv coords are generated. The nVidia paper that Mezz posted is a very good reference, especially when you first start to learn about shadow maps.

Share this post


Link to post
Share on other sites
ok, I'll look into the nVidia paper... but so far I can't really understand how the shadow maps can be valid at the same time.. this will cost alot of texunits? or do I create an extra pass that project all of them into one big depthmap and use that one only?

Share this post


Link to post
Share on other sites
Quote:
Original post by McZ
I can't really understand how the shadow maps can be valid at the same time..


I'm not sure I understand this question. If you have one shadow map for each light, then render the scene from each light's POV into their shadow maps, then all the shadow maps contain valid information. After you've done this, you can use these shadow maps when drawing your actual scene from the viewer's perspective, to tell whether certain objects are in shadow or not.

Quote:
Original post by McZ
this will cost alot of texunits?


It will if you do multiple lights in one pass, but you can do a pass per light and only bind one of your shadow map textures at a time, hence only using one texture unit.

Quote:
Original post by McZ
or do I create an extra pass that project all of them into one big depthmap and use that one only?


I've never heard of this as a technique, so I couldn't recommend it.

-Mezz

Share this post


Link to post
Share on other sites
ahh thank you! now I understand :)

I use up all tex units I have free for a pass.. but what if my texunits isn't enough for one pass? how do I split it into several passes? do the extra passes also need depthmap testing?

and what to do if I have more depthmaps then tex units?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!