From 91c6d5814777dce576d394abf6a9b16319a1ba1c Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Wed, 7 Jun 2023 10:58:15 +0200 Subject: [PATCH] Comments --- .../PostProcessing/Runtime/Effects/SuperResolution.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs index a6a9f0c..b9c653c 100644 --- a/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs +++ b/Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs @@ -151,10 +151,12 @@ namespace UnityEngine.Rendering.PostProcessing var camera = context.camera; _originalRect = camera.rect; + // Determine the desired rendering and display resolutions _displaySize = new Vector2Int(camera.pixelWidth, camera.pixelHeight); Fsr2.GetRenderResolutionFromQualityMode(out int renderWidth, out int renderHeight, _displaySize.x, _displaySize.y, qualityMode); _renderSize = new Vector2Int(renderWidth, renderHeight); + // Render to a smaller portion of the screen by manipulating the camera's viewport rect camera.aspect = (_displaySize.x * _originalRect.width) / (_displaySize.y * _originalRect.height); camera.rect = new Rect(0, 0, _originalRect.width * _renderSize.x / _displaySize.x, _originalRect.height * _renderSize.y / _displaySize.y); } @@ -205,6 +207,7 @@ namespace UnityEngine.Rendering.PostProcessing _prevExposureSource = exposureSource; _prevDisplaySize = _displaySize; + // Initialize FSR2 context Fsr2.InitializationFlags flags = 0; if (context.camera.allowHDR) flags |= Fsr2.InitializationFlags.EnableHighDynamicRange; if (enableFP16) flags |= Fsr2.InitializationFlags.EnableFP16Usage; @@ -234,6 +237,7 @@ namespace UnityEngine.Rendering.PostProcessing _fsrContext = null; } + // Undo the current mipmap bias offset if (!float.IsNaN(_appliedBiasOffset) && !float.IsInfinity(_appliedBiasOffset) && _appliedBiasOffset != 0f) { _callbacks.ApplyMipmapBias(-_appliedBiasOffset); @@ -265,7 +269,7 @@ namespace UnityEngine.Rendering.PostProcessing var camera = context.camera; // Set up the main FSR2 dispatch parameters - // The input and output textures are left blank here, as they are already being bound elsewhere in this source file + // The input textures are left blank here, as they get bound directly through SetGlobalTexture elsewhere in this source file _dispatchDescription.Color = null; _dispatchDescription.Depth = null; _dispatchDescription.MotionVectors = null; @@ -293,6 +297,7 @@ namespace UnityEngine.Rendering.PostProcessing _dispatchDescription.ViewSpaceToMetersFactor = 1.0f; // 1 unit is 1 meter in Unity _dispatchDescription.Reset = _resetHistory; + // Set up the parameters for the optional experimental auto-TCR feature _dispatchDescription.EnableAutoReactive = autoGenerateTransparencyAndComposition; if (autoGenerateTransparencyAndComposition) { @@ -312,6 +317,7 @@ namespace UnityEngine.Rendering.PostProcessing private void SetupAutoReactiveDescription(PostProcessRenderContext context) { + // Set up the parameters to auto-generate a reactive mask _genReactiveDescription.ColorOpaqueOnly = colorOpaqueOnly; _genReactiveDescription.ColorPreUpscale = null; _genReactiveDescription.OutReactive = null;