Class HDCachedShadowManager
The class responsible to handle cached shadow maps (shadows with Update mode set to OnEnable or OnDemand).
Inherited Members
Namespace: UnityEngine.Rendering.HighDefinition
Assembly: Unity.RenderPipelines.HighDefinition.Runtime.dll
Syntax
public class HDCachedShadowManager
Properties
instance
Get the cached shadow manager to control cached shadow maps.
Declaration
public static HDCachedShadowManager instance { get; }
Property Value
Type | Description |
---|---|
HDCachedShadowManager |
Methods
DefragAtlas(HDLightType)
If a light is added after a scene is loaded, its placement in the atlas might be not optimal and the suboptimal placement might prevent a light to find a place in the atlas. This function will force a defragmentation of the atlas containing lights of type lightType and redistributes the shadows inside so that the placement is optimal. Note however that this will also mark the shadow maps as dirty and they will be re-rendered as soon the light will come into view for the first time after this function call.
Declaration
public void DefragAtlas(HDLightType lightType)
Parameters
Type | Name | Description |
---|---|---|
HDLightType | lightType | The type of the light contained in the atlas that need defragmentation. |
ForceEvictLight(HDAdditionalLightData)
This function can be used to evict a light from its atlas. The slots occupied by such light will be available to be occupied by other shadows. Note that eviction happens automatically upon light destruction and, if lightData.preserveCachedShadow is false, upon disabling of the light.
Declaration
public void ForceEvictLight(HDAdditionalLightData lightData)
Parameters
Type | Name | Description |
---|---|---|
HDAdditionalLightData | lightData | The light to evict from the atlas. |
ForceRegisterLight(HDAdditionalLightData)
This function can be used to register a light to the cached shadow system if not already registered. It is necessary to call this function if a light has been evicted with ForceEvictLight and it needs to be registered again. Please note that a light is automatically registered when enabled or when the shadow update changes from EveryFrame to OnDemand or OnEnable.
Declaration
public void ForceRegisterLight(HDAdditionalLightData lightData)
Parameters
Type | Name | Description |
---|---|---|
HDAdditionalLightData | lightData | The light to register. |
LightHasBeenPlaceAndRenderedAtLeastOnce(HDAdditionalLightData, int)
This function verifies if the light has its shadow maps placed in the cached shadow atlas and if it was rendered at least once.
Declaration
public bool LightHasBeenPlaceAndRenderedAtLeastOnce(HDAdditionalLightData lightData, int numberOfCascades = 0)
Parameters
Type | Name | Description |
---|---|---|
HDAdditionalLightData | lightData | The light that we want to check. |
int | numberOfCascades | Optional parameter required only when querying data about a directional light. It needs to match the number of cascades used by the directional light. |
Returns
Type | Description |
---|---|
bool | True if the shadow map is already placed in the atlas and rendered at least once, false otherwise. |
LightHasBeenPlacedInAtlas(HDAdditionalLightData)
This function verifies if the light has its shadow maps placed in the cached shadow atlas.
Declaration
public bool LightHasBeenPlacedInAtlas(HDAdditionalLightData lightData)
Parameters
Type | Name | Description |
---|---|---|
HDAdditionalLightData | lightData | The light that we want to check the placement of. |
Returns
Type | Description |
---|---|
bool | True if the shadow map is already placed in the atlas, false otherwise. |
ShadowHasBeenPlaceAndRenderedAtLeastOnce(HDAdditionalLightData, int)
This function verifies if the light if a specific sub-shadow maps is placed in the cached shadow atlas and if it was rendered at least once.
Declaration
public bool ShadowHasBeenPlaceAndRenderedAtLeastOnce(HDAdditionalLightData lightData, int shadowIndex)
Parameters
Type | Name | Description |
---|---|---|
HDAdditionalLightData | lightData | The light that we want to check. |
int | shadowIndex | The sub-shadow index (e.g. cascade index or point light face). It is ignored when irrelevant to the light type. |
Returns
Type | Description |
---|---|
bool | True if the shadow map is already placed in the atlas and rendered at least once, false otherwise. |
WouldFitInAtlas(int, HDLightType)
This function verifies if a shadow map of resolution shadowResolution for a light of type lightType would fit in the atlas when inserted.
Declaration
public bool WouldFitInAtlas(int shadowResolution, HDLightType lightType)
Parameters
Type | Name | Description |
---|---|---|
int | shadowResolution | The resolution of the hypothetical shadow map that we are assessing. |
HDLightType | lightType | The type of the light that cast the hypothetical shadow map that we are assessing. |
Returns
Type | Description |
---|---|
bool | True if the shadow map would fit in the atlas, false otherwise. |
WouldFitInAtlas(HDAdditionalLightData)
This function verifies if the shadow map for the passed light would fit in the atlas when inserted.
Declaration
public bool WouldFitInAtlas(HDAdditionalLightData lightData)
Parameters
Type | Name | Description |
---|---|---|
HDAdditionalLightData | lightData | The light that we try to fit in the atlas. |
Returns
Type | Description |
---|---|
bool | True if the shadow map would fit in the atlas, false otherwise. If lightData does not cast shadows, false is returned. |