2025-11-25 08:19:33 -05:00
|
|
|
|
using Echovoid.Runtime.Behavior.Rendering;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.Rendering;
|
|
|
|
|
|
using UnityEngine.Rendering.Universal;
|
|
|
|
|
|
|
2026-02-13 09:22:11 -05:00
|
|
|
|
namespace SLSUtilities.Rendering.PostProcessing
|
2025-11-25 08:19:33 -05:00
|
|
|
|
{
|
2025-12-22 18:36:29 -05:00
|
|
|
|
[System.Serializable, VolumeComponentMenu("SLS/Postprocessing/RGBSplitGlitch")]
|
2025-11-25 08:19:33 -05:00
|
|
|
|
public class RGBSplitGlitch : ScriptablePostProcessorVolume
|
|
|
|
|
|
{
|
|
|
|
|
|
public override CustomPostProcessInjectionPoint InjectionPoint => CustomPostProcessInjectionPoint.BeforePostProcess;
|
|
|
|
|
|
public override int OrderInInjectionPoint => 0;
|
|
|
|
|
|
|
|
|
|
|
|
public ClampedFloatParameter intensity = new(0f, 0f, 1f);
|
|
|
|
|
|
public ClampedFloatParameter speed = new(10f, 0f, 100f);
|
2025-12-23 19:47:06 -05:00
|
|
|
|
public override string GetShaderName() => "SLS/Postprocessing/RGBSplitGlitch";
|
2025-11-25 08:19:33 -05:00
|
|
|
|
|
2026-04-29 06:16:07 -04:00
|
|
|
|
private float _elapsedTime = 1.0f;
|
2025-11-25 08:19:33 -05:00
|
|
|
|
|
|
|
|
|
|
public override void Render(CommandBuffer cmd, ref RenderingData renderingData, RTHandle source, RTHandle destination)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (material == null) return;
|
2026-04-29 06:16:07 -04:00
|
|
|
|
_elapsedTime += Time.unscaledDeltaTime;
|
|
|
|
|
|
if (_elapsedTime > 100)
|
2025-11-25 08:19:33 -05:00
|
|
|
|
{
|
2026-04-29 06:16:07 -04:00
|
|
|
|
_elapsedTime = 0;
|
2025-11-25 08:19:33 -05:00
|
|
|
|
}
|
|
|
|
|
|
cmd.SetGlobalVector(InternalShaderHelpers.ID._RGBSplitGlitchParams,
|
2026-04-29 06:16:07 -04:00
|
|
|
|
new Vector4(intensity.value * 0.01f, Mathf.Floor(_elapsedTime * speed.value)));
|
2025-11-25 08:19:33 -05:00
|
|
|
|
Blitter.BlitCameraTexture(cmd, source, destination, material, 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool IsActive() => intensity.value > 0f;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|