From a56f0742b5d22e78ffae33a80fc9a6a3919dc47b Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Sun, 22 Dec 2024 16:30:50 +0100 Subject: [PATCH] Further tweaked motion vector processing, now the camera motion vectors from Unity produce an exact match with the auto-generated motion from the clip-delta matrix, in both D3D, Vulkan and OpenGL. It also makes sense with regards to the flipped Y-coordinate in screen space now. The final result looks good now too. --- .../Runtime/Effects/Upscaling/SGSR2/Shaders/sgsr2_birp.hlsl | 5 ++--- .../Runtime/Effects/Upscaling/SGSR2/Shaders/sgsr2_hdrp.hlsl | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/sgsr2_birp.hlsl b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/sgsr2_birp.hlsl index 19823cd..be757a0 100644 --- a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/sgsr2_birp.hlsl +++ b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/sgsr2_birp.hlsl @@ -21,10 +21,9 @@ SamplerState s_LinearClamp : register(s1); inline float2 decodeVelocityFromTexture(float2 ev) { - // Nothing much to do, motion vectors are not encoded #if UNITY_UV_STARTS_AT_TOP - return -ev; + return float2(ev.x, -ev.y) * 2.0f; #else - return ev; + return ev * 2.0f; #endif } diff --git a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/sgsr2_hdrp.hlsl b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/sgsr2_hdrp.hlsl index e0531ab..6133399 100644 --- a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/sgsr2_hdrp.hlsl +++ b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/sgsr2_hdrp.hlsl @@ -9,10 +9,9 @@ inline float2 decodeVelocityFromTexture(float2 ev) { - // Nothing much to do, motion vectors are not encoded #if UNITY_UV_STARTS_AT_TOP - return -ev; + return float2(ev.x, -ev.y) * 2.0f; #else - return ev; + return ev * 2.0f; #endif }