Skip to content

Commit 3fa98bf

Browse files
Charles-H-UnityEvergreen
authored andcommitted
Fix: URP Rendergraph does not correctly set up depth buffer in gizmo pass
Fix https://jira.unity3d.com/browse/GFXRPF-224 The depth buffer was configured as read-only meaning any rendering relying on depth writing & testing was not working correctly.
1 parent e0e98ad commit 3fa98bf

File tree

10 files changed

+691
-1
lines changed

10 files changed

+691
-1
lines changed

Packages/com.unity.render-pipelines.universal/Runtime/ScriptableRenderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ internal void DrawRenderGraphGizmos(RenderGraph renderGraph, ContextContainer fr
976976
Profiling.drawGizmos))
977977
{
978978
builder.SetRenderAttachment(color, 0, AccessFlags.Write);
979-
builder.SetRenderAttachmentDepth(depth, AccessFlags.Read);
979+
builder.SetRenderAttachmentDepth(depth, AccessFlags.ReadWrite);
980980

981981
passData.gizmoRenderList = renderGraph.CreateGizmoRendererList(cameraData.camera, gizmoSubset);
982982
builder.UseRendererList(passData.gizmoRenderList);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using UnityEngine;
2+
3+
public class GizmoDrawer : MonoBehaviour
4+
{
5+
public Material GizmoMaterial;
6+
public Mesh m_GizmoMesh;
7+
8+
void OnDrawGizmos()
9+
{
10+
if (m_GizmoMesh == null)
11+
{
12+
return;
13+
}
14+
15+
16+
for (int i = -2; i <= 2; i++)
17+
{
18+
for (int j = -2; j <= 2; j++)
19+
{
20+
Color c = new Color((i + 2.0f) / 5.0f, 0, (j + 2.0f) / 5.0f);
21+
GizmoMaterial.SetColor("_Color", c);
22+
GizmoMaterial.SetColor("_BaseColor", c);
23+
GizmoMaterial.SetPass(0);
24+
Graphics.DrawMeshNow(m_GizmoMesh, transform.position + new Vector3(i,j,0), Quaternion.identity);
25+
}
26+
}
27+
}
28+
}

Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/CommonAssets/GizmoDrawer.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/CodeBasedTests.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &-2285839236351282593
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 11
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
13+
m_Name:
14+
m_EditorClassIdentifier:
15+
version: 9
16+
--- !u!21 &2100000
17+
Material:
18+
serializedVersion: 8
19+
m_ObjectHideFlags: 0
20+
m_CorrespondingSourceObject: {fileID: 0}
21+
m_PrefabInstance: {fileID: 0}
22+
m_PrefabAsset: {fileID: 0}
23+
m_Name: GizmoMaterial
24+
m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3}
25+
m_Parent: {fileID: 0}
26+
m_ModifiedSerializedProperties: 0
27+
m_ValidKeywords: []
28+
m_InvalidKeywords: []
29+
m_LightmapFlags: 4
30+
m_EnableInstancingVariants: 0
31+
m_DoubleSidedGI: 0
32+
m_CustomRenderQueue: -1
33+
stringTagMap:
34+
RenderType: Opaque
35+
disabledShaderPasses:
36+
- MOTIONVECTORS
37+
m_LockedProperties:
38+
m_SavedProperties:
39+
serializedVersion: 3
40+
m_TexEnvs:
41+
- _BaseMap:
42+
m_Texture: {fileID: 0}
43+
m_Scale: {x: 1, y: 1}
44+
m_Offset: {x: 0, y: 0}
45+
- _BumpMap:
46+
m_Texture: {fileID: 0}
47+
m_Scale: {x: 1, y: 1}
48+
m_Offset: {x: 0, y: 0}
49+
- _DetailAlbedoMap:
50+
m_Texture: {fileID: 0}
51+
m_Scale: {x: 1, y: 1}
52+
m_Offset: {x: 0, y: 0}
53+
- _DetailMask:
54+
m_Texture: {fileID: 0}
55+
m_Scale: {x: 1, y: 1}
56+
m_Offset: {x: 0, y: 0}
57+
- _DetailNormalMap:
58+
m_Texture: {fileID: 0}
59+
m_Scale: {x: 1, y: 1}
60+
m_Offset: {x: 0, y: 0}
61+
- _EmissionMap:
62+
m_Texture: {fileID: 0}
63+
m_Scale: {x: 1, y: 1}
64+
m_Offset: {x: 0, y: 0}
65+
- _MainTex:
66+
m_Texture: {fileID: 0}
67+
m_Scale: {x: 1, y: 1}
68+
m_Offset: {x: 0, y: 0}
69+
- _MetallicGlossMap:
70+
m_Texture: {fileID: 0}
71+
m_Scale: {x: 1, y: 1}
72+
m_Offset: {x: 0, y: 0}
73+
- _OcclusionMap:
74+
m_Texture: {fileID: 0}
75+
m_Scale: {x: 1, y: 1}
76+
m_Offset: {x: 0, y: 0}
77+
- _ParallaxMap:
78+
m_Texture: {fileID: 0}
79+
m_Scale: {x: 1, y: 1}
80+
m_Offset: {x: 0, y: 0}
81+
- _SpecGlossMap:
82+
m_Texture: {fileID: 0}
83+
m_Scale: {x: 1, y: 1}
84+
m_Offset: {x: 0, y: 0}
85+
- unity_Lightmaps:
86+
m_Texture: {fileID: 0}
87+
m_Scale: {x: 1, y: 1}
88+
m_Offset: {x: 0, y: 0}
89+
- unity_LightmapsInd:
90+
m_Texture: {fileID: 0}
91+
m_Scale: {x: 1, y: 1}
92+
m_Offset: {x: 0, y: 0}
93+
- unity_ShadowMasks:
94+
m_Texture: {fileID: 0}
95+
m_Scale: {x: 1, y: 1}
96+
m_Offset: {x: 0, y: 0}
97+
m_Ints: []
98+
m_Floats:
99+
- _AddPrecomputedVelocity: 0
100+
- _AlphaClip: 0
101+
- _AlphaToMask: 0
102+
- _Blend: 0
103+
- _BlendModePreserveSpecular: 1
104+
- _BlendOp: 0
105+
- _BumpScale: 1
106+
- _ClearCoatMask: 0
107+
- _ClearCoatSmoothness: 0
108+
- _Cull: 2
109+
- _Cutoff: 0.5
110+
- _DetailAlbedoMapScale: 1
111+
- _DetailNormalMapScale: 1
112+
- _DstBlend: 0
113+
- _DstBlendAlpha: 0
114+
- _EnvironmentReflections: 1
115+
- _GlossMapScale: 0
116+
- _Glossiness: 0
117+
- _GlossinessSource: 0
118+
- _GlossyReflections: 0
119+
- _Metallic: 0
120+
- _OcclusionStrength: 1
121+
- _Parallax: 0.005
122+
- _QueueOffset: 0
123+
- _ReceiveShadows: 1
124+
- _SampleGI: 0
125+
- _Shininess: 0
126+
- _Smoothness: 0.5
127+
- _SmoothnessSource: 0
128+
- _SmoothnessTextureChannel: 0
129+
- _SpecSource: 0
130+
- _SpecularHighlights: 1
131+
- _SrcBlend: 1
132+
- _SrcBlendAlpha: 1
133+
- _Surface: 0
134+
- _WorkflowMode: 1
135+
- _ZWrite: 1
136+
m_Colors:
137+
- _BaseColor: {r: 0.8, g: 0, b: 0.8, a: 1}
138+
- _Color: {r: 0.8, g: 0, b: 0.8, a: 1}
139+
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
140+
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
141+
m_BuildTextureStacks: []
142+
m_AllowLocking: 1

Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/CodeBasedTests/GizmoMaterial.mat.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)