using Echovoid.Runtime.Behavior.Rendering; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; namespace SLSUtilities.Rendering.PostProcessing { [System.Serializable, VolumeComponentMenu("SLS/Postprocessing/Space Pulse (Shockwave)")] public class SpacePulse : ScriptablePostProcessorVolume { public override CustomPostProcessInjectionPoint InjectionPoint => CustomPostProcessInjectionPoint.AfterPostProcess; public override int OrderInInjectionPoint => 56; [Header("Animation")] [Tooltip("The progress of the pulse. 0 = far center, 1+ = hits the camera and disappears. Drive this value using C#/Timeline.")] public ClampedFloatParameter pulseProgress = new(0f, 0f, 2f); [Header("Appearance")] [Tooltip("Emission Color of the pulse shockwave. Alpha controls the core brightness.")] public ColorParameter color = new(new Color(0f, 1f, 1f, 1f), true, true, true); [Tooltip("Thickness of the shockwave ring.")] public ClampedFloatParameter thickness = new(0.1f, 0.01f, 0.5f); [Header("Distortion")] [Tooltip("How strongly it warps/refracts the background pixels (positive pushes out, negative pulls in).")] public ClampedFloatParameter distortion = new(0.05f, -0.2f, 0.2f); [Tooltip("Chromatic aberration split on the edges of the pulse.")] public ClampedFloatParameter chromaticAberration = new(0.02f, 0f, 0.1f); [Header("Center")] [Tooltip("The vanishing point from where the pulse originates (0.5, 0.5 is screen center).")] public Vector2Parameter vfxCenter = new(new Vector2(0.5f, 0.5f)); public override string GetShaderName() => "SLS/Postprocessing/SpacePulse"; public override bool IsActive() => pulseProgress.value > 0f && pulseProgress.value < 1.5f; public override void Render(CommandBuffer cmd, ref RenderingData renderingData, RTHandle source, RTHandle target) { if (material == null) return; material.SetColor(InternalShaderHelpers.ID._SpacePulseColor, color.value); // Pack params into Vector4 for single pass Vector4 p = new Vector4(pulseProgress.value, thickness.value, distortion.value, chromaticAberration.value); material.SetVector(InternalShaderHelpers.ID._SpacePulseParams, p); material.SetVector(InternalShaderHelpers.ID._SpacePulseCenter, vfxCenter.value); Blitter.BlitCameraTexture(cmd, source, target, material, 0); } } }