|
|
@ -22,8 +22,7 @@ using System; |
|
|
using System.Collections; |
|
|
using System.Collections; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using UnityEngine; |
|
|
using UnityEngine; |
|
|
using UnityEngine.Rendering; |
|
|
|
|
|
using UnityEngine.Rendering.PostProcessing; |
|
|
|
|
|
|
|
|
using UnityEngine.Experimental.Rendering; |
|
|
using FidelityFX; |
|
|
using FidelityFX; |
|
|
|
|
|
|
|
|
namespace UnityEngine.Rendering.PostProcessing |
|
|
namespace UnityEngine.Rendering.PostProcessing |
|
|
@ -64,9 +63,13 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
[Serializable] |
|
|
[Serializable] |
|
|
public class GenerateReactiveParameters |
|
|
public class GenerateReactiveParameters |
|
|
{ |
|
|
{ |
|
|
|
|
|
[Tooltip("A value to scale the output")] |
|
|
[Range(0, 2)] public float scale = 0.5f; |
|
|
[Range(0, 2)] public float scale = 0.5f; |
|
|
|
|
|
[Tooltip("A threshold value to generate a binary reactive mask")] |
|
|
[Range(0, 1)] public float cutoffThreshold = 0.2f; |
|
|
[Range(0, 1)] public float cutoffThreshold = 0.2f; |
|
|
|
|
|
[Tooltip("A value to set for the binary reactive mask")] |
|
|
[Range(0, 1)] public float binaryValue = 0.9f; |
|
|
[Range(0, 1)] public float binaryValue = 0.9f; |
|
|
|
|
|
[Tooltip("Flags to determine how to generate the reactive mask")] |
|
|
public Fsr2.GenerateReactiveFlags flags = Fsr2.GenerateReactiveFlags.ApplyTonemap | Fsr2.GenerateReactiveFlags.ApplyThreshold | Fsr2.GenerateReactiveFlags.UseComponentsMax; |
|
|
public Fsr2.GenerateReactiveFlags flags = Fsr2.GenerateReactiveFlags.ApplyTonemap | Fsr2.GenerateReactiveFlags.ApplyThreshold | Fsr2.GenerateReactiveFlags.UseComponentsMax; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -133,7 +136,7 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
context.camera.rect = _originalRect; |
|
|
context.camera.rect = _originalRect; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void Render(PostProcessRenderContext context) |
|
|
|
|
|
|
|
|
public void Render(PostProcessRenderContext context, RenderTargetIdentifier opaqueOnly) |
|
|
{ |
|
|
{ |
|
|
var cmd = context.command; |
|
|
var cmd = context.command; |
|
|
cmd.BeginSample("FSR2"); |
|
|
cmd.BeginSample("FSR2"); |
|
|
@ -156,7 +159,11 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
|
|
|
|
|
|
if (autoGenerateReactiveMask) |
|
|
if (autoGenerateReactiveMask) |
|
|
{ |
|
|
{ |
|
|
// TODO: auto-generate reactive mask
|
|
|
|
|
|
|
|
|
SetupAutoReactiveDescription(context, opaqueOnly); |
|
|
|
|
|
|
|
|
|
|
|
cmd.GetTemporaryRT(Fsr2ShaderIDs.UavAutoReactive, _renderSize.x, _renderSize.y, 0, default, GraphicsFormat.R8_UNorm, 1, true); |
|
|
|
|
|
_fsrContext.GenerateReactiveMask(_genReactiveDescription, cmd); |
|
|
|
|
|
_dispatchDescription.Reactive = Fsr2ShaderIDs.UavAutoReactive; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
cmd.GetTemporaryRT(Fsr2ShaderIDs.UavUpscaledOutput, _displaySize.x, _displaySize.y, 0, default, context.sourceFormat, default, 1, true); |
|
|
cmd.GetTemporaryRT(Fsr2ShaderIDs.UavUpscaledOutput, _displaySize.x, _displaySize.y, 0, default, context.sourceFormat, default, 1, true); |
|
|
@ -264,6 +271,18 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void SetupAutoReactiveDescription(PostProcessRenderContext context, RenderTargetIdentifier opaqueOnly) |
|
|
|
|
|
{ |
|
|
|
|
|
_genReactiveDescription.ColorOpaqueOnly = opaqueOnly; |
|
|
|
|
|
_genReactiveDescription.ColorPreUpscale = null; |
|
|
|
|
|
_genReactiveDescription.OutReactive = null; |
|
|
|
|
|
_genReactiveDescription.RenderSize = _renderSize; |
|
|
|
|
|
_genReactiveDescription.Scale = generateReactiveParameters.scale; |
|
|
|
|
|
_genReactiveDescription.CutoffThreshold = generateReactiveParameters.cutoffThreshold; |
|
|
|
|
|
_genReactiveDescription.BinaryValue = generateReactiveParameters.binaryValue; |
|
|
|
|
|
_genReactiveDescription.Flags = generateReactiveParameters.flags; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private class Callbacks : Fsr2CallbacksBase |
|
|
private class Callbacks : Fsr2CallbacksBase |
|
|
{ |
|
|
{ |
|
|
private readonly PostProcessResources _resources; |
|
|
private readonly PostProcessResources _resources; |
|
|
|