Skip to main content
GameDev.net gamedev.net
🔒 Locked

Shadow mapping - near and far

Started by lsdogsdnbgj May 18, 2013 at 3:41 PM 5 replies 1.4k views
Original Post
lsdogsdnbgj
lsdogsdnbgj

Hi everyone,

At the moment, I'm using my shadow mapping technique to make a small object cast a shadow onto the terrain from a fairly large distance. However, this means that I have insufficient depth resolution for the object to perform self shadowing, which I would also like. So, how can I create a shadow map with sufficient depth resolution to create self-shadowing, but also allows the shadow to extend out onto the distant terrain? It might help to know that my small object is always going to be in front of the terrain.

Thanks for the help!

kubera
kubera

You would consider rendering two shadows independently with different math parameters

and then merge theirs output textures into one shadow by the HLSL.

It would be less efficient (two shadows processed).

lsdogsdnbgj
lsdogsdnbgj

Thanks for the reply - I did consider doing this, and I think it might be the only way! I have noticed that a lot of games manage to render both self-shadowing and also shadows of distant objects like trees and buildings. Do they do a similar thing?

menohack
menohack

If you are trying to cast a large shadow from a small object onto terrain you should be using a directional light (orthographic) since you are imitating the sun. Orthographic projections do not depend on distance so you can make the shadow map perfectly centered around the caster even if it is infinitely far away.

lsdogsdnbgj
lsdogsdnbgj

That's what I'm doing at the moment - the only problem is that the terrain is so distant that the depth resolution isn't good enough to allow for self shadowing as well as the casting of the distant shadow.

menohack
menohack

Use multiple shadow maps for a single light. One shadow map contains only your lunar lander while the other has the entire scene. When you draw the lander switch to the new shadow map. When you draw the terrain switch to the other one. This requires two depth passes and an extra shader resource view of another depth texture.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.