Stencil Shadowing Demands

swaaye

Entirely Suboptimal
Legend
Supporter
I've tried toggling the shadows in Doom3 and noticed that it's just a totally massive drain on the framerate. Without it I can maintain 40-50fps in the game, while with it on, framerates can drop into the teens....this is on my notebook's 9600 @ 450/230.

I've noticed this as well in other games which have limited optional stencil shadows, such as Elite Force 2.

Can someone explain for me what is so demanding about these shadows that it can drop GPU performance by 2/3? The shadows certainly don't look THAT good or seem THAT complicated.
 
Well, that's stencil shadows for you. While stenciling is very cheap, it can be extremely demanding when it covers half the screen, and that just for one light. It's very fillrate demanding. There are tricks to cut down that work though such as using a scissor rectangle, depth bounds or clipping planes. But still, shadow mapping will still be faster in most situations, which is also one of the main reasons I prefer that technique.
 
I've been thinking that shadow mapping would have been sufficient for Doom 3. The aliasing that occurs as a result of low texture resolution probably wouldn't be much of an issue, given that the radius of the average light in Doom 3 appears to be quite low.
 
Shadow map is more expensive regarding to point lights (a cube map is required). Apparently there are a lot of point lights in Doom 3 (such as the imps' fireballs). However, shadow map is more "compatible" to current GPU development.
 
Well, that's stencil shadows for you. While stenciling is very cheap, it can be extremely demanding when it covers half the screen, and that just for one light. It's very fillrate demanding.

Yeah, but they're so cool toss in fog... :p
 
You mean for volumetric effects, right? With shadow mapping and projective texturing, you can achieve much better volumetric effects.
 
Shadow map is more expensive regarding to point lights (a cube map is required). Apparently there are a lot of point lights in Doom 3 (such as the imps' fireballs). However, shadow map is more "compatible" to current GPU development.
That depends on geometric complexity as well. Cubic shadow mapping would give much better performance with a 10-20K poly model than would stencil shadowing.
 
AFAIR they are generating long thin triangles, which is very hardware unfriendly. (page breaks...) [ask Simon Fenney he knows that better than I]

Stencil Shadows produce obvious artifacts with self shadowing and fragment shaders changing depth/displacing surface, such as the Parallax mapping fragment shader.
 
A rough summary:

Stencil shadows:
+ more robust method of shadowing
+ supported easily by all modern cards
- very fillrate heavy
- quite geometry heavy
- can also be CPU heavy if volumes are extruded on CPU
- only hard-edged shadows

Shadow maps:
+ can do soft-edged shadows
+ excellent for highly controlled scenes (camera & object positions well known)
+ CPU light
+/- can also be geometry heavy
+/- can also be fillrate heavy
- not very robust, easy to break
- self-shadowing often a problem

Basically, a question under current active research is 'Once all the problems with shadow maps in fully dynamic scenes have been fixed, are they better than stencil shadows?' I think that the fact they are better suited to soft shadows will likely be the key in the long run.
 
pcchen said:
Shadow map is more expensive regarding to point lights (a cube map is required). Apparently there are a lot of point lights in Doom 3 (such as the imps' fireballs). However, shadow map is more "compatible" to current GPU development.

I believe there's also something called dual paraloid shadow maps, altough I think they suffer from aliasing.
Anyway it's a 'virtual' cube map, since you don't have 6 textures, but you can put all 6 (or less) projections at different resolutions inside the same texture to reduce state change.
Only needs so fragment shaders ops to access correct 'face'.

Anyway Shadow Maps are *way* faster than stencil shadow volumes, in most circumstances.
 
Humus said:
Well, that's stencil shadows for you. While stenciling is very cheap, it can be extremely demanding when it covers half the screen, and that just for one light. It's very fillrate demanding. There are tricks to cut down that work though such as using a scissor rectangle, depth bounds or clipping planes. But still, shadow mapping will still be faster in most situations, which is also one of the main reasons I prefer that technique.

And what do you think about the Hybrid-Stencil-Shadowing-Shadow-Mapping Algorithm?
 
Since it's still hard shadows I don't find it all that interesting. If you're going to spend that amount of effort into generating shadows, you may want to aim at soft shadows instead.
 
Silent Hill 3 for the Sony Playstation2 does soft-edged stencil shadows. Well, it's not stencils, since the hardware lacks a stencil buffer, but it has the means to do the equivalent of a stencil buffer as I understand it... Just check out the diner scene in the beginning of the game with the blinds n stuff, very impressive. It also self-shadows, not that I feel that is very important in a game as I tend to miss things like that when playing anyway.
 
Guden Oden said:
Silent Hill 3 for the Sony Playstation2 does soft-edged stencil shadows. Well, it's not stencils, since the hardware lacks a stencil buffer, but it has the means to do the equivalent of a stencil buffer as I understand it... Just check out the diner scene in the beginning of the game with the blinds n stuff, very impressive. It also self-shadows, not that I feel that is very important in a game as I tend to miss things like that when playing anyway.

I think you mean something like this Shadow Volume Algorithm using an Alpha-buffer of Framebuffer with OpenGL to simulate an Stencilbuffer without penalty ( at least on an Geforce2 MX ) :

Shadow Volumes Revisited
 
Guden Oden said:
Silent Hill 3 for the Sony Playstation2 does soft-edged stencil shadows. Well, it's not stencils, since the hardware lacks a stencil buffer, but it has the means to do the equivalent of a stencil buffer as I understand it...
It simulates stencil counting with alpha blending ops - it's equivalent math, and on PS2 the color only rendering is 2x faster too.
IIRC first PS2 game with soft-edged volume shadows was ICO (I think it came out before SH2) - and they were followed by many others.

Speaking of performance characteristics, at 640x480 with 2.4GPix the volume rendering is still fillrate limited 90% of the time - and that's with silhouette tracing&extraction on "GPU" side.

How about someone finally make irregular rasterizer hw for shadowmaps :p Would save everyone lots of headaches...
 
Ingenu said:
I believe there's also something called dual paraloid shadow maps, altough I think they suffer from aliasing.
I thought the primary problem with dual parabaloid mapping was that it takes longer to construct them (it's not a linear mapping), which pretty much removes the possibility of using them for realtime shadowing.
 
Chalnoth said:
I thought the primary problem with dual parabaloid mapping was that it takes longer to construct them (it's not a linear mapping), which pretty much removes the possibility of using them for realtime shadowing.

I suppose the general approach for realtime use would be to render to cubemap faces first, then map each cubemap face to the proper place in the paraboloid maps.
It can be done in realtime, but it's only useful for hardware which doesn't support cubemapping, I guess. And hardware that doesn't support cubemapping, most probably doesn't have the precision or speed required anyway.
 
Fafalada said:
How about someone finally make irregular rasterizer hw for shadowmaps :p Would save everyone lots of headaches...
What kind of irregular rasterizer? Is there previous discussion about this?
 
Back
Top