Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XPipeline]Consolidation for Material's Priority in URP and HDRP #3966

Merged
merged 7 commits into from Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Expand Up @@ -193,6 +193,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- The default LookDev volume profile is now copied and referened in the Asset folder instead of the package folder.
- Changed normal used in path tracing to create a local light list from the geometric to the smooth shading one.
- Embed the HDRP config package instead of copying locally, the `Packages` folder is versionned by Collaborate. (case 1276518)
- Materials with Transparent Surface type, the property Sorting Priority is clamped on the UI from -50 to 50 instead of -100 to 100.
- Improved lighting models for AxF shader area lights.
- Updated Wizard to better handle RenderPipelineAsset in Quality Settings
- Added Global settings check in Wizard
Expand Down
Expand Up @@ -16,7 +16,7 @@ The resulting queue is a list of GameObjects that are first sorted by their Mate

## Sorting by Material

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.
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.

![](Images/RendererAndMaterialPriority1.png)

Expand Down
Expand Up @@ -17,3 +17,9 @@ ClearFlag.Depth does not implicitely clear stencil anymore. ClearFlag.Stencil ad
## HDRP Global Settings

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.

## Materials

### Transparent Surface Type

If you had materials with **Transparent Surface Type**, with a sorting priority that is excceding the new range of -50/50, you will need to remap them to the new range values. This will not affect you until you edit the sorting priority property on the material inspector.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Expand Up @@ -47,9 +47,9 @@ internal class Styles
}

MaterialProperty specularOcclusionMode = null;
MaterialProperty addPrecomputedVelocity = null;

const string kSpecularOcclusionMode = "_SpecularOcclusionMode";

MaterialProperty addPrecomputedVelocity = null;
const string kAddPrecomputedVelocity = HDMaterialProperties.kAddPrecomputedVelocity;

Features m_Features;
Expand Down
Expand Up @@ -581,7 +581,7 @@ protected void DrawSurfaceGUI()
}

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

if (enableFogOnTransparent != null)
materialEditor.ShaderProperty(enableFogOnTransparent, Styles.enableTransparentFogText);
Expand Down
Expand Up @@ -9,42 +9,42 @@ namespace UnityEngine.Rendering.HighDefinition

internal static class HDRenderQueue
{
const int k_TransparentPriorityQueueRange = 100;
const int k_TransparentPriorityQueueRangeStep = 100;

public enum Priority
{
Background = UnityEngine.Rendering.RenderQueue.Background,
Background = RenderQueue.Background,


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

AfterPostprocessOpaque = UnityEngine.Rendering.RenderQueue.GeometryLast + 1,
AfterPostprocessOpaqueAlphaTest = UnityEngine.Rendering.RenderQueue.GeometryLast + 10,
AfterPostprocessOpaque = RenderQueue.GeometryLast + 1,
AfterPostprocessOpaqueAlphaTest = RenderQueue.GeometryLast + 10,

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

TransparentFirst = UnityEngine.Rendering.RenderQueue.Transparent - k_TransparentPriorityQueueRange,
Transparent = UnityEngine.Rendering.RenderQueue.Transparent,
TransparentLast = UnityEngine.Rendering.RenderQueue.Transparent + k_TransparentPriorityQueueRange,
TransparentFirst = RenderQueue.Transparent - k_TransparentPriorityQueueRangeStep,
Transparent = RenderQueue.Transparent,
TransparentLast = RenderQueue.Transparent + k_TransparentPriorityQueueRangeStep,

LowTransparentFirst = 3400 - k_TransparentPriorityQueueRange,
LowTransparentFirst = 3400 - k_TransparentPriorityQueueRangeStep,
LowTransparent = 3400,
LowTransparentLast = 3400 + k_TransparentPriorityQueueRange,
LowTransparentLast = 3400 + k_TransparentPriorityQueueRangeStep,

AfterPostprocessTransparentFirst = 3700 - k_TransparentPriorityQueueRange,
AfterPostprocessTransparentFirst = 3700 - k_TransparentPriorityQueueRangeStep,
AfterPostprocessTransparent = 3700,
AfterPostprocessTransparentLast = 3700 + k_TransparentPriorityQueueRange,
AfterPostprocessTransparentLast = 3700 + k_TransparentPriorityQueueRangeStep,

Overlay = UnityEngine.Rendering.RenderQueue.Overlay
Overlay = RenderQueue.Overlay
}

public enum RenderQueueType
Expand Down Expand Up @@ -107,7 +107,8 @@ internal static RenderQueueType MigrateRenderQueueToHDRP10(RenderQueueType rende

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

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

public static RenderQueueType GetTypeByRenderQueueValue(int renderQueue)
{
Expand Down Expand Up @@ -170,7 +171,7 @@ public static RenderQueueType GetTransparentEquivalent(RenderQueueType type)
return type;
case RenderQueueType.Overlay:
case RenderQueueType.Background:
throw new ArgumentException("Unknow RenderQueueType conversion to transparent equivalent, was " + type);
throw new ArgumentException("Unknown RenderQueueType conversion to transparent equivalent, was " + type);
}
}

Expand All @@ -189,7 +190,7 @@ public static RenderQueueType GetOpaqueEquivalent(RenderQueueType type)
return type;
case RenderQueueType.Overlay:
case RenderQueueType.Background:
throw new ArgumentException("Unknow RenderQueueType conversion to opaque equivalent, was " + type);
throw new ArgumentException("Unknown RenderQueueType conversion to opaque equivalent, was " + type);
}
}

Expand Down Expand Up @@ -272,9 +273,9 @@ public static string GetShaderTagValue(int index)
{
// Special case for transparent (as we have transparent range from PreRefractionFirst to AfterPostprocessTransparentLast
// that start before RenderQueue.Transparent value
if (HDRenderQueue.k_RenderQueue_AllTransparent.Contains(index)
|| HDRenderQueue.k_RenderQueue_AfterPostProcessTransparent.Contains(index)
|| HDRenderQueue.k_RenderQueue_LowTransparent.Contains(index))
if (k_RenderQueue_AllTransparent.Contains(index)
|| k_RenderQueue_AfterPostProcessTransparent.Contains(index)
|| k_RenderQueue_LowTransparent.Contains(index))
{
int v = (index - (int)RenderQueue.Transparent);
return "Transparent" + ((v < 0) ? "" : "+") + v;
Expand Down
1 change: 1 addition & 0 deletions com.unity.render-pipelines.universal/CHANGELOG.md
Expand Up @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Changed UniversalRenderPipelineCameraEditor to URPCameraEditor
- Reduced the size of the fragment input struct of the TerrainLitPasses and LitGBufferPass, SimpleLitForwardPass and SimpleLitGBufferPass lighting shaders.
- Bokeh Depth of Field performance improvement: moved some calculations from GPU to CPU.
- Advanced Options > Priority has been renamed to Sorting Priority
- 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.
- DepthNormals passes now sample normal maps if used on the material, otherwise output the geometry normal.
- SSAO Texture is now R8 instead of ARGB32 if supported by the platform.
Expand Down
Expand Up @@ -95,8 +95,8 @@ protected class Styles
public static readonly GUIContent fixNormalNow = EditorGUIUtility.TrTextContent("Fix now",
"Converts the assigned texture to be a normal map format.");

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

#endregion
Expand Down