48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Rendering;
|
|
using UnityEngine.Rendering.Universal;
|
|
using Debug = UnityEngine.Debug;
|
|
|
|
public class GlitchFeature : ScriptableRendererFeature
|
|
{
|
|
[Serializable]
|
|
public class Settings
|
|
{
|
|
public RenderTexture glitchTex;
|
|
public RenderTexture blendTex;
|
|
|
|
public Material blendMat;
|
|
public Material fadeMat;
|
|
|
|
public float sample;
|
|
public float fadeStrength;
|
|
}
|
|
|
|
[SerializeField] private Settings _settings = new Settings();
|
|
|
|
private GlitchPass _glitchPass;
|
|
private BlendPass _blendPass;
|
|
|
|
public override void Create()
|
|
{
|
|
_blendPass = new BlendPass();
|
|
_glitchPass = new GlitchPass();
|
|
}
|
|
|
|
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
|
|
{
|
|
// var cmd = CommandBufferPool.Get();
|
|
|
|
_blendPass.renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing;
|
|
_blendPass.Settings = _settings;
|
|
renderer.EnqueuePass(_blendPass);
|
|
|
|
_glitchPass.renderPassEvent = RenderPassEvent.AfterRenderingOpaques;
|
|
_glitchPass.Settings = _settings;
|
|
renderer.EnqueuePass(_glitchPass);
|
|
}
|
|
}
|