Browse Source

Comments

stable
Nico de Poel 3 years ago
parent
commit
91c6d58147
  1. 8
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs

8
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs

@ -151,10 +151,12 @@ namespace UnityEngine.Rendering.PostProcessing
var camera = context.camera; var camera = context.camera;
_originalRect = camera.rect; _originalRect = camera.rect;
// Determine the desired rendering and display resolutions
_displaySize = new Vector2Int(camera.pixelWidth, camera.pixelHeight); _displaySize = new Vector2Int(camera.pixelWidth, camera.pixelHeight);
Fsr2.GetRenderResolutionFromQualityMode(out int renderWidth, out int renderHeight, _displaySize.x, _displaySize.y, qualityMode); Fsr2.GetRenderResolutionFromQualityMode(out int renderWidth, out int renderHeight, _displaySize.x, _displaySize.y, qualityMode);
_renderSize = new Vector2Int(renderWidth, renderHeight); _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.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); 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; _prevExposureSource = exposureSource;
_prevDisplaySize = _displaySize; _prevDisplaySize = _displaySize;
// Initialize FSR2 context
Fsr2.InitializationFlags flags = 0; Fsr2.InitializationFlags flags = 0;
if (context.camera.allowHDR) flags |= Fsr2.InitializationFlags.EnableHighDynamicRange; if (context.camera.allowHDR) flags |= Fsr2.InitializationFlags.EnableHighDynamicRange;
if (enableFP16) flags |= Fsr2.InitializationFlags.EnableFP16Usage; if (enableFP16) flags |= Fsr2.InitializationFlags.EnableFP16Usage;
@ -234,6 +237,7 @@ namespace UnityEngine.Rendering.PostProcessing
_fsrContext = null; _fsrContext = null;
} }
// Undo the current mipmap bias offset
if (!float.IsNaN(_appliedBiasOffset) && !float.IsInfinity(_appliedBiasOffset) && _appliedBiasOffset != 0f) if (!float.IsNaN(_appliedBiasOffset) && !float.IsInfinity(_appliedBiasOffset) && _appliedBiasOffset != 0f)
{ {
_callbacks.ApplyMipmapBias(-_appliedBiasOffset); _callbacks.ApplyMipmapBias(-_appliedBiasOffset);
@ -265,7 +269,7 @@ namespace UnityEngine.Rendering.PostProcessing
var camera = context.camera; var camera = context.camera;
// Set up the main FSR2 dispatch parameters // 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.Color = null;
_dispatchDescription.Depth = null; _dispatchDescription.Depth = null;
_dispatchDescription.MotionVectors = null; _dispatchDescription.MotionVectors = null;
@ -293,6 +297,7 @@ namespace UnityEngine.Rendering.PostProcessing
_dispatchDescription.ViewSpaceToMetersFactor = 1.0f; // 1 unit is 1 meter in Unity _dispatchDescription.ViewSpaceToMetersFactor = 1.0f; // 1 unit is 1 meter in Unity
_dispatchDescription.Reset = _resetHistory; _dispatchDescription.Reset = _resetHistory;
// Set up the parameters for the optional experimental auto-TCR feature
_dispatchDescription.EnableAutoReactive = autoGenerateTransparencyAndComposition; _dispatchDescription.EnableAutoReactive = autoGenerateTransparencyAndComposition;
if (autoGenerateTransparencyAndComposition) if (autoGenerateTransparencyAndComposition)
{ {
@ -312,6 +317,7 @@ namespace UnityEngine.Rendering.PostProcessing
private void SetupAutoReactiveDescription(PostProcessRenderContext context) private void SetupAutoReactiveDescription(PostProcessRenderContext context)
{ {
// Set up the parameters to auto-generate a reactive mask
_genReactiveDescription.ColorOpaqueOnly = colorOpaqueOnly; _genReactiveDescription.ColorOpaqueOnly = colorOpaqueOnly;
_genReactiveDescription.ColorPreUpscale = null; _genReactiveDescription.ColorPreUpscale = null;
_genReactiveDescription.OutReactive = null; _genReactiveDescription.OutReactive = null;

Loading…
Cancel
Save