Jump to content

  • Log In with Google      Sign In   
  • Create Account


Shadow maps update optimization


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 solenoidz   Members   -  Reputation: 504

Like
0Likes
Like

Posted 27 September 2012 - 11:09 PM

Hello.
I'm thinking, is there a way to prevent shadow maps to render every single objects, that is in light's range every frame, and still sustain visual quality ?
Let's say, I have a sun light source, a small terrain, a few trees and and a wooden box that is controlled by physics. Now I need to shadow this scene. The naive approach would be to render the terrain, the trees and the box every frame into the light's depth map.
Since light do not move relative to the terrain and the trees, can I just render them once into the light's depth map, and only render the wooden box every frame, since it is rolling downhill, for example.

Is there any way to only re-render objects that are in motion relative to the light ?


Thank you.

Edited by solenoidz, 27 September 2012 - 11:13 PM.


Sponsor:

#2 Ashaman73   Crossbones+   -  Reputation: 5837

Like
1Likes
Like

Posted 27 September 2012 - 11:33 PM

Is there any way to only re-render objects that are in motion relative to the light ?

Yes, but I would take a few steps back first.

Caching a lightmap scene with static objects is ok, but I would not be surprised if the cache didn't survive very long. The reason is, that shadowmapping really suffers from a lot of artifacts and therefore you often try to maximize the shadow map density and doing other tricks depending on light source and the camera. Using techniques like CSM often only renders the shadowmaps directly in front of the camera, which means, that turning the camera would often invalidate the cache.

On the other hand, drawing only to the depth buffer is really fast. IMHO the benefit of such an optimization is questable and often other parts of the pipeline have a much heavier impact on the performance. And adding animation for trees and grass would make most of the effort obsolete.

Edited by Ashaman73, 27 September 2012 - 11:36 PM.


#3 solenoidz   Members   -  Reputation: 504

Like
0Likes
Like

Posted 28 September 2012 - 12:00 AM

Thank you, I always appreciate your help.
Yes, I'm using CSM, but as you said later on, animation for trees and grass makes most of the effort obsolete, because I still need to render the distant trees animated shadows, especially when they cast long shadow from the low sun, and the vector sun-camera direction approaches sun-tree direction.
Ok, lets think of light sources that cast cube-shadows in an indoor environment. If I have a house mesh, and in one of the rooms, I have a light that do not move and cast omnidirectional cube-map shadows, can I cache the light depth map instead of re-render the whole house 6 times every frame ?

Edited by solenoidz, 28 September 2012 - 12:03 AM.


#4 Ashaman73   Crossbones+   -  Reputation: 5837

Like
0Likes
Like

Posted 28 September 2012 - 02:07 AM

Ok, lets think of light sources that cast cube-shadows in an indoor environment. If I have a house mesh, and in one of the rooms, I have a light that do not move and cast omnidirectional cube-map shadows, can I cache the light depth map instead of re-render the whole house 6 times every frame ?

Yes, caching is valid.

But caching is between static and dynamic shadows, so if you want static shadows, lightmaps would be the best quality solution, if you want dynamic shadows, you need to render it each frame, at least parts of it.

The question is, if you cache i.e. the static house mesh and render only the characters to the shadow map, is the benefit really that great ? You need to copy the static zbuffer first, then render the dynamic part to it. On the other hand, using a shadow-mesh (lower polycount) and some culling algorithms (i.e. portals for indoor scenes), the house rendering might be only a fraction of the whole scene rendering, considering that you need to copy the zbuffer (bandwidth).

#5 MJP   Moderators   -  Reputation: 8756

Like
0Likes
Like

Posted 28 September 2012 - 02:09 AM

The issue I always come back to when thinking about caching for shadow maps is that it often does nothing to improve your worst-cast performance, which is really bad for games. It's pretty hard to come up with a caching scheme that won't cause you to completely re-render your shadow map for certain cases, at least not without dramatically increasing memory requirements.

Edited by MJP, 28 September 2012 - 02:11 AM.


#6 kauna   Crossbones+   -  Reputation: 1899

Like
0Likes
Like

Posted 28 September 2012 - 05:41 AM

Hi,

It is perfectly fine to have a shadow map for static objects and another one for dynamic objects. The disadvantages have been discussed earlier in this post, but there is something to clarify, You may mix your static and dynamic shadow maps in pixel shader pretty easily without any pre-mixing of the shadow maps.

At this moment I'm using one huge shadowmap for static objects and 2 levels of CSM for dynamic objects. With densely populated terrain the performance gain is noticeable. The static shadow map is rendered around the player position so it isn't invalidated by changing the camera direction. I update the bigger shadow map every few seconds.

The biggest problem with the static shadow map is the terrain level-of-detail which changes often enough. When the camera moves fast (faster than typical player movement) the geometry in the shadow map may not be up to date and some false shadows may appear on the terrain.

Otherwise to optimize the shadow map update I render often lower resolution model for trees and such objects since it's really difficult to see such small errors in the shadowmap. Also, for updating the CSMs, I use geometry shader to direct drawing to multiple slices of a texture array (don't use GS for instancing since it's not made for it).

Best regards!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS