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
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).
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.
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
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.
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…
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.
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.