Shadow volumes optimization
Shadow volumes optimization
Some time ago i add "doom3 style" lighting in to my engine. First version was very slow, like 30-40fps.With some optimizations i'm get big speedup. Now i use
1 - frustrum, pvs and occlusion query lights culling
2- two side stencil
3- draw shadow volumes with precompiled static vbo
4- light scissors
5- light depth bounds
That make the new? Use z-pass volumes? Q2 geometry very simple, I'm not sure that this is an advantage in comparison with Carmack reverse...
1 - frustrum, pvs and occlusion query lights culling
2- two side stencil
3- draw shadow volumes with precompiled static vbo
4- light scissors
5- light depth bounds
That make the new? Use z-pass volumes? Q2 geometry very simple, I'm not sure that this is an advantage in comparison with Carmack reverse...
Re: Shadow volumes optimization
z-pass means that you can skip caps. it can be an effective optimisation as it means you only draw edges and don't have quite so much fill rate (stencil shadows are quite expensive in fillrate, of course). z-pass will not work if the view is in shadow, but will be faster in the cases where it does work. The trick is writing the code to decide whether its safe to use z-pass for each individual light.
one potential optimisation is to optimise your shadow volumes to avoid excessive overdraw which can greatly help in when given complex geometry.
the main issue imho with complex geometry is not the extra fillrate that results from it, but rather the cpu costs from working out whether each triangle surface is facing the light or not. With the world, this can be precompiled and with the extra filling clipped away, but moving models will need to be animated and rechecked every single frame.
Most people seem to prefer shadowmapping nowadays. Softer shadows are generally nicer and much less harsh. The real advantage though is that you don't have to generate lots of shadow edges based upon surface normals, meaning you can just push the entire mesh to the gpu in one... or 6 rather... goes. As a result, it can scale much better at higher detail levels. Especially if you can ensure that they're spot/sun lights.
Is the theoroy, anyway.
one potential optimisation is to optimise your shadow volumes to avoid excessive overdraw which can greatly help in when given complex geometry.
the main issue imho with complex geometry is not the extra fillrate that results from it, but rather the cpu costs from working out whether each triangle surface is facing the light or not. With the world, this can be precompiled and with the extra filling clipped away, but moving models will need to be animated and rechecked every single frame.
Most people seem to prefer shadowmapping nowadays. Softer shadows are generally nicer and much less harsh. The real advantage though is that you don't have to generate lots of shadow edges based upon surface normals, meaning you can just push the entire mesh to the gpu in one... or 6 rather... goes. As a result, it can scale much better at higher detail levels. Especially if you can ensure that they're spot/sun lights.
Is the theoroy, anyway.
Re: Shadow volumes optimization
soft shadows are also doable with stencil volumes, albeit a bit hacky in doom3 since Theres no depth texture access sikkmod uses a small hack to emulate one.
Speedwise its even worse than sheer stencil volumes though and because of the hack it suffers from a bit of the same problem that SSAO does in sikkmod.
Speedwise its even worse than sheer stencil volumes though and because of the hack it suffers from a bit of the same problem that SSAO does in sikkmod.
Productivity is a state of mind.
Re: Shadow volumes optimization
Yes, I know how it was done. I is not hard to do, but I do not see the need (only speed falls)reckless wrote:soft shadows are also doable with stencil volumes, albeit a bit hacky in doom3 since Theres no depth texture access sikkmod uses a small hack to emulate one.
Speedwise its even worse than sheer stencil volumes though and because of the hack it suffers from a bit of the same problem that SSAO does in sikkmod.
Re: Shadow volumes optimization
Just an option doom3 actually has an experimental renderer in Draw_exp.cpp that utilized shadowmapping but the shaders were missing in the final release.
It was rather nasty though using the wgl extentions instead of newer ARB ones but it gave an idea on how to get it.
It was rather nasty though using the wgl extentions instead of newer ARB ones but it gave an idea on how to get it.
Productivity is a state of mind.
Re: Shadow volumes optimization
Yes i saw it. http://www.uraldev.ru/articles/files/45 ... 04_eng.txt Carmak about doom3 and experemental render path with shadow buffersreckless wrote:Just an option doom3 actually has an experimental renderer in Draw_exp.cpp that utilized shadowmapping but the shaders were missing in the final release.
It was rather nasty though using the wgl extentions instead of newer ARB ones but it gave an idea on how to get it.
Re: Shadow volumes optimization
Biggest issue if fixing the exp renderer would be that the shadowmaps only Work on entities not on the World, so the World shadows would still be stencil volumes.
Someone WHO knows more about it than me could probably fix that oversight though
Someone WHO knows more about it than me could probably fix that oversight though
Productivity is a state of mind.
Re: Shadow volumes optimization
I decided to use only the z-fail vulumes. Geometry as I said simple and large overload will not be
Re: Shadow volumes optimization
Your latest svn build seems to have reasonably nice shadows quite a bit better than doom3's even.
Nice Work i love your parallax shader also, would be damn nice to get that one working in Doom3 but as far as i know the problem is material based (well not really cause it applies the effect on every damn surface ) id rather have a material based version that way i could apply the effect on select surfaces only. Hmm i hope someone can lend a hand with that part someday as it seems i have taken over maintainance off sikkmod heh
Nice Work i love your parallax shader also, would be damn nice to get that one working in Doom3 but as far as i know the problem is material based (well not really cause it applies the effect on every damn surface ) id rather have a material based version that way i could apply the effect on select surfaces only. Hmm i hope someone can lend a hand with that part someday as it seems i have taken over maintainance off sikkmod heh
Productivity is a state of mind.
Re: Shadow volumes optimization
Thanks for the tip, but you overestimate my contribution in to parallax shader. I just optimized for speed is what you can see in qfusion or in dark places. The idea is simple as a couple of cents
Re: Shadow volumes optimization
I think D3 BFG added some optimizations found in this talk to reduce overdraw, at least I noticed some console variable...
http://www.terathon.com/gdc05_lengyel.pdf
http://www.terathon.com/gdc05_lengyel.pdf
Re: Shadow volumes optimization
Still quite nice Work only recently started looking into C++ seriously and learning a new language like ARB assembly / GLSL is pretty hard at my age C++ was doable because it shares some parts with C but still yikes!!!. You do not want to know how long it took for me to get the ARB watershader working in my realm engine
Productivity is a state of mind.
Re: Shadow volumes optimization
Original d3 use light scissors and depth bounds, but depth bounds test work only on gf anf lastest ati carsSpiney wrote:I think D3 BFG added some optimizations found in this talk to reduce overdraw, at least I noticed some console variable...
http://www.terathon.com/gdc05_lengyel.pdf