Shadow volumes optimization
Moderator: InsideQC Admins
13 posts
• Page 1 of 1
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...
-

Barnes - Posts: 226
- Joined: Thu Dec 24, 2009 2:26 pm
- Location: Russia, Moscow
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.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
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.
-

revelator - Posts: 2567
- Joined: Thu Jan 24, 2008 12:04 pm
- Location: inside tha debugger
Re: Shadow volumes optimization
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.
Yes, I know how it was done. I is not hard to do, but I do not see the need (only speed falls)
-

Barnes - Posts: 226
- Joined: Thu Dec 24, 2009 2:26 pm
- Location: Russia, Moscow
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.
-

revelator - Posts: 2567
- Joined: Thu Jan 24, 2008 12:04 pm
- Location: inside tha debugger
Re: Shadow volumes optimization
reckless wrote:Just an optiondoom3 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.
Yes i saw it. http://www.uraldev.ru/articles/files/45/carmack_quakecon2004_eng.txt Carmak about doom3 and experemental render path with shadow buffers
-

Barnes - Posts: 226
- Joined: Thu Dec 24, 2009 2:26 pm
- Location: Russia, Moscow
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.
-

revelator - Posts: 2567
- Joined: Thu Jan 24, 2008 12:04 pm
- Location: inside tha debugger
Re: Shadow volumes optimization
I decided to use only the z-fail vulumes. Geometry as I said simple and large overload will not be
-

Barnes - Posts: 226
- Joined: Thu Dec 24, 2009 2:26 pm
- Location: Russia, Moscow
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 :S) 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
Productivity is a state of mind.
-

revelator - Posts: 2567
- Joined: Thu Jan 24, 2008 12:04 pm
- Location: inside tha debugger
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 
-

Barnes - Posts: 226
- Joined: Thu Dec 24, 2009 2:26 pm
- Location: Russia, Moscow
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
- Spiney
- Posts: 63
- Joined: Mon Feb 13, 2012 1:35 pm
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 :S 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.
-

revelator - Posts: 2567
- Joined: Thu Jan 24, 2008 12:04 pm
- Location: inside tha debugger
Re: Shadow volumes optimization
Spiney 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
Original d3 use light scissors and depth bounds, but depth bounds test work only on gf anf lastest ati cars
-

Barnes - Posts: 226
- Joined: Thu Dec 24, 2009 2:26 pm
- Location: Russia, Moscow
13 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest