From fad865f8bc63c8f1f4301f1217dcfa637119c830 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Fri, 7 Apr 2023 12:32:07 +0200 Subject: [PATCH] Went back to HDR being derived from camera HDR settings. Maybe not entirely correct, but definitely less error prone. --- Assets/Scenes/SampleScene.unity | 1 - Assets/Scenes/SampleScenePPV2Post.unity | 1 - Assets/Scripts/Fsr2ImageEffect.cs | 14 +++++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 43adc99..d82469a 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -319,7 +319,6 @@ MonoBehaviour: qualityMode: 2 performSharpenPass: 1 sharpness: 0.8 - enableHDR: 1 enableFP16: 0 enableAutoExposure: 1 preExposure: 1 diff --git a/Assets/Scenes/SampleScenePPV2Post.unity b/Assets/Scenes/SampleScenePPV2Post.unity index bd4e890..1681681 100644 --- a/Assets/Scenes/SampleScenePPV2Post.unity +++ b/Assets/Scenes/SampleScenePPV2Post.unity @@ -322,7 +322,6 @@ MonoBehaviour: qualityMode: 3 performSharpenPass: 1 sharpness: 0.8 - enableHDR: 1 enableFP16: 0 enableAutoExposure: 1 preExposure: 1 diff --git a/Assets/Scripts/Fsr2ImageEffect.cs b/Assets/Scripts/Fsr2ImageEffect.cs index 88ebadb..dd85783 100644 --- a/Assets/Scripts/Fsr2ImageEffect.cs +++ b/Assets/Scripts/Fsr2ImageEffect.cs @@ -44,8 +44,6 @@ namespace FidelityFX [Tooltip("Strength of the sharpening effect.")] [Range(0, 1)] public float sharpness = 0.8f; - [Tooltip("Make use of high-dynamic range render texture formats and tonemapping adjustment during upscaling.")] - public bool enableHDR = true; [Tooltip("Allow the use of half precision compute operations, potentially improving performance if the platform supports it.")] public bool enableFP16 = false; @@ -144,7 +142,7 @@ namespace FidelityFX // Initialize FSR2 context Fsr2.InitializationFlags flags = 0; - if (enableHDR) flags |= Fsr2.InitializationFlags.EnableHighDynamicRange; + if (_renderCamera.allowHDR) flags |= Fsr2.InitializationFlags.EnableHighDynamicRange; if (enableFP16) flags |= Fsr2.InitializationFlags.EnableFP16Usage; if (enableAutoExposure) flags |= Fsr2.InitializationFlags.EnableAutoExposure; @@ -366,8 +364,14 @@ namespace FidelityFX // Shut up the Unity warning about not writing to the destination texture RenderTexture.active = dest; } - - private RenderTextureFormat GetDefaultFormat() => enableHDR ? RenderTextureFormat.DefaultHDR : RenderTextureFormat.Default; + + private RenderTextureFormat GetDefaultFormat() + { + if (_originalRenderTarget != null) + return _originalRenderTarget.format; + + return _renderCamera.allowHDR ? RenderTextureFormat.DefaultHDR : RenderTextureFormat.Default; + } private Vector2Int GetDisplaySize() {