PDA

View Full Version : heavy Stencil Shadows



aje1234l
03-08-2015, 12:11 PM
Hello i am creating a 3d world with opengl and i recently apllied shadows with the stencill buffer. The shadows looks perfect but i have a problem.
Stencil shadows are extremelly heavy rendering when i use it to all my objects in scene( i mean when all objects casts shadows ). The scene consists of buildings
and trees and free roaming between them. Is there a way to make the shadows more easy rendering?
I used display lists but the performace increased a little. Is there a way to store the shadow matrix in some array and use it latter.

Thanks...

Dark Photon
03-08-2015, 12:49 PM
Hello i am creating a 3d world with opengl and i recently apllied shadows with the stencill buffer. The shadows looks perfect but i have a problem.
Stencil shadows are extremelly heavy rendering when i use it to all my objects in scene( i mean when all objects casts shadows ).

Yep.


The scene consists of buildings and trees and free roaming between them. Is there a way to make the shadows more easy rendering?

There are things you can do to try and reduce the hit of stencil shadows, but there are no two ways about it: They can be very heavy on fill, if you can't bound the drivers of that fill. For instance, a tiny projected shadow from a complex object can require multiple layers of fill extending across the entire screen! Ouch!

Some things to look at: cull your shadow volumes (if one can't intersect the view frustum, or cast a shadow on anything within it, then...), two-sided stencil, depth pass instead of depth-fail when you can, and that's just getting started.

You may instead want to consider a shadow map-based approach. They've got their quirks, but they're not such fill pigs (or state change pigs). They're much easier on the CPU side, and the GPU-side (being depth-only) is lightning fast. You'll still want to cull objects into your shadow frustum (or frusta) intelligently, but beyond that, just toss it all at the GPU and let it sort it out.