2021-04-25 01:59:37 +02:00
|
|
|
using System;
|
2021-04-24 03:06:03 +02:00
|
|
|
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;
|
2021-04-25 01:59:37 +02:00
|
|
|
blend.SetFloat("_Sample", Settings.sample);
|
|
|
|
// blend.SetFloat("_DeltaTime", Time.deltaTime);
|
2021-04-24 03:06:03 +02:00
|
|
|
|
2021-04-25 01:59:37 +02:00
|
|
|
// blend.SetTexture("_GlitchTex", Settings.glitchTex);
|
|
|
|
// blend.SetTexture("_BlendTex", Settings.blendTex);
|
2021-04-24 03:06:03 +02:00
|
|
|
|
|
|
|
cmd.Blit(_src,_dest,blend);
|
|
|
|
|
|
|
|
context.ExecuteCommandBuffer(cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void FrameCleanup(CommandBuffer cmd)
|
|
|
|
{
|
|
|
|
cmd.ReleaseTemporaryRT(_tempTex.id);
|
|
|
|
}
|
|
|
|
}
|