Browse Source

Refactored opaque-only color texture to be provided as a property, instead of as a function argument. This keeps the Render() method in line with all of the other effects.

stable
Nico de Poel 3 years ago
parent
commit
2323ae88d5
  1. 15
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/SuperResolution.cs
  2. 3
      Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/PostProcessLayer.cs

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

@ -102,6 +102,7 @@ namespace UnityEngine.Rendering.PostProcessing
public Vector2 jitter { get; private set; }
public Vector2Int renderSize => _renderSize;
public Vector2Int displaySize => _displaySize;
public RenderTargetIdentifier colorOpaqueOnly { get; set; }
private Fsr2Context _fsrContext;
private Vector2Int _renderSize;
@ -163,7 +164,7 @@ namespace UnityEngine.Rendering.PostProcessing
context.camera.rect = _originalRect;
}
public void Render(PostProcessRenderContext context, RenderTargetIdentifier opaqueOnly)
public void Render(PostProcessRenderContext context)
{
var cmd = context.command;
cmd.BeginSample("FSR2");
@ -180,11 +181,11 @@ namespace UnityEngine.Rendering.PostProcessing
cmd.SetGlobalTexture(Fsr2ShaderIDs.SrvInputDepth, BuiltinRenderTextureType.CameraTarget, RenderTextureSubElement.Depth);
cmd.SetGlobalTexture(Fsr2ShaderIDs.SrvInputMotionVectors, BuiltinRenderTextureType.MotionVectors);
SetupDispatchDescription(context, opaqueOnly);
SetupDispatchDescription(context);
if (autoGenerateReactiveMask)
{
SetupAutoReactiveDescription(context, opaqueOnly);
SetupAutoReactiveDescription(context);
cmd.GetTemporaryRT(Fsr2ShaderIDs.UavAutoReactive, _renderSize.x, _renderSize.y, 0, default, GraphicsFormat.R8_UNorm, 1, true);
_fsrContext.GenerateReactiveMask(_genReactiveDescription, cmd);
@ -263,7 +264,7 @@ namespace UnityEngine.Rendering.PostProcessing
jitter = new Vector2(jitterX, jitterY);
}
private void SetupDispatchDescription(PostProcessRenderContext context, RenderTargetIdentifier opaqueOnly)
private void SetupDispatchDescription(PostProcessRenderContext context)
{
var camera = context.camera;
@ -299,7 +300,7 @@ namespace UnityEngine.Rendering.PostProcessing
_dispatchDescription.EnableAutoReactive = autoGenerateTransparencyAndComposition;
if (autoGenerateTransparencyAndComposition)
{
_dispatchDescription.ColorOpaqueOnly = opaqueOnly;
_dispatchDescription.ColorOpaqueOnly = colorOpaqueOnly;
_dispatchDescription.AutoTcThreshold = generateTransparencyAndCompositionParameters.autoTcThreshold;
_dispatchDescription.AutoTcScale = generateTransparencyAndCompositionParameters.autoTcScale;
_dispatchDescription.AutoReactiveScale = generateTransparencyAndCompositionParameters.autoReactiveScale;
@ -313,9 +314,9 @@ namespace UnityEngine.Rendering.PostProcessing
}
}
private void SetupAutoReactiveDescription(PostProcessRenderContext context, RenderTargetIdentifier opaqueOnly)
private void SetupAutoReactiveDescription(PostProcessRenderContext context)
{
_genReactiveDescription.ColorOpaqueOnly = opaqueOnly;
_genReactiveDescription.ColorOpaqueOnly = colorOpaqueOnly;
_genReactiveDescription.ColorPreUpscale = null;
_genReactiveDescription.OutReactive = null;
_genReactiveDescription.RenderSize = _renderSize;

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

@ -1159,7 +1159,8 @@ namespace UnityEngine.Rendering.PostProcessing
var finalDestination = context.destination;
context.GetScreenSpaceTemporaryRT(cmd, fsrTarget, 0, context.sourceFormat);
context.destination = fsrTarget;
superResolution.Render(context, m_opaqueOnly);
superResolution.colorOpaqueOnly = m_opaqueOnly;
superResolution.Render(context);
context.source = fsrTarget;
context.destination = finalDestination;

Loading…
Cancel
Save