From 5b203e7ef5ffc4b191f044d098af19cc32c026f1 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Sat, 21 Dec 2024 21:01:13 +0100 Subject: [PATCH] Set normalized device coordinates Y direction to be up, which is standard in Unity, and properly detect non-zero motion vector inputs. This *seems* to be the correct recipe. --- .../Upscaling/SGSR2/Shaders/2_pass_cs/sgsr2_convert.compute | 2 +- .../Upscaling/SGSR2/Shaders/3_pass_cs/sgsr2_convert.compute | 2 +- .../Runtime/Effects/Upscaling/SGSR2/Shaders/sgsr2_common.hlsl | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_cs/sgsr2_convert.compute b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_cs/sgsr2_convert.compute index aa214fe..5d4711e 100644 --- a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_cs/sgsr2_convert.compute +++ b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_cs/sgsr2_convert.compute @@ -68,7 +68,7 @@ void CS(uint3 gl_GlobalInvocationID : SV_DispatchThreadID) float2 EncodedVelocity = LOAD_TEXTURE2D_X(InputVelocity, InputPos); float2 motion; - if (EncodedVelocity.x > 0.0) + if (any(abs(EncodedVelocity) > 0.0)) { motion = decodeVelocityFromTexture(EncodedVelocity.xy); } diff --git a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/3_pass_cs/sgsr2_convert.compute b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/3_pass_cs/sgsr2_convert.compute index 33214e1..e049225 100644 --- a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/3_pass_cs/sgsr2_convert.compute +++ b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/3_pass_cs/sgsr2_convert.compute @@ -58,7 +58,7 @@ void CS(uint3 gl_GlobalInvocationID : SV_DispatchThreadID) float2 EncodedVelocity = LOAD_TEXTURE2D_X(InputVelocity, InputPos); float2 motion; - if (EncodedVelocity.x > 0.0) + if (any(abs(EncodedVelocity) > 0.0)) { motion = decodeVelocityFromTexture(EncodedVelocity.xy); } diff --git a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/sgsr2_common.hlsl b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/sgsr2_common.hlsl index 56a5d1e..c79d47d 100644 --- a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/sgsr2_common.hlsl +++ b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/sgsr2_common.hlsl @@ -1,5 +1,7 @@ #define EPSILON 1.192e-07f +#define REQUEST_NDC_Y_UP + #ifdef UNITY_REVERSED_Z #define DEPTH_NEAREST(a, b) max((a), (b)) #define DEPTH_CLIP(depth) ((depth) > 1.0e-05f)