Sign in to follow this  

optimizing for multiple shadow maps

This topic is 3199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, I have started to set up my code to use multiple shadow maps and lights but I do not want to draw the whole scene for every shadow map. Is it possible to do something so I can prevent this?? thanks

Share this post


Link to post
Share on other sites
Frustum culling. Also you should only draw shadow casters, beside the usual optimizations (draw flat, etc). I also don't bind textures and pass texture coordinates to polygons that don't have alpha on its texture.

Share this post


Link to post
Share on other sites
Quote:
Original post by biraneto
Frustum culling.


Currently my whole scene is in one large OBJ file. And everything I have read abut frustum culling tells me I will need to test my objects to see if they intersect, obviously it will and this will just cost me time. Or am I missing something??

Share this post


Link to post
Share on other sites
Sorry... I thought your scene was something like an open area with trees, etc. Frustum culling is only usefull if you are not looking the whole thing all the time.

Share this post


Link to post
Share on other sites
Quote:
Original post by biraneto
Sorry... I thought your scene was something like an open area with trees, etc. Frustum culling is only usefull if you are not looking the whole thing all the time.


Well, when using multiple shadowmaps, then they're hopefully not all 'looking'/covering at the entire scene :)
So frustum culling would be good when rendering into the shadowmaps.

Share this post


Link to post
Share on other sites
Quote:
Original post by stein
Quote:
Original post by biraneto
Sorry... I thought your scene was something like an open area with trees, etc. Frustum culling is only usefull if you are not looking the whole thing all the time.


Well, when using multiple shadowmaps, then they're hopefully not all 'looking'/covering at the entire scene :)
So frustum culling would be good when rendering into the shadowmaps.


I more the likly will add frustum culling later, but right now it would be pointless, so I am looking for other ways to optimize drawing the shadows to the scene.

Share this post


Link to post
Share on other sites
Quote:
Original post by cherryyosh
I more the likly will add frustum culling later, but right now it would be pointless, so I am looking for other ways to optimize drawing the shadows to the scene.


If it's pointless to add frustum culling, then why do you want to optimize?
What's the problem at hand?

Share this post


Link to post
Share on other sites
How about this: you have/copy the depth-buffer of your scene as/to a texture.
You draw a fullscreen quad per shadowmap, in multiply-mode blending.
Knowing your MVP matrix, x:y position at pixel, and depth - you get a vec3 of where the texel is in world-space. You fetch info from shadowmap: whether/how-much this vec3 is shadowed. Return that result in gl_FragColor. Scene color gets blended (darkened) where there are shadows.

Needs shaders and maybe some funky math. Haven't tried to code it, but it's been used in Crysis.

I bet it can even speed-up rendering, by keeping cache locality and for a lot of similar reasons.

Share this post


Link to post
Share on other sites
I've got parallel-split shadow map code that renders the scene multiple times, so I've also approached the issue of optimizing for multiple shadow maps.

For me, the biggest performance win was in the elimination of material state changes while in depth-only rendering mode. Most surfaces are opaque, which means that their material doesn't matter during shadow map rendering. This means you can merge the geometry of all opaque surfaces into a single large element buffer and render in one pass using a trivial shader. After that, any alpha masked materials are rendered one-by-one.

I actually keep two sets of element buffers: one for color mode and another for depth-only mode. The result is a drastic reduction in batch count, program switching, and texture binding.

Share this post


Link to post
Share on other sites
* Depending on your hardware, rendering all shadow maps simultaneously into a texture array in a single pass using geometry shaders can give large speedups.

* Many GPUs have a special highly optimized depth-only rasterization mode, which gets enabled under certain circumstances (read NVidias GPU programming guide).

* CSM/PSSM have a multitude of other, more obscure optimization possibilities, due to the mathematical relationship between the individual maps (ie. they aren't arbitrarily positioned).

* Frustum culling is vital, especially in CSM/PSSM.

* Use smaller shadow maps with a filterable shadow representation (VSM, ESM, ACDF SM) rather than the standard depth value with large maps and PCF.

* Some more aggressive forms of occlusion culling can be used for CSM/PSSM based systems.

Share this post


Link to post
Share on other sites

This topic is 3199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this