Search Issue Tracker
Fixed
Fixed in 2021.3.29f1, 2022.3.5f1, 2023.1.5f1, 2023.2.0a22
Votes
1
Found in
2021.3.27f1
2022.3.1f1
2023.1.0b19
2023.2.0a18
Issue ID
UUM-37441
Regression
No
[2D] [URP] Objects are rendered twice when Foremost Sorting Layer is enabled
Reproduction steps:
1. Open the “SortingLayerStripped“ project
2. Open the “SampleScene“ scene
3. Open and enable the Frame Debugger
Expected result: There is a single “RenderLoop.Draw” frame
Actual result: There are two “RenderLoop.Draw” frames
Reproduced in: 2021.3.27f1, 2022.3.1f1, 2023.1.0b19, 2023.2.0a18
Reproduced using: macOS 13.3.1 (Intel), Windows 11
Notes:
1. Also reproduced in Standalone Development Player
2. Reproduced when any of the Sorting Layers of the objects placed in the scene match the Foremost Sorting Layer
3. Not reproduced when there is no Sorting Layer that matches the Foremost Sorting Layer
4. Not reproduced when placing a Global Light 2D in the scene
5. Internal discussion confirming it’s a bug
6. Code diff between Global Light 2D and no Global Light 2D
6.1. With Global Light 2D (“Render2DLightingPass.cs” line 299)
{noformat}
if (cameraSortingLayerBoundsIndex >= layerBatch.layerRange.lowerBound && cameraSortingLayerBoundsIndex < layerBatch.layerRange.upperBound && m_Renderer2DData.useCameraSortingLayerTexture)
{
filterSettings.sortingLayerRange = new SortingLayerRange(layerBatch.layerRange.lowerBound, cameraSortingLayerBoundsIndex);
Render(context, cmd, ref renderingData, ref filterSettings, drawSettings);
CopyCameraSortingLayerRenderTexture(context, renderingData, copyStoreAction);
filterSettings.sortingLayerRange = new SortingLayerRange((short)(cameraSortingLayerBoundsIndex + 1), layerBatch.layerRange.upperBound);
Render(context, cmd, ref renderingData, ref filterSettings, drawSettings);
}{noformat}
6.2. Without Global Light 2D (“Render2DLightingPass.cs” line 433)
{noformat}
if (m_Renderer2DData.useCameraSortingLayerTexture)
{
filterSettings.sortingLayerRange = new SortingLayerRange(short.MinValue, m_CameraSortingLayerBoundsIndex);
Render(context, cmd, ref renderingData, ref filterSettings, unlitDrawSettings);
CopyCameraSortingLayerRenderTexture(context, renderingData, storeAction);
filterSettings.sortingLayerRange = new SortingLayerRange(m_CameraSortingLayerBoundsIndex, short.MaxValue); <= No add to +1.
Render(context, cmd, ref renderingData, ref filterSettings, unlitDrawSettings);
}{noformat}
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- UI Toolkit World UI Text Field unfocuses immediately when clicking on it using XR Controller
- Crash on CallWindowProcW when entering Play mode for the second time and running the Editor in the background while using System.Windows.Forms functions
- 2D Freeform Light shadows disappear when light center is offset from shape bounds
- Crash on MarkAllDependencies when opening scenes with Assets from the YarnSpinner package
- Crash on CollectAllSceneManagerAndObjectIDs when opening a specific Scene
Add comment