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

53 lines
1.6 KiB
C#
Raw Permalink Normal View History

2021-04-24 03:06:03 +02:00
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;
2021-04-26 00:44:43 +02:00
public RenderTexture stencilTex;
2021-04-24 03:06:03 +02:00
public RenderTexture blendTex;
public Material blendMat;
public Material fadeMat;
2021-04-26 00:44:43 +02:00
public Material stencilMat;
2021-04-24 03:06:03 +02:00
public float sample;
public float fadeStrength;
}
[SerializeField] private Settings _settings = new Settings();
private GlitchPass _glitchPass;
private BlendPass _blendPass;
2021-04-26 00:44:43 +02:00
private GlitchStencilPass _stencilPass;
2021-04-24 03:06:03 +02:00
public override void Create()
{
2021-04-26 00:44:43 +02:00
_blendPass = new BlendPass(_settings);
2021-04-24 03:06:03 +02:00
_glitchPass = new GlitchPass();
2021-04-26 00:44:43 +02:00
_stencilPass = new GlitchStencilPass(_settings);
2021-04-24 03:06:03 +02:00
}
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
{
2021-04-26 00:44:43 +02:00
// get glitch stencil information
_stencilPass.renderPassEvent = RenderPassEvent.AfterRendering;
renderer.EnqueuePass(_stencilPass);
2021-04-24 03:06:03 +02:00
_blendPass.renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing;
renderer.EnqueuePass(_blendPass);
2021-04-26 00:44:43 +02:00
// _glitchPass.renderPassEvent = RenderPassEvent.AfterRenderingOpaques;
// _glitchPass.Settings = _settings;
// renderer.EnqueuePass(_glitchPass);
2021-04-24 03:06:03 +02:00
}
}