Refresh and Expiration for Shadow Maps
- Last UpdatedApr 07, 2023
- 2 minute read
Refreshing Shadow Maps
A light.shadow\refreshFrameRate parameter prevents rendering too many Shadow Maps each frame.
-
refreshFrameRate= 0 à The Shadow Map is generated only once.
-
refreshFrameRate= n à The Shadow Map is generated n times per second (for example, 5 means the map is generated five times per second)
This parameter is per Light, but it can be scaled by the global shadowMaps\textureRefreshMultiplier parameter.
-
value = light.shadow\refreshFrameRate x shadowMaps\textureRefreshMultiplier
Negative 'refresh'
When refreshFrameRate is a negative value, the Shadow Map is generated every frame:
-
refreshFrameRate= -1 à The Shadow Map is generated every frame.
-
refreshFrameRate= -10 à Same as above, but textureRefreshMultiplier is not considered.
By using -1, you can stop the generation when textureRefreshMultiplier is set to 0.
By using -10, the Shadow Map repeatedly generates.
Automatic refresh
A Shadow Map can be aware of when it must be generated. If nothing moves inside the Light's frustum, there is no need to regenerate.
This feature works only for Human objects. The light.shadow\refreshOnHumans parameter activates it.
To use this feature, set the refreshFrameRate to 0 and enable this flag.
Shadow Map Expiration
Shadow Map buffers that are not used for a number of frames can release the video memory to other Shadow Maps that need it.
For example, because a Light does not cast shadows anymore, or it is no longer visible in the scene.
Regulate expiry time
Regulate the expiration time with the global shadowMaps\textureExpirationTime parameter.
-
textureExpirationTime = 0 à Shadow Maps never expire.
-
textureExpirationTime = n à Unused Shadow Maps expire after n seconds.
Not having an expiration time:
-
Pros: A refresh rate is zero (because it is generated only once) reduces the cost of generating the Shadow Maps.
-
Cons: Because Each Shadow Map permanently reserves some video memory, the application uses more video memory.
Having an expiration time:
-
Pros: Video memory unused by other Lights can be reused.
-
Cons: A Light with an expired Shadow Map must regenerate the Shadow Map when it is used again.