Skip to content

Commit 2b4fed1

Browse files
arttu-peltonenEvergreen
authored andcommitted
Fix broken motion vectors on URP Deferred
Fix for https://jira.unity3d.com/browse/UUM-61051 This PR fixes motion vectors being broken on URP Deferred. This was apparent because _CameraDepthTexture was showing a default texture in Frame Debugger when using Deferred. Binding the texture fixes that, and the output looks correct now. Before: https://media.github.cds.internal.unity3d.com/user/3380/files/732ede31-e722-48b5-9fb1-ac30818468c1 After: https://media.github.cds.internal.unity3d.com/user/3380/files/bcaa314f-6609-441d-bae2-a8b59dfbe78a
1 parent 42c7e54 commit 2b4fed1

File tree

9 files changed

+16106
-2
lines changed

9 files changed

+16106
-2
lines changed

Packages/com.unity.render-pipelines.universal/Runtime/Passes/MotionVectorRenderPass.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ sealed class MotionVectorRenderPass : ScriptableRenderPass
1616
public const string k_MotionVectorsLightModeTag = "MotionVectors";
1717
static readonly string[] s_ShaderTags = new string[] { k_MotionVectorsLightModeTag };
1818

19-
private static readonly ProfilingSampler s_SetMotionMatrixProfilingSampler = new ProfilingSampler("SetMotionVectorGlobalMatrices");
19+
static readonly int s_CameraDepthTextureID = Shader.PropertyToID("_CameraDepthTexture");
20+
static readonly ProfilingSampler s_SetMotionMatrixProfilingSampler = new ProfilingSampler("SetMotionVectorGlobalMatrices");
2021

2122
RTHandle m_Color;
2223
RTHandle m_Depth;
@@ -239,6 +240,9 @@ internal void Render(RenderGraph renderGraph, ContextContainer frameData, Textur
239240

240241
builder.SetRenderFunc((PassData data, RasterGraphContext context) =>
241242
{
243+
if (data.cameraMaterial != null)
244+
data.cameraMaterial.SetTexture(s_CameraDepthTextureID, data.cameraDepth);
245+
242246
ExecutePass(context.cmd, data, data.rendererListHdl);
243247
});
244248
}

Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/CommonAssets/URPAssets/DefaultURPAsset.asset

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ MonoBehaviour:
4343
- {fileID: 11400000, guid: 708aca6b4b64e8f41946dabb10fe1586, type: 2}
4444
- {fileID: 11400000, guid: 32bad5b5f60f85349bb6751a615e4571, type: 2}
4545
- {fileID: 11400000, guid: c24cfbcb0b49eb642b5173d4d3478f4d, type: 2}
46+
- {fileID: 11400000, guid: 81afd9c2ea9393c4589e79894b0c709b, type: 2}
4647
m_DefaultRendererIndex: 0
4748
m_RequireDepthTexture: 1
4849
m_RequireOpaqueTexture: 1
@@ -103,11 +104,11 @@ MonoBehaviour:
103104
m_UseAdaptivePerformance: 1
104105
m_ColorGradingMode: 0
105106
m_ColorGradingLutSize: 32
107+
m_AllowPostProcessAlphaOutput: 0
106108
m_UseFastSRGBLinearConversion: 0
107109
m_SupportDataDrivenLensFlare: 0
108110
m_SupportScreenSpaceLensFlare: 0
109111
m_GPUResidentDrawerMode: 0
110-
m_UseLegacyLightmaps: 0
111112
m_SmallMeshScreenPercentage: 0
112113
m_GPUResidentDrawerEnableOcclusionCullingInCameras: 0
113114
m_ShadowType: 0
@@ -134,6 +135,7 @@ MonoBehaviour:
134135
m_PrefilterDebugKeywords: 1
135136
m_PrefilterWriteRenderingLayers: 1
136137
m_PrefilterHDROutput: 1
138+
m_PrefilterAlphaOutput: 0
137139
m_PrefilterSSAODepthNormals: 1
138140
m_PrefilterSSAOSourceDepthLow: 1
139141
m_PrefilterSSAOSourceDepthMedium: 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &11400000
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 0
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: de640fe3d0db1804a85f9fc8f5cadab6, type: 3}
13+
m_Name: MotionVectorRenderer_Deferred
14+
m_EditorClassIdentifier:
15+
debugShaders:
16+
debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7,
17+
type: 3}
18+
hdrDebugViewPS: {fileID: 4800000, guid: 573620ae32aec764abd4d728906d2587, type: 3}
19+
probeVolumeSamplingDebugComputeShader: {fileID: 7200000, guid: 53626a513ea68ce47b59dc1299fe3959,
20+
type: 3}
21+
probeVolumeResources:
22+
probeVolumeDebugShader: {fileID: 4800000, guid: e5c6678ed2aaa91408dd3df699057aae,
23+
type: 3}
24+
probeVolumeFragmentationDebugShader: {fileID: 4800000, guid: 03cfc4915c15d504a9ed85ecc404e607,
25+
type: 3}
26+
probeVolumeOffsetDebugShader: {fileID: 4800000, guid: 53a11f4ebaebf4049b3638ef78dc9664,
27+
type: 3}
28+
probeVolumeSamplingDebugShader: {fileID: 4800000, guid: 8f96cd657dc40064aa21efcc7e50a2e7,
29+
type: 3}
30+
probeSamplingDebugMesh: {fileID: -3555484719484374845, guid: 57d7c4c16e2765b47a4d2069b311bffe,
31+
type: 3}
32+
probeSamplingDebugTexture: {fileID: 2800000, guid: 24ec0e140fb444a44ab96ee80844e18e,
33+
type: 3}
34+
probeVolumeBlendStatesCS: {fileID: 0}
35+
m_RendererFeatures:
36+
- {fileID: 7182410664851599670}
37+
m_RendererFeatureMap: 36f17415720cad63
38+
m_UseNativeRenderPass: 0
39+
xrSystemData: {fileID: 11400000, guid: 60e1133243b97e347b653163a8c01b64, type: 2}
40+
postProcessData: {fileID: 0}
41+
m_AssetVersion: 2
42+
m_OpaqueLayerMask:
43+
serializedVersion: 2
44+
m_Bits: 4294967295
45+
m_TransparentLayerMask:
46+
serializedVersion: 2
47+
m_Bits: 4294967295
48+
m_DefaultStencilState:
49+
overrideStencilState: 0
50+
stencilReference: 0
51+
stencilCompareFunction: 8
52+
passOperation: 2
53+
failOperation: 0
54+
zFailOperation: 0
55+
m_ShadowTransparentReceive: 1
56+
m_RenderingMode: 1
57+
m_DepthPrimingMode: 0
58+
m_CopyDepthMode: 0
59+
m_DepthAttachmentFormat: 0
60+
m_DepthTextureFormat: 0
61+
m_AccurateGbufferNormals: 0
62+
m_IntermediateTextureMode: 1
63+
--- !u!114 &7182410664851599670
64+
MonoBehaviour:
65+
m_ObjectHideFlags: 0
66+
m_CorrespondingSourceObject: {fileID: 0}
67+
m_PrefabInstance: {fileID: 0}
68+
m_PrefabAsset: {fileID: 0}
69+
m_GameObject: {fileID: 0}
70+
m_Enabled: 1
71+
m_EditorHideFlags: 0
72+
m_Script: {fileID: 11500000, guid: 71942f416c7166748bc5eca0666d2ccc, type: 3}
73+
m_Name: NewCaptureMotionVectorsRendererFeature
74+
m_EditorClassIdentifier:
75+
m_Active: 1
76+
m_Shader: {fileID: 4800000, guid: 8472b56af86da7b409c2cc4ed12aa711, type: 3}
77+
m_Intensity: 50

Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/206_Motion_Vectors/MotionVectorRenderer_Deferred.asset.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)