Skip to content

Commit e7e0609

Browse files
lpledouxUnityEvergreen
authored andcommitted
Fix for the background motion vectors computation being incorrect after the last change
1 parent 109cc29 commit e7e0609

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Packages/com.unity.render-pipelines.universal/Shaders/XR/XRMotionVector.shader

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,16 @@ Shader "Hidden/Universal Render Pipeline/XR/XRMotionVector"
6262
UNITY_SETUP_INSTANCE_ID(input);
6363
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
6464

65-
output.position = GetFullScreenTriangleVertexPosition(input.vertexID);
66-
67-
float depth = 1 - UNITY_NEAR_CLIP_VALUE;
68-
output.position.z = depth;
65+
output.position = GetFullScreenTriangleVertexPosition(input.vertexID, 1 - UNITY_NEAR_CLIP_VALUE);
6966

7067
// Reconstruct world position
71-
float3 posWS = ComputeWorldSpacePosition(output.position.xy, depth, UNITY_MATRIX_I_VP);
68+
// We can use the clip space as is because contrary to the convention mentioned in Common.hlsl (RP Core),
69+
// this clip space is already Y-up
70+
float3 posWS = ComputeWorldSpacePosition(output.position, UNITY_MATRIX_I_VP);
7271

7372
// Multiply with current and previous non-jittered view projection
74-
output.posCS = mul(_NonJitteredViewProjMatrix, float4(posWS.xyz, 1.0));
75-
output.prevPosCS = mul(_PrevViewProjMatrix, float4(posWS.xyz, 1.0));
73+
output.posCS = mul(_NonJitteredViewProjMatrix, float4(posWS, 1.0));
74+
output.prevPosCS = mul(_PrevViewProjMatrix, float4(posWS, 1.0));
7675

7776
return output;
7877
}

0 commit comments

Comments
 (0)