Browse Source

Added a custom effect injection point right before upscaling & TAA, to be rendered at the lower internal rendering resolution.

stable
Nico de Poel 3 years ago
parent
commit
695c09e8ff
  1. 13
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessEvent.cs
  2. 10
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessLayer.cs

13
Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessEvent.cs

@ -9,20 +9,29 @@ namespace UnityEngine.Rendering.PostProcessing
{ {
/// <summary> /// <summary>
/// Effects at this injection points will execute before transparent objects are rendered. /// Effects at this injection points will execute before transparent objects are rendered.
/// These effects will be rendered at the internal render resolution.
/// </summary> /// </summary>
BeforeTransparent = 0, BeforeTransparent = 0,
/// <summary>
/// Effects at this injection point will execute before upscaling and temporal anti-aliasing.
/// These effects will be rendered at the internal render resolution.
/// </summary>
BeforeUpscaling = 1,
/// <summary> /// <summary>
/// Effects at this injection points will execute after temporal anti-aliasing and before /// Effects at this injection points will execute after temporal anti-aliasing and before
/// builtin effects are rendered. /// builtin effects are rendered.
/// These effects will be rendered at the display resolution.
/// </summary> /// </summary>
BeforeStack = 1,
BeforeStack = 2,
/// <summary> /// <summary>
/// Effects at this injection points will execute after builtin effects have been rendered /// Effects at this injection points will execute after builtin effects have been rendered
/// and before the final pass that does FXAA and applies dithering. /// and before the final pass that does FXAA and applies dithering.
/// These effects will be rendered at the display resolution.
/// </summary> /// </summary>
AfterStack = 2,
AfterStack = 3,
} }
// Box free comparer for our `PostProcessEvent` enum, else the runtime will box the type when // Box free comparer for our `PostProcessEvent` enum, else the runtime will box the type when

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

@ -173,6 +173,9 @@ namespace UnityEngine.Rendering.PostProcessing
[SerializeField] [SerializeField]
List<SerializedBundleRef> m_BeforeTransparentBundles; List<SerializedBundleRef> m_BeforeTransparentBundles;
[SerializeField]
List<SerializedBundleRef> m_BeforeUpscalingBundles;
[SerializeField] [SerializeField]
List<SerializedBundleRef> m_BeforeStackBundles; List<SerializedBundleRef> m_BeforeStackBundles;
@ -314,6 +317,7 @@ namespace UnityEngine.Rendering.PostProcessing
// Create these lists only once, the serialization system will take over after that // Create these lists only once, the serialization system will take over after that
RuntimeUtilities.CreateIfNull(ref m_BeforeTransparentBundles); RuntimeUtilities.CreateIfNull(ref m_BeforeTransparentBundles);
RuntimeUtilities.CreateIfNull(ref m_BeforeUpscalingBundles);
RuntimeUtilities.CreateIfNull(ref m_BeforeStackBundles); RuntimeUtilities.CreateIfNull(ref m_BeforeStackBundles);
RuntimeUtilities.CreateIfNull(ref m_AfterStackBundles); RuntimeUtilities.CreateIfNull(ref m_AfterStackBundles);
@ -329,6 +333,7 @@ namespace UnityEngine.Rendering.PostProcessing
// Update sorted lists with newly added or removed effects in the assemblies // Update sorted lists with newly added or removed effects in the assemblies
UpdateBundleSortList(m_BeforeTransparentBundles, PostProcessEvent.BeforeTransparent); UpdateBundleSortList(m_BeforeTransparentBundles, PostProcessEvent.BeforeTransparent);
UpdateBundleSortList(m_BeforeUpscalingBundles, PostProcessEvent.BeforeUpscaling);
UpdateBundleSortList(m_BeforeStackBundles, PostProcessEvent.BeforeStack); UpdateBundleSortList(m_BeforeStackBundles, PostProcessEvent.BeforeStack);
UpdateBundleSortList(m_AfterStackBundles, PostProcessEvent.AfterStack); UpdateBundleSortList(m_AfterStackBundles, PostProcessEvent.AfterStack);
@ -336,6 +341,7 @@ namespace UnityEngine.Rendering.PostProcessing
sortedBundles = new Dictionary<PostProcessEvent, List<SerializedBundleRef>>(new PostProcessEventComparer()) sortedBundles = new Dictionary<PostProcessEvent, List<SerializedBundleRef>>(new PostProcessEventComparer())
{ {
{ PostProcessEvent.BeforeTransparent, m_BeforeTransparentBundles }, { PostProcessEvent.BeforeTransparent, m_BeforeTransparentBundles },
{ PostProcessEvent.BeforeUpscaling, m_BeforeUpscalingBundles },
{ PostProcessEvent.BeforeStack, m_BeforeStackBundles }, { PostProcessEvent.BeforeStack, m_BeforeStackBundles },
{ PostProcessEvent.AfterStack, m_AfterStackBundles } { PostProcessEvent.AfterStack, m_AfterStackBundles }
}; };
@ -1055,6 +1061,10 @@ namespace UnityEngine.Rendering.PostProcessing
} }
context.source = lastTarget; context.source = lastTarget;
} }
// Right before upscaling & temporal anti-aliasing
if (HasActiveEffects(PostProcessEvent.BeforeUpscaling, context))
lastTarget = RenderInjectionPoint(PostProcessEvent.BeforeUpscaling, context, "BeforeUpscaling", lastTarget);
// Do temporal anti-aliasing first // Do temporal anti-aliasing first
if (context.IsTemporalAntialiasingActive()) if (context.IsTemporalAntialiasingActive())

Loading…
Cancel
Save