|
|
|
@ -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
|
|
|
|
|