From 84b52c88536809b501dca363d091c99e5b7aa845 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Wed, 1 Mar 2023 14:56:30 +0100 Subject: [PATCH] Set non-jittered projection matrix before applying jittering, making motion vector jitter cancellation unnecessary. This should make outputting non-jittered upscaled depth and motion vectors for subsequent render passes a lot easier. --- Assets/Scripts/Fsr2Controller.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Fsr2Controller.cs b/Assets/Scripts/Fsr2Controller.cs index 8bb9264..13f9d34 100644 --- a/Assets/Scripts/Fsr2Controller.cs +++ b/Assets/Scripts/Fsr2Controller.cs @@ -47,7 +47,7 @@ namespace FidelityFX private void OnEnable() { - Fsr2.InitializationFlags flags = Fsr2.InitializationFlags.EnableMotionVectorsJitterCancellation; + Fsr2.InitializationFlags flags = 0; if (enableFP16) flags |= Fsr2.InitializationFlags.EnableFP16Usage; @@ -191,7 +191,7 @@ namespace FidelityFX _dispatchDescription.Reset = _reset; _reset = false; - // Perform custom jittering of the camera's projection matrix according to FSR2's instructions + // Perform custom jittering of the camera's projection matrix according to FSR2's documentation int jitterPhaseCount = Fsr2.GetJitterPhaseCount(_renderSize.x, _displaySize.x); Fsr2.GetJitterOffset(out float jitterX, out float jitterY, Time.frameCount, jitterPhaseCount); @@ -201,7 +201,9 @@ namespace FidelityFX jitterY = 2.0f * jitterY / _renderSize.y; var jitterTranslationMatrix = Matrix4x4.Translate(new Vector3(jitterX, jitterY, 0)); + _renderCamera.nonJitteredProjectionMatrix = _renderCamera.projectionMatrix; _renderCamera.projectionMatrix = jitterTranslationMatrix * _renderCamera.nonJitteredProjectionMatrix; + _renderCamera.useJitteredProjectionMatrixForTransparentRendering = false; } private void OnRenderImage(RenderTexture src, RenderTexture dest)