From f5ad1705907334634466433dbaa1a8633fa53a39 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Tue, 1 Oct 2024 23:27:26 +0200 Subject: [PATCH] Ported velocity factor and exposure clear value from FSR 3.1.1 code --- Runtime/FSR3/Fsr3Upscaler.cs | 2 ++ Runtime/FSR3/Fsr3UpscalerContext.cs | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Runtime/FSR3/Fsr3Upscaler.cs b/Runtime/FSR3/Fsr3Upscaler.cs index d69aa29..374db52 100644 --- a/Runtime/FSR3/Fsr3Upscaler.cs +++ b/Runtime/FSR3/Fsr3Upscaler.cs @@ -265,6 +265,8 @@ namespace FidelityFX.FSR3 public float deltaPreExposure; public float viewSpaceToMetersFactor; public float frameIndex; + + public float velocityFactor; } [Serializable, StructLayout(LayoutKind.Sequential)] diff --git a/Runtime/FSR3/Fsr3UpscalerContext.cs b/Runtime/FSR3/Fsr3UpscalerContext.cs index 2b7f2ef..75ad8f9 100644 --- a/Runtime/FSR3/Fsr3UpscalerContext.cs +++ b/Runtime/FSR3/Fsr3UpscalerContext.cs @@ -34,6 +34,11 @@ namespace FidelityFX.FSR3 public class Fsr3UpscalerContext { private const int MaxQueuedFrames = 16; + + public float VelocityFactor + { + set => UpscalerConsts.velocityFactor = Mathf.Clamp01(value); + } private Fsr3Upscaler.ContextDescription _contextDescription; private CommandBuffer _commandBuffer; @@ -96,6 +101,7 @@ namespace FidelityFX.FSR3 _resourceFrameIndex = 0; UpscalerConsts.maxUpscaleSize = _contextDescription.MaxUpscaleSize; + UpscalerConsts.velocityFactor = 1.0f; _resources.Create(_contextDescription); CreatePasses(); @@ -232,7 +238,7 @@ namespace FidelityFX.FSR3 // Auto exposure always used to track luma changes in locking logic commandBuffer.SetRenderTarget(_resources.FrameInfo); - commandBuffer.ClearRenderTarget(false, true, new Color(0f, 1e8f, 0f, 0f)); + commandBuffer.ClearRenderTarget(false, true, new Color(0f, 1f, 0f, 0f)); // Reset atomic counter to 0 commandBuffer.SetRenderTarget(_resources.SpdAtomicCounter);