Skip to content

Commit d00c7bd

Browse files
authored
[XPipeline]Consolidation for Material's Priority in URP and HDRP (#3966)
1 parent 2e9f1dc commit d00c7bd

File tree

8 files changed

+40
-31
lines changed

8 files changed

+40
-31
lines changed

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
208208
- The default LookDev volume profile is now copied and referened in the Asset folder instead of the package folder.
209209
- Changed normal used in path tracing to create a local light list from the geometric to the smooth shading one.
210210
- Embed the HDRP config package instead of copying locally, the `Packages` folder is versionned by Collaborate. (case 1276518)
211+
- Materials with Transparent Surface type, the property Sorting Priority is clamped on the UI from -50 to 50 instead of -100 to 100.
211212
- Improved lighting models for AxF shader area lights.
212213
- Updated Wizard to better handle RenderPipelineAsset in Quality Settings
213214
- UI for Frame Settings has been updated: default values in the HDRP Settings and Custom Frame Settings are always editable

com.unity.render-pipelines.high-definition/Documentation~/Renderer-And-Material-Priority.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The resulting queue is a list of GameObjects that are first sorted by their Mate
1616

1717
## Sorting by Material
1818

19-
Materials with a **Transparent Surface Type** have a **Sorting Priority** property that you can use to sort groups of Meshes that use different Materials. This property is an integer value clamped between -100 and 100.
19+
Materials with a **Transparent Surface Type** have a **Sorting Priority** property that you can use to sort groups of Meshes that use different Materials. This property is an integer value clamped between -50 and 50.
2020

2121
![](Images/RendererAndMaterialPriority1.png)
2222

com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2021.1-to-2021.2.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ ClearFlag.Depth does not implicitely clear stencil anymore. ClearFlag.Stencil ad
1717
## HDRP Global Settings
1818

1919
From 2021.2, the HDRP Asset assigned in the Graphics Settings no longer acts as the default Asset for HDRP. A new HDRP Global Settings Asset now exists to save settings unrelated to which HDRP Asset is active.
20+
21+
## Materials
22+
23+
### Transparent Surface Type
24+
25+
From 2021.2, the range for **Sorting Priority** values has decreased from between -100 and 100 to between -50 and 50. If you used transparent materials (**Surface Type** set to **Transparent**) with a sorting priority lower than -50 or greater than 50, you must remap them to within the new range. HDRP does not clamp the Sorting Priority to the new range until you edit the Sorting Priority property.

com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/AdvancedOptionsUIBlock.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ internal class Styles
4747
}
4848

4949
MaterialProperty specularOcclusionMode = null;
50-
MaterialProperty addPrecomputedVelocity = null;
51-
5250
const string kSpecularOcclusionMode = "_SpecularOcclusionMode";
51+
52+
MaterialProperty addPrecomputedVelocity = null;
5353
const string kAddPrecomputedVelocity = HDMaterialProperties.kAddPrecomputedVelocity;
5454

5555
Features m_Features;

com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ protected void DrawSurfaceGUI()
581581
}
582582

583583
if (transparentSortPriority != null)
584-
materialEditor.IntShaderProperty(transparentSortPriority, Styles.transparentSortPriorityText, HDRenderQueue.ClampsTransparentRangePriority);
584+
materialEditor.IntSliderShaderProperty(transparentSortPriority, -HDRenderQueue.sortingPriortyRange, HDRenderQueue.sortingPriortyRange, Styles.transparentSortPriorityText);
585585

586586
if (enableFogOnTransparent != null)
587587
materialEditor.ShaderProperty(enableFogOnTransparent, Styles.enableTransparentFogText);

com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderQueue.cs

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,42 @@ namespace UnityEngine.Rendering.HighDefinition
99

1010
internal static class HDRenderQueue
1111
{
12-
const int k_TransparentPriorityQueueRange = 100;
12+
const int k_TransparentPriorityQueueRangeStep = 100;
1313

1414
public enum Priority
1515
{
16-
Background = UnityEngine.Rendering.RenderQueue.Background,
16+
Background = RenderQueue.Background,
1717

1818

19-
Opaque = UnityEngine.Rendering.RenderQueue.Geometry,
20-
OpaqueDecal = UnityEngine.Rendering.RenderQueue.Geometry + 225, // Opaque Decal mean Opaque that can receive decal
21-
OpaqueAlphaTest = UnityEngine.Rendering.RenderQueue.AlphaTest,
22-
OpaqueDecalAlphaTest = UnityEngine.Rendering.RenderQueue.AlphaTest + 25,
19+
Opaque = RenderQueue.Geometry,
20+
OpaqueDecal = RenderQueue.Geometry + 225, // Opaque Decal mean Opaque that can receive decal
21+
OpaqueAlphaTest = RenderQueue.AlphaTest,
22+
OpaqueDecalAlphaTest = RenderQueue.AlphaTest + 25,
2323
// Warning: we must not change Geometry last value to stay compatible with occlusion
24-
OpaqueLast = UnityEngine.Rendering.RenderQueue.GeometryLast,
24+
OpaqueLast = RenderQueue.GeometryLast,
2525

26-
AfterPostprocessOpaque = UnityEngine.Rendering.RenderQueue.GeometryLast + 1,
27-
AfterPostprocessOpaqueAlphaTest = UnityEngine.Rendering.RenderQueue.GeometryLast + 10,
26+
AfterPostprocessOpaque = RenderQueue.GeometryLast + 1,
27+
AfterPostprocessOpaqueAlphaTest = RenderQueue.GeometryLast + 10,
2828

2929
// For transparent pass we define a range of 200 value to define the priority
3030
// Warning: Be sure no range are overlapping
31-
PreRefractionFirst = 2750 - k_TransparentPriorityQueueRange,
31+
PreRefractionFirst = 2750 - k_TransparentPriorityQueueRangeStep,
3232
PreRefraction = 2750,
33-
PreRefractionLast = 2750 + k_TransparentPriorityQueueRange,
33+
PreRefractionLast = 2750 + k_TransparentPriorityQueueRangeStep,
3434

35-
TransparentFirst = UnityEngine.Rendering.RenderQueue.Transparent - k_TransparentPriorityQueueRange,
36-
Transparent = UnityEngine.Rendering.RenderQueue.Transparent,
37-
TransparentLast = UnityEngine.Rendering.RenderQueue.Transparent + k_TransparentPriorityQueueRange,
35+
TransparentFirst = RenderQueue.Transparent - k_TransparentPriorityQueueRangeStep,
36+
Transparent = RenderQueue.Transparent,
37+
TransparentLast = RenderQueue.Transparent + k_TransparentPriorityQueueRangeStep,
3838

39-
LowTransparentFirst = 3400 - k_TransparentPriorityQueueRange,
39+
LowTransparentFirst = 3400 - k_TransparentPriorityQueueRangeStep,
4040
LowTransparent = 3400,
41-
LowTransparentLast = 3400 + k_TransparentPriorityQueueRange,
41+
LowTransparentLast = 3400 + k_TransparentPriorityQueueRangeStep,
4242

43-
AfterPostprocessTransparentFirst = 3700 - k_TransparentPriorityQueueRange,
43+
AfterPostprocessTransparentFirst = 3700 - k_TransparentPriorityQueueRangeStep,
4444
AfterPostprocessTransparent = 3700,
45-
AfterPostprocessTransparentLast = 3700 + k_TransparentPriorityQueueRange,
45+
AfterPostprocessTransparentLast = 3700 + k_TransparentPriorityQueueRangeStep,
4646

47-
Overlay = UnityEngine.Rendering.RenderQueue.Overlay
47+
Overlay = RenderQueue.Overlay
4848
}
4949

5050
public enum RenderQueueType
@@ -107,7 +107,8 @@ internal static RenderQueueType MigrateRenderQueueToHDRP10(RenderQueueType rende
107107

108108
public static int Clamps(this RenderQueueRange range, int value) => Math.Max(range.lowerBound, Math.Min(value, range.upperBound));
109109

110-
public static int ClampsTransparentRangePriority(int value) => Math.Max(-k_TransparentPriorityQueueRange, Math.Min(value, k_TransparentPriorityQueueRange));
110+
public const int sortingPriortyRange = 50;
111+
public static int ClampsTransparentRangePriority(int value) => Math.Max(-sortingPriortyRange, Math.Min(value, sortingPriortyRange));
111112

112113
public static RenderQueueType GetTypeByRenderQueueValue(int renderQueue)
113114
{
@@ -170,7 +171,7 @@ public static RenderQueueType GetTransparentEquivalent(RenderQueueType type)
170171
return type;
171172
case RenderQueueType.Overlay:
172173
case RenderQueueType.Background:
173-
throw new ArgumentException("Unknow RenderQueueType conversion to transparent equivalent, was " + type);
174+
throw new ArgumentException("Unknown RenderQueueType conversion to transparent equivalent, was " + type);
174175
}
175176
}
176177

@@ -189,7 +190,7 @@ public static RenderQueueType GetOpaqueEquivalent(RenderQueueType type)
189190
return type;
190191
case RenderQueueType.Overlay:
191192
case RenderQueueType.Background:
192-
throw new ArgumentException("Unknow RenderQueueType conversion to opaque equivalent, was " + type);
193+
throw new ArgumentException("Unknown RenderQueueType conversion to opaque equivalent, was " + type);
193194
}
194195
}
195196

@@ -272,9 +273,9 @@ public static string GetShaderTagValue(int index)
272273
{
273274
// Special case for transparent (as we have transparent range from PreRefractionFirst to AfterPostprocessTransparentLast
274275
// that start before RenderQueue.Transparent value
275-
if (HDRenderQueue.k_RenderQueue_AllTransparent.Contains(index)
276-
|| HDRenderQueue.k_RenderQueue_AfterPostProcessTransparent.Contains(index)
277-
|| HDRenderQueue.k_RenderQueue_LowTransparent.Contains(index))
276+
if (k_RenderQueue_AllTransparent.Contains(index)
277+
|| k_RenderQueue_AfterPostProcessTransparent.Contains(index)
278+
|| k_RenderQueue_LowTransparent.Contains(index))
278279
{
279280
int v = (index - (int)RenderQueue.Transparent);
280281
return "Transparent" + ((v < 0) ? "" : "+") + v;

com.unity.render-pipelines.universal/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3333
- Changed UniversalRenderPipelineCameraEditor to URPCameraEditor
3434
- Reduced the size of the fragment input struct of the TerrainLitPasses and LitGBufferPass, SimpleLitForwardPass and SimpleLitGBufferPass lighting shaders.
3535
- Bokeh Depth of Field performance improvement: moved some calculations from GPU to CPU.
36+
- Advanced Options > Priority has been renamed to Sorting Priority
3637
- Opacity as Density blending feature for Terrain Lit Shader is now disabled when the Terrain has more than four Terrain Layers. This is now similar to the Height-blend feature for the Terrain Lit Shader.
3738
- DepthNormals passes now sample normal maps if used on the material, otherwise output the geometry normal.
3839
- SSAO Texture is now R8 instead of ARGB32 if supported by the platform.

com.unity.render-pipelines.universal/Editor/ShaderGUI/BaseShaderGUI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ protected class Styles
9595
public static readonly GUIContent fixNormalNow = EditorGUIUtility.TrTextContent("Fix now",
9696
"Converts the assigned texture to be a normal map format.");
9797

98-
public static readonly GUIContent queueSlider = EditorGUIUtility.TrTextContent("Priority",
99-
"Determines the chronological rendering order for a Material. High values are rendered first.");
98+
public static readonly GUIContent queueSlider = EditorGUIUtility.TrTextContent("Sorting Priority",
99+
"Determines the chronological rendering order for a Material. Materials with lower value are rendered first.");
100100
}
101101

102102
#endregion

0 commit comments

Comments
 (0)