|
|
@ -6,19 +6,19 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
{ |
|
|
{ |
|
|
protected override string VariantName => "SGSR2 2-Pass Fragment"; |
|
|
protected override string VariantName => "SGSR2 2-Pass Fragment"; |
|
|
|
|
|
|
|
|
private Material _material; |
|
|
|
|
|
|
|
|
private PropertySheet _sheet; |
|
|
private readonly RenderTargetIdentifier[] _mrt = new RenderTargetIdentifier[2]; |
|
|
private readonly RenderTargetIdentifier[] _mrt = new RenderTargetIdentifier[2]; |
|
|
|
|
|
|
|
|
public override void CreateContext(PostProcessRenderContext context, Upscaling config) |
|
|
public override void CreateContext(PostProcessRenderContext context, Upscaling config) |
|
|
{ |
|
|
{ |
|
|
base.CreateContext(context, config); |
|
|
base.CreateContext(context, config); |
|
|
|
|
|
|
|
|
_material = new Material(context.resources.shaders.sgsr2Upscaler.twoPassFragment); |
|
|
|
|
|
|
|
|
_sheet = new PropertySheet(new Material(context.resources.shaders.sgsr2Upscaler.twoPassFragment)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public override void DestroyContext() |
|
|
public override void DestroyContext() |
|
|
{ |
|
|
{ |
|
|
RuntimeUtilities.Destroy(_material); |
|
|
|
|
|
|
|
|
_sheet.Release(); |
|
|
|
|
|
|
|
|
base.DestroyContext(); |
|
|
base.DestroyContext(); |
|
|
} |
|
|
} |
|
|
@ -27,19 +27,16 @@ namespace UnityEngine.Rendering.PostProcessing |
|
|
{ |
|
|
{ |
|
|
uint frameIndex = _frameCount % 2; |
|
|
uint frameIndex = _frameCount % 2; |
|
|
|
|
|
|
|
|
// TODO: try using a PropertySheet here again, now that PPV2 is functional
|
|
|
|
|
|
cmd.SetGlobalTexture("InputColor", context.source); |
|
|
cmd.SetGlobalTexture("InputColor", context.source); |
|
|
cmd.SetGlobalTexture("MotionDepthClipAlphaBuffer", _motionDepthClipAlpha); |
|
|
|
|
|
cmd.SetGlobalTexture("PrevOutput", _upscaleHistory[frameIndex ^ 1]); |
|
|
|
|
|
cmd.SetGlobalConstantBuffer(_paramsBuffer, "cbSGSR2", 0, Marshal.SizeOf<SGSR2.Params>()); |
|
|
|
|
|
|
|
|
|
|
|
cmd.SetRenderTarget(_motionDepthClipAlpha, context.source); |
|
|
|
|
|
cmd.DrawMesh(RuntimeUtilities.fullscreenTriangle, Matrix4x4.identity, _material, 0, 0); |
|
|
|
|
|
|
|
|
_sheet.properties.SetTexture("MotionDepthClipAlphaBuffer", _motionDepthClipAlpha); |
|
|
|
|
|
_sheet.properties.SetTexture("PrevOutput", _upscaleHistory[frameIndex ^ 1]); |
|
|
|
|
|
_sheet.properties.SetConstantBuffer("cbSGSR2", _paramsBuffer, 0, Marshal.SizeOf<SGSR2.Params>()); |
|
|
|
|
|
|
|
|
|
|
|
cmd.BlitFullscreenTriangle(BuiltinRenderTextureType.None, _motionDepthClipAlpha, _sheet, 0); |
|
|
|
|
|
|
|
|
_mrt[0] = context.destination; |
|
|
_mrt[0] = context.destination; |
|
|
_mrt[1] = _upscaleHistory[frameIndex]; |
|
|
_mrt[1] = _upscaleHistory[frameIndex]; |
|
|
cmd.SetRenderTarget(_mrt, context.destination); |
|
|
|
|
|
cmd.DrawMesh(RuntimeUtilities.fullscreenTriangle, Matrix4x4.identity, _material, 0, 1); |
|
|
|
|
|
|
|
|
cmd.BlitFullscreenTriangle(BuiltinRenderTextureType.None, _mrt, BuiltinRenderTextureType.None, _sheet, 1); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |