You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.4 KiB
39 lines
1.4 KiB
using System.Runtime.InteropServices;
|
|
|
|
namespace UnityEngine.Rendering.PostProcessing
|
|
{
|
|
internal class SGSR2Upscaler_2PassFS: SGSR2Upscaler
|
|
{
|
|
protected override string VariantName => "SGSR2 2-Pass Fragment";
|
|
|
|
private Material _material;
|
|
|
|
public override void CreateContext(PostProcessRenderContext context, Upscaling config)
|
|
{
|
|
base.CreateContext(context, config);
|
|
|
|
_material = new Material(context.resources.shaders.sgsr2Upscaler.twoPassFragment);
|
|
}
|
|
|
|
public override void DestroyContext()
|
|
{
|
|
RuntimeUtilities.Destroy(_material);
|
|
|
|
base.DestroyContext();
|
|
}
|
|
|
|
protected override void DoRender(CommandBuffer cmd, PostProcessRenderContext context, Upscaling config)
|
|
{
|
|
uint frameIndex = _frameCount % 2;
|
|
|
|
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.Blit(BuiltinRenderTextureType.None, _motionDepthClipAlpha, _material, 0);
|
|
cmd.Blit(BuiltinRenderTextureType.None, _upscaleHistory[frameIndex], _material, 1);
|
|
cmd.Blit(_upscaleHistory[frameIndex], context.destination);
|
|
}
|
|
}
|
|
}
|