Skip to content

Commit 621c259

Browse files
Antoine Lelievresebastienlagarde
andauthored
Hdrp/fix/custom pass msaa rendering info (#42)
* Add an info box to warn about depth test artifacts when rendering object twice in custom passes with MSAA * Updated changelog Co-authored-by: sebastienlagarde <[email protected]>
1 parent e82cc10 commit 621c259

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
9999
- Added option to disable XR rendering on the camera settings.
100100
- Added support for specular AA from geometric curvature in AxF
101101
- Added support for baked AO (no input for now) in AxF
102+
- Added an info box to warn about depth test artifacts when rendering object twice in custom passes with MSAA.
102103

103104
### Fixed
104105
- Fix when rescale probe all direction below zero (1219246)

com.unity.render-pipelines.high-definition/Editor/RenderPipeline/CustomPass/DrawRenderersCustomPassDrawer.cs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ private class Styles
5656
public static string unlitShaderMessage = "HDRP Unlit shaders will force the shader passes to \"ForwardOnly\"";
5757
public static string hdrpLitShaderMessage = "HDRP Lit shaders are not supported in a custom pass";
5858
public static string opaqueObjectWithDeferred = "Your HDRP settings does not support ForwardOnly, some object might not render.";
59+
public static string objectRendererTwiceWithMSAA = "MSAA is enabled, re-rendering same object twice will cause depth test artifacts in Before/After Post Process injection points";
5960
}
6061

6162
//Headers and layout
62-
private int m_FilterLines = 3;
63+
private int m_FilterLines = 2;
6364
private int m_MaterialLines = 2;
6465

6566
// Foldouts
@@ -86,6 +87,8 @@ private class Styles
8687

8788
ReorderableList m_ShaderPassesList;
8889

90+
CustomPassVolume m_Volume;
91+
8992
bool customDepthIsNone => (CustomPass.TargetBuffer)m_TargetDepthBuffer.intValue == CustomPass.TargetBuffer.None;
9093

9194
protected override void Initialize(SerializedProperty customPass)
@@ -112,6 +115,8 @@ protected override void Initialize(SerializedProperty customPass)
112115
m_DepthCompareFunction = customPass.FindPropertyRelative("depthCompareFunction");
113116
m_DepthWrite = customPass.FindPropertyRelative("depthWrite");
114117

118+
m_Volume = customPass.serializedObject.targetObject as CustomPassVolume;
119+
115120
m_ShaderPassesList = new ReorderableList(null, m_ShaderPasses, true, true, true, true);
116121

117122
m_ShaderPassesList.drawElementCallback =
@@ -132,6 +137,14 @@ protected override void Initialize(SerializedProperty customPass)
132137

133138
protected override void DoPassGUI(SerializedProperty customPass, Rect rect)
134139
{
140+
if (ShowMsaaObjectInfo())
141+
{
142+
Rect helpBoxRect = rect;
143+
helpBoxRect.height = Styles.helpBoxHeight;
144+
EditorGUI.HelpBox(helpBoxRect, Styles.objectRendererTwiceWithMSAA, MessageType.Info);
145+
rect.y += Styles.helpBoxHeight;
146+
}
147+
135148
DoFilters(ref rect);
136149

137150
m_RendererFoldout.boolValue = EditorGUI.Foldout(rect, m_RendererFoldout.boolValue, Styles.renderHeader, true);
@@ -156,7 +169,7 @@ protected override void DoPassGUI(SerializedProperty customPass, Rect rect)
156169
}
157170
}
158171

159-
// Tel if we need to show a warning for rendering opaque object and we're in deferred.
172+
// Tell if we need to show a warning for rendering opaque object and we're in deferred.
160173
bool ShowOpaqueObjectWarning()
161174
{
162175
// Only opaque objects are concerned
@@ -173,6 +186,18 @@ bool ShowOpaqueObjectWarning()
173186
return true;
174187
}
175188

189+
// Tell if we need to show the MSAA message info
190+
bool ShowMsaaObjectInfo()
191+
{
192+
if (!HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.supportMSAA)
193+
return false;
194+
195+
if (m_Volume.injectionPoint != CustomPassInjectionPoint.AfterPostProcess && m_Volume.injectionPoint != CustomPassInjectionPoint.BeforePostProcess)
196+
return false;
197+
198+
return true;
199+
}
200+
176201
void DoFilters(ref Rect rect)
177202
{
178203
m_FilterFoldout.boolValue = EditorGUI.Foldout(rect, m_FilterFoldout.boolValue, Styles.filtersHeader, true);
@@ -296,9 +321,11 @@ protected override float GetPassHeight(SerializedProperty customPass)
296321
{
297322
float height = Styles.defaultLineSpace;
298323

324+
height += ShowMsaaObjectInfo() ? Styles.helpBoxHeight : 0;
325+
299326
if (m_FilterFoldout.boolValue)
300327
{
301-
height *= m_FilterLines;
328+
height += Styles.defaultLineSpace * m_FilterLines;
302329
height += ShowOpaqueObjectWarning() ? Styles.helpBoxHeight : 0;
303330
}
304331

0 commit comments

Comments
 (0)