Browse Source

Allow a choice for exposure value source: either auto-calculated from FSR2 or Unity, or a manual texture, or the default value.

stable
Nico de Poel 3 years ago
parent
commit
23d26aa84b
  1. 2
      Assets/Scenes/SampleScenePPV2.unity
  2. 7
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Editor/PostProcessLayerEditor.cs
  3. 26
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs

2
Assets/Scenes/SampleScenePPV2.unity

@ -350,7 +350,7 @@ MonoBehaviour:
performSharpenPass: 1 performSharpenPass: 1
sharpness: 0.8 sharpness: 0.8
enableFP16: 0 enableFP16: 0
enableAutoExposure: 1
exposureSource: 1
preExposure: 1 preExposure: 1
exposure: {fileID: 0} exposure: {fileID: 0}
reactiveMask: {fileID: 0} reactiveMask: {fileID: 0}

7
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Editor/PostProcessLayerEditor.cs

@ -33,7 +33,7 @@ namespace UnityEditor.Rendering.PostProcessing
SerializedProperty m_FsrQualityMode; SerializedProperty m_FsrQualityMode;
SerializedProperty m_FsrPerformSharpen; SerializedProperty m_FsrPerformSharpen;
SerializedProperty m_FsrSharpness; SerializedProperty m_FsrSharpness;
SerializedProperty m_FsrAutoExposure;
SerializedProperty m_FsrExposureSource;
SerializedProperty m_FsrAutoReactive; SerializedProperty m_FsrAutoReactive;
SerializedProperty m_FsrAutoReactiveParams; SerializedProperty m_FsrAutoReactiveParams;
SerializedProperty m_FsrAutoTcr; SerializedProperty m_FsrAutoTcr;
@ -87,7 +87,7 @@ namespace UnityEditor.Rendering.PostProcessing
m_FsrQualityMode = FindProperty(x => x.superResolution.qualityMode); m_FsrQualityMode = FindProperty(x => x.superResolution.qualityMode);
m_FsrPerformSharpen = FindProperty(x => x.superResolution.performSharpenPass); m_FsrPerformSharpen = FindProperty(x => x.superResolution.performSharpenPass);
m_FsrSharpness = FindProperty(x => x.superResolution.sharpness); m_FsrSharpness = FindProperty(x => x.superResolution.sharpness);
m_FsrAutoExposure = FindProperty(x => x.superResolution.enableAutoExposure);
m_FsrExposureSource = FindProperty(x => x.superResolution.exposureSource);
m_FsrAutoReactive = FindProperty(x => x.superResolution.autoGenerateReactiveMask); m_FsrAutoReactive = FindProperty(x => x.superResolution.autoGenerateReactiveMask);
m_FsrAutoReactiveParams = FindProperty(x => x.superResolution.generateReactiveParameters); m_FsrAutoReactiveParams = FindProperty(x => x.superResolution.generateReactiveParameters);
m_FsrAutoTcr = FindProperty(x => x.superResolution.autoGenerateTransparencyAndComposition); m_FsrAutoTcr = FindProperty(x => x.superResolution.autoGenerateTransparencyAndComposition);
@ -214,10 +214,11 @@ namespace UnityEditor.Rendering.PostProcessing
} }
else if (m_AntialiasingMode.intValue == (int)PostProcessLayer.Antialiasing.SuperResolution) else if (m_AntialiasingMode.intValue == (int)PostProcessLayer.Antialiasing.SuperResolution)
{ {
// TODO: add remaining FSR2 options
EditorGUILayout.PropertyField(m_FsrQualityMode); EditorGUILayout.PropertyField(m_FsrQualityMode);
EditorGUILayout.PropertyField(m_FsrPerformSharpen); EditorGUILayout.PropertyField(m_FsrPerformSharpen);
EditorGUILayout.PropertyField(m_FsrSharpness); EditorGUILayout.PropertyField(m_FsrSharpness);
EditorGUILayout.PropertyField(m_FsrAutoExposure);
EditorGUILayout.PropertyField(m_FsrExposureSource);
EditorGUILayout.PropertyField(m_FsrAutoReactive); EditorGUILayout.PropertyField(m_FsrAutoReactive);
if (m_FsrAutoReactive.boolValue) EditorGUILayout.PropertyField(m_FsrAutoReactiveParams); if (m_FsrAutoReactive.boolValue) EditorGUILayout.PropertyField(m_FsrAutoReactiveParams);
EditorGUILayout.PropertyField(m_FsrAutoTcr); EditorGUILayout.PropertyField(m_FsrAutoTcr);

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

@ -44,13 +44,21 @@ namespace UnityEngine.Rendering.PostProcessing
[Tooltip("Allow the use of half precision compute operations, potentially improving performance if the platform supports it.")] [Tooltip("Allow the use of half precision compute operations, potentially improving performance if the platform supports it.")]
public bool enableFP16 = false; public bool enableFP16 = false;
[Tooltip("Allow an exposure value to be computed internally. When set to false, either the provided exposure texture or a default exposure value will be used.")]
public bool enableAutoExposure = true;
[Tooltip("Choose where to get the exposure value from. Use auto-exposure from either FSR2 or Unity, provide a manual exposure texture, or use a default value.")]
public ExposureSource exposureSource = ExposureSource.Auto;
[Tooltip("Value by which the input signal will be divided, to get back to the original signal produced by the game.")] [Tooltip("Value by which the input signal will be divided, to get back to the original signal produced by the game.")]
public float preExposure = 1.0f; public float preExposure = 1.0f;
[Tooltip("Optional 1x1 texture containing the exposure value for the current frame.")] [Tooltip("Optional 1x1 texture containing the exposure value for the current frame.")]
public Texture exposure = null; public Texture exposure = null;
public enum ExposureSource
{
Default,
Auto,
Unity,
Manual,
}
[Tooltip("Optional texture to control the influence of the current frame on the reconstructed output. If unset, either an auto-generated or a default cleared reactive mask will be used.")] [Tooltip("Optional texture to control the influence of the current frame on the reconstructed output. If unset, either an auto-generated or a default cleared reactive mask will be used.")]
public Texture reactiveMask = null; public Texture reactiveMask = null;
[Tooltip("Optional texture for marking areas of specialist rendering which should be accounted for during the upscaling process. If unset, a default cleared mask will be used.")] [Tooltip("Optional texture for marking areas of specialist rendering which should be accounted for during the upscaling process. If unset, a default cleared mask will be used.")]
@ -107,6 +115,7 @@ namespace UnityEngine.Rendering.PostProcessing
private readonly Fsr2.GenerateReactiveDescription _genReactiveDescription = new Fsr2.GenerateReactiveDescription(); private readonly Fsr2.GenerateReactiveDescription _genReactiveDescription = new Fsr2.GenerateReactiveDescription();
private Fsr2.QualityMode _prevQualityMode; private Fsr2.QualityMode _prevQualityMode;
private ExposureSource _prevExposureSource;
private Vector2Int _prevDisplaySize; private Vector2Int _prevDisplaySize;
private Rect _originalRect; private Rect _originalRect;
@ -161,12 +170,10 @@ namespace UnityEngine.Rendering.PostProcessing
// Monitor for any resolution changes and recreate the FSR2 context if necessary // Monitor for any resolution changes and recreate the FSR2 context if necessary
// We can't create an FSR2 context without info from the post-processing context, so delay the initial setup until here // We can't create an FSR2 context without info from the post-processing context, so delay the initial setup until here
if (_fsrContext == null || _displaySize.x != _prevDisplaySize.x || _displaySize.y != _prevDisplaySize.y || qualityMode != _prevQualityMode)
if (_fsrContext == null || _displaySize.x != _prevDisplaySize.x || _displaySize.y != _prevDisplaySize.y || qualityMode != _prevQualityMode || exposureSource != _prevExposureSource)
{ {
DestroyFsrContext(); DestroyFsrContext();
CreateFsrContext(context); CreateFsrContext(context);
_prevQualityMode = qualityMode;
} }
cmd.SetGlobalTexture(Fsr2ShaderIDs.SrvInputColor, context.source); cmd.SetGlobalTexture(Fsr2ShaderIDs.SrvInputColor, context.source);
@ -197,12 +204,14 @@ namespace UnityEngine.Rendering.PostProcessing
private void CreateFsrContext(PostProcessRenderContext context) private void CreateFsrContext(PostProcessRenderContext context)
{ {
_prevQualityMode = qualityMode;
_prevExposureSource = exposureSource;
_prevDisplaySize = _displaySize; _prevDisplaySize = _displaySize;
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;
if (enableAutoExposure) flags |= Fsr2.InitializationFlags.EnableAutoExposure;
if (exposureSource == ExposureSource.Auto) flags |= Fsr2.InitializationFlags.EnableAutoExposure;
_callbacks = CallbacksFactory(context); _callbacks = CallbacksFactory(context);
_fsrContext = Fsr2.CreateContext(_displaySize, _renderSize, _callbacks, flags); _fsrContext = Fsr2.CreateContext(_displaySize, _renderSize, _callbacks, flags);
@ -262,8 +271,9 @@ namespace UnityEngine.Rendering.PostProcessing
_dispatchDescription.Exposure = null; _dispatchDescription.Exposure = null;
_dispatchDescription.Reactive = null; _dispatchDescription.Reactive = null;
_dispatchDescription.TransparencyAndComposition = null; _dispatchDescription.TransparencyAndComposition = null;
if (!enableAutoExposure && exposure != null) _dispatchDescription.Exposure = exposure;
if (exposureSource == ExposureSource.Manual && exposure != null) _dispatchDescription.Exposure = exposure;
if (exposureSource == ExposureSource.Unity) _dispatchDescription.Exposure = context.autoExposureTexture;
if (reactiveMask != null) _dispatchDescription.Reactive = reactiveMask; if (reactiveMask != null) _dispatchDescription.Reactive = reactiveMask;
if (transparencyAndCompositionMask != null) _dispatchDescription.TransparencyAndComposition = transparencyAndCompositionMask; if (transparencyAndCompositionMask != null) _dispatchDescription.TransparencyAndComposition = transparencyAndCompositionMask;

Loading…
Cancel
Save