How to prevent volume shadows from going through walls?

I don’t get your calculation Korval. Don’t you need for shadow mapping

  • 1 pass for ambient
  • n passes for rendering the scene into the shadow-map
  • n passes to add light to the scene per lightsource

too?
No.

You need n passes for each light. Then, you have 1 pass for the geometry, using n separate depth textures.

Granted, for 50 lights, you’ll need several passes. But you’ll need far from 50 separate passes. Plus, because you’re not destroying your depth buffer (which you have to do with shadow volumes) between each pass, you can take advantage of an automatic depth-first pass to use early z-culling of fragments.

Now, do some (perhaps many) people do shadow mapping that way? Yes. However, this is often for other reasons. Fragment shader length is one; this allows them to have effectively longer fragment shaders than you execute in one pass, as long as the shader code for each individual light can fit.

But that has nothing to do with the shadow mapping algorithm itself; the algorithm allows for the possibility of using n+1 passes.

Additionally, for shadow-mapping you might need more than one pass to create the shadow-maps, depending on the used technique (and some other factors).
Perhaps, but:

1: These are not full scene passes. Just passes over objects in that part of the scene.
2: You’re not using up vast quantities of fillrate rendering large overlapping volumes like you are with shadow volume rendering.

Granted, for 50 lights, you’ll need several passes.
Are you sure about that?

Originally posted by Korval:
You need n passes for each light. Then, you have 1 pass for the geometry, using n separate depth textures.

With geometry shaders is should be possible to render several shadowmaps simultaneously altrough that is likely to be advantageous only for specific scene & light setups.


Plus, because you’re not destroying your depth buffer (which you have to do with shadow volumes) between each pass

There is no destroying of depth buffer in shadow volumes, actualy they depend on the depth buffer containing correct values to work. Only the stencil must be cleared.

Originally posted by Leghorn:
[quote]Granted, for 50 lights, you’ll need several passes.
Are you sure about that?
[/QUOTE]I think his point was to tell that you might end with more passes not to tell exact value which depends on capabilities of the hw such as number of shader instructions, uniforms, samplers, size of textures and support for array textures.

Of course you can pack 64 256x256 shadowmaps into one 2048x2048 texture if you wish and if you fit into shader length and uniform size limit.

There is still deffered shading, which requires one pass for scene rendering into the big buffer + n passes for n lights.

The disadvantage of this technique is one big render texture to hold all the data, but with next generation hardware that should not be a performance issue :slight_smile:

Regards,
dReddi

Please stop the thread hijacking!

If you have that much time, why don’t you help me along with my questions in my thread about soft volumetric stencil shadows?

You guys all seem to know so much, but if asked for details, hardly ever tell a noob what he needs to know. :slight_smile:

My trick is to compute the closest wall in the way of an object’s shadow, increase that distance by some factor and cap the shadow volume there. That will not always give me perfect shadows, but for my application works sufficiently well.

You can do an exact intersection of the shadow volume with the wall and clip the shadow volume to the wall plane, that way you will have the exact vizibile shadow frustum.
In fact, this is the way it should be done for static geometry with precalculated shadow volumes.

I don’t understand though why you wouldn’t want to make walls cast shadows too…

Originally Posted by karx11erx
You guys all seem to know so much, but if asked for details, hardly ever tell a noob what he needs to know.
I think the noob needs to pull his head in and read the thread again. You’ve been given the solution - but you sound like you’re too lazy to do it for yourself. In pretty much all your posts you’ve come back with a smart arsed response.

Originally posted by Jan
The moment you calculate shadows for some objects, you need to do so for all objects in you scene, including your static geometry
Go off, change your engine to calculate shadow volumes for the static geometry (ie. Walls) and see what happens. Then you can come back and bitch that Jan didn’t provide you with a solution.

Thanks rgpc.

  1. Common mistake is that people do not read carefully about what shadows are before they implement it. Shadows do NOT darken the scene - shoadows only tell what pixels can receive lighting from particular light source.

  2. If your wall does not cast shadow, then all objects on one side of wall can receive light from light source on other side of wall. That’s wrong and that’s why wall needs to cast shadow.

  3. You can optimize your application using some precomputed visibility list that will tell you that some areas NEVER receive light from a light source. This can be done for lights that do not move and for lights that move in restricted area. If you do that, then you don’t need to cast shadow from a wall since your light does not affect anything that’s on the other side of the wall.
    So, even if your shadow goes trough a wall, you don’t see it on the other side, because “shoadows only tell what pixels can receive lighting from particular light source” and you allredy know that pixels on the other side do not receive light.

End of discussion…

@karx11erx

I am a little late to join this discussion… you could still use stencil shadows if you are not using z-fail (if your cam is above these rooms, like strategy game), and if your rooms have straight walls, you can cut shadow volume which you use to fill stencil buffer with clipping planes that you position in each wall. I think you can have up to 8 clipping planes in one time.

of course, this means that shadow will be “cut” even on “passages”… but maybe in level design you could solve this somehow.

p.s.

also, in level design, artist can create shadow volumes for all static object, for all static light sources. this way you would not need to calculate + clip them.

if artist uses 3dsmax, you can easily write plugin that will generate shadow volume depending on the lights artist created in the scene.

for dynamic lights or moving objects, if walls are thick, you can generate shadow volume objects that are shorter than wall thickness. this way their shadows will not go through them.

but honestly, the best would be to cast shadow volumes for all objects in the scene. you could use “modeled” shadow volumes (which can be optimized a lot, since manually modeled) and calculated ones.