revival/game/Assets/Scripts/Rendering/BlendPass.cs

56 lines
1.7 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class BlendPass : ScriptableRenderPass
{
public GlitchFeature.Settings Settings { get; set; }
private RenderTargetIdentifier _src;
private RenderTargetIdentifier _dest;
private RenderTargetHandle _tempTex;
private RenderTargetIdentifier _cameraColor;
public void Setup(RenderTargetIdentifier cameraColor)
{
_cameraColor = cameraColor;
}
public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
{
base.Configure(cmd, cameraTextureDescriptor);
_src = new RenderTargetIdentifier(Settings.glitchTex);
_dest = new RenderTargetIdentifier(Settings.blendTex);
cmd.GetTemporaryRT(_tempTex.id, Settings.blendTex.descriptor);
}
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
{
var cmd = CommandBufferPool.Get();
// set properties on material
var blend = Settings.blendMat;
blend.SetFloat("_Sample", Settings.sample);
// blend.SetFloat("_DeltaTime", Time.deltaTime);
// blend.SetTexture("_GlitchTex", Settings.glitchTex);
// blend.SetTexture("_BlendTex", Settings.blendTex);
cmd.Blit(_src,_dest,blend);
context.ExecuteCommandBuffer(cmd);
}
public override void FrameCleanup(CommandBuffer cmd)
{
cmd.ReleaseTemporaryRT(_tempTex.id);
}
}