You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add new API to CachedShadowManager and fix WouldFitInAtlas (#3387)
* Fix WillFitAtlas + add API entry with light data itself.
* Light is placed API
* Changelog
* Placed and rendered API
* Fix assert
* Doc update
Co-authored-by: sebastienlagarde <sebastien@unity3d.com>
Copy file name to clipboardExpand all lines: com.unity.render-pipelines.high-definition/CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
19
19
- Added browsing of the documentation of Compositor Window
20
20
- Added a complete solution for volumetric clouds for HDRP including a cloud map generation tool.
21
21
- Added a Force Forward Emissive option for Lit Material that forces the Emissive contribution to render in a separate forward pass when the Lit Material is in Deferred Lit shader Mode.
22
+
- Added new API in CachedShadowManager
22
23
23
24
### Fixed
24
25
- Fixed an exception when opening the color picker in the material UI (case 1307143).
@@ -47,6 +48,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
47
48
- Fixed sub-shadow rendering for cached shadow maps.
48
49
- Fixed PCSS filtering issues with cached shadow maps.
49
50
51
+
- Fixed WouldFitInAtlas that would previously return wrong results if any one face of a point light would fit (it used to return true even though the light in entirety wouldn't fit).
52
+
50
53
### Changed
51
54
- Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard
52
55
- Removed the material pass probe volumes evaluation mode.
Copy file name to clipboardExpand all lines: com.unity.render-pipelines.high-definition/Documentation~/Shadows-in-HDRP.md
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -132,6 +132,8 @@ If the shadow atlas is full when a Light requests a spot, the cached shadow mana
132
132
After a Scene loads with all the already placed Lights, if you add a new Light with cached shadows to the Scene, HDRP tries to place it in order to fill the holes in the atlas. However, depending on the order of insertion, the atlas may be fragmented and the holes available are not enough to place the Light's shadow map in. In this case, you can defragment the atlas to allow for additional Lights. To do this, pass the target atlas into the following function: `HDCachedShadowManager.instance.DefragAtlas`
133
133
Note that this causes HDRP to mark all the shadow maps in the atlas as dirty which means HDRP renders them the moment their parent Light becomes visible.
134
134
135
+
It is possible to check if a light has its shadow maps has a placement in the cached shadow atlas `HDCachedShadowManager.instance.LightHasBeenPlacedInAtlas` and if it has been placed and rendered at least once with `HDCachedShadowManager.instance.LightHasBeenPlaceAndRenderedAtLeastOnce`.
136
+
135
137
### Preserving shadow atlas placement
136
138
137
139
If you disable the Light or change its **Update Mode** to **Every Frame**, the cached shadow manager unreserves the Light's shadow map's space in the cached shadow atlas and HDRP begins to render the Light's shadow map to the normal shadow atlases every frame. If the cached shadow manager needs to allocate space on the atlas for another Light, it can overwrite the space currently taken up by the original Light's shadow map.
privateboolm_NeedOptimalPacking=true;// Whenever this is set to true, the pending lights are sorted before insertion.
36
43
37
-
privateList<bool>m_AtlasSlots;// One entry per slot (of size m_MinSlotSize) true if occupied, false if free.
44
+
privateList<SlotValue>m_AtlasSlots;// One entry per slot (of size m_MinSlotSize) true if occupied, false if free.
38
45
39
46
// Note: Some of these could be simple lists, but since we might need to search by index some of them and we want to avoid GC alloc, a dictionary is easier.
40
47
// This also mean slightly worse performance, however hopefully the number of cached shadow lights is not huge at any tie.
privateDictionary<int,int>m_ShadowsWithValidData;// Shadows that have been placed and rendered at least once (OnDemand shadows are not rendered unless requested explicitly). It is a dictionary for fast access by shadow index.
privateDictionary<int,CachedShadowRecord>m_RecordsPendingPlacement;// Note: this is different from m_RegisteredLightDataPendingPlacement because it contains records that were allocated in the system
45
53
// but they lost their spot (e.g. post defrag). They don't have a light associated anymore if not by index, so we keep a separate collection.
@@ -57,6 +65,7 @@ public HDCachedShadowAtlas(ShadowMapType type)
// Note: If changing the characteristics of the atlas via HDRP asset, the lights OnEnable will not be called again so we are missing them, however we can explicitly
@@ -108,21 +117,26 @@ public void AddBlitRequestsForUpdatedShadows(HDDynamicShadowAtlas dynamicAtlas)
0 commit comments