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

33 lines
979 B
C#
Raw Permalink Normal View History

2021-04-26 00:44:43 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class GlitchStencilPass : ScriptableRenderPass
{
private readonly GlitchFeature.Settings _settings;
private readonly RenderTargetIdentifier _src;
private readonly RenderTargetIdentifier _dest;
public GlitchStencilPass(GlitchFeature.Settings settings)
{
_settings = settings;
_src = new RenderTargetIdentifier(_settings.glitchTex);
_dest = new RenderTargetIdentifier(_settings.stencilTex);
}
// input is the view of the glitch camera
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
{
var cmd = CommandBufferPool.Get();
var stencil = _settings.stencilMat;
cmd.Blit(_src,_dest,stencil);
context.ExecuteCommandBuffer(cmd);
}
}