From 721731a24f808e9405abc89281ed77e5dc1f3152 Mon Sep 17 00:00:00 2001 From: doodlum <15017472+doodlum@users.noreply.github.com> Date: Sun, 13 Oct 2024 15:39:59 +0100 Subject: [PATCH] fix: sky motion vectors (#638) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: sky motion vectors * style: 🎨 apply clang-format changes --------- Co-authored-by: doodlum --- package/Shaders/Sky.hlsl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/package/Shaders/Sky.hlsl b/package/Shaders/Sky.hlsl index 7805c84a2..a0be92e28 100644 --- a/package/Shaders/Sky.hlsl +++ b/package/Shaders/Sky.hlsl @@ -241,7 +241,15 @@ PS_OUTPUT main(PS_INPUT input) psout.Color = float4(0, 0, 0, 1.0); # endif // OCCLUSION - float2 screenMotionVector = GetSSMotionVector(input.WorldPosition, input.PreviousWorldPosition, eyeIndex); + float3 viewPosition = mul(CameraView[eyeIndex], float4(input.WorldPosition.xyz, 1)).xyz; + float2 screenUV = FrameBuffer::ViewToUV(viewPosition, true, eyeIndex); + + float4 positionWS = half4(2 * half2(screenUV.x, -screenUV.y + 1) - 1, 1.0, 1); + positionWS = mul(CameraViewProjInverse[eyeIndex], positionWS); + positionWS.xyz = positionWS.xyz / positionWS.w; + positionWS.w = 1; + + float2 screenMotionVector = GetSSMotionVector(positionWS, positionWS, eyeIndex); psout.MotionVectors = float4(screenMotionVector, 0, psout.Color.w); psout.Normal = float4(0.5, 0.5, 0, psout.Color.w);