Browse Source

Added support for auto-transparency & composition

stable
Nico de Poel 3 years ago
parent
commit
397710f50f
  1. 6
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Editor/PostProcessLayerEditor.cs
  2. 32
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs
  3. 2
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessLayer.cs

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

@ -36,6 +36,8 @@ namespace UnityEditor.Rendering.PostProcessing
SerializedProperty m_FsrAutoExposure;
SerializedProperty m_FsrAutoReactive;
SerializedProperty m_FsrAutoReactiveParams;
SerializedProperty m_FsrAutoTcr;
SerializedProperty m_FsrAutoTcrParams;
SerializedProperty m_FogEnabled;
SerializedProperty m_FogExcludeSkybox;
@ -88,6 +90,8 @@ namespace UnityEditor.Rendering.PostProcessing
m_FsrAutoExposure = FindProperty(x => x.superResolution.enableAutoExposure);
m_FsrAutoReactive = FindProperty(x => x.superResolution.autoGenerateReactiveMask);
m_FsrAutoReactiveParams = FindProperty(x => x.superResolution.generateReactiveParameters);
m_FsrAutoTcr = FindProperty(x => x.superResolution.autoGenerateTransparencyAndComposition);
m_FsrAutoTcrParams = FindProperty(x => x.superResolution.generateTransparencyAndCompositionParameters);
m_FogEnabled = FindProperty(x => x.fog.enabled);
m_FogExcludeSkybox = FindProperty(x => x.fog.excludeSkybox);
@ -216,6 +220,8 @@ namespace UnityEditor.Rendering.PostProcessing
EditorGUILayout.PropertyField(m_FsrAutoExposure);
EditorGUILayout.PropertyField(m_FsrAutoReactive);
if (m_FsrAutoReactive.boolValue) EditorGUILayout.PropertyField(m_FsrAutoReactiveParams);
EditorGUILayout.PropertyField(m_FsrAutoTcr);
if (m_FsrAutoTcr.boolValue) EditorGUILayout.PropertyField(m_FsrAutoTcrParams);
}
}
EditorGUI.indentLevel--;

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

@ -73,6 +73,24 @@ namespace UnityEngine.Rendering.PostProcessing
public Fsr2.GenerateReactiveFlags flags = Fsr2.GenerateReactiveFlags.ApplyTonemap | Fsr2.GenerateReactiveFlags.ApplyThreshold | Fsr2.GenerateReactiveFlags.UseComponentsMax;
}
[Tooltip("(Experimental) Automatically generate and use Reactive mask and Transparency & composition mask internally.")]
public bool autoGenerateTransparencyAndComposition = false;
[Tooltip("Parameters to control the process of auto-generating transparency and composition masks.")]
public GenerateTcrParameters generateTransparencyAndCompositionParameters = new GenerateTcrParameters();
[Serializable]
public class GenerateTcrParameters
{
[Tooltip("Setting this value too small will cause visual instability. Larger values can cause ghosting.")]
[Range(0, 1)] public float autoTcThreshold = 0.05f;
[Tooltip("Smaller values will increase stability at hard edges of translucent objects.")]
[Range(0, 2)] public float autoTcScale = 1.0f;
[Tooltip("Larger values result in more reactive pixels.")]
[Range(0, 10)] public float autoReactiveScale = 5.0f;
[Tooltip("Maximum value reactivity can reach.")]
[Range(0, 1)] public float autoReactiveMax = 0.9f;
}
public Vector2 jitter { get; private set; }
public Vector2Int renderSize => _renderSize;
public Vector2Int displaySize => _displaySize;
@ -155,7 +173,7 @@ namespace UnityEngine.Rendering.PostProcessing
cmd.SetGlobalTexture(Fsr2ShaderIDs.SrvInputDepth, BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Depth);
cmd.SetGlobalTexture(Fsr2ShaderIDs.SrvInputMotionVectors, BuiltinRenderTextureType.MotionVectors);
SetupDispatchDescription(context);
SetupDispatchDescription(context, opaqueOnly);
if (autoGenerateReactiveMask)
{
@ -232,7 +250,7 @@ namespace UnityEngine.Rendering.PostProcessing
jitter = new Vector2(jitterX, jitterY);
}
private void SetupDispatchDescription(PostProcessRenderContext context)
private void SetupDispatchDescription(PostProcessRenderContext context, RenderTargetIdentifier opaqueOnly)
{
var camera = context.camera;
@ -264,6 +282,16 @@ namespace UnityEngine.Rendering.PostProcessing
_dispatchDescription.ViewSpaceToMetersFactor = 1.0f; // 1 unit is 1 meter in Unity
_dispatchDescription.Reset = _reset;
_dispatchDescription.EnableAutoReactive = autoGenerateTransparencyAndComposition;
if (autoGenerateTransparencyAndComposition)
{
_dispatchDescription.ColorOpaqueOnly = opaqueOnly;
_dispatchDescription.AutoTcThreshold = generateTransparencyAndCompositionParameters.autoTcThreshold;
_dispatchDescription.AutoTcScale = generateTransparencyAndCompositionParameters.autoTcScale;
_dispatchDescription.AutoReactiveScale = generateTransparencyAndCompositionParameters.autoReactiveScale;
_dispatchDescription.AutoReactiveMax = generateTransparencyAndCompositionParameters.autoReactiveMax;
}
if (SystemInfo.usesReversedZBuffer)
{
// Swap the near and far clip plane distances as FSR2 expects this when using inverted depth

2
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessLayer.cs

@ -641,7 +641,7 @@ namespace UnityEngine.Rendering.PostProcessing
aoRenderer.Get().RenderAfterOpaque(context);
}
bool fsrRequiresOpaque = context.IsSuperResolutionActive() && superResolution.autoGenerateReactiveMask; // TODO or auto-TCR
bool fsrRequiresOpaque = context.IsSuperResolutionActive() && (superResolution.autoGenerateReactiveMask || superResolution.autoGenerateTransparencyAndComposition);
bool isFogActive = fog.IsEnabledAndSupported(context);
bool hasCustomOpaqueOnlyEffects = HasOpaqueOnlyEffects(context);

Loading…
Cancel
Save