From c9e294213d254ba3c0276007795cd2aa208fcf4a Mon Sep 17 00:00:00 2001 From: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Date: Thu, 23 Nov 2023 19:18:43 +0100 Subject: [PATCH] chromatic abberation added --- .../PostProcessingVFX/GameCameraProfile.asset | 27 ++++++++++++++++++ Assets/Scripts/Minigames.cs | 19 +++++++++---- Assets/Scripts/PostProcessingVFX.cs | 28 +++++++++++++++++-- 3 files changed, 66 insertions(+), 8 deletions(-) diff --git a/Assets/PostProcessingVFX/GameCameraProfile.asset b/Assets/PostProcessingVFX/GameCameraProfile.asset index b234054a0..9bf99fcdf 100644 --- a/Assets/PostProcessingVFX/GameCameraProfile.asset +++ b/Assets/PostProcessingVFX/GameCameraProfile.asset @@ -1,5 +1,31 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!114 &-2309378551457945779 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6050e2d5de785ce4d931e4dbdbf2d755, type: 3} + m_Name: ChromaticAberration + m_EditorClassIdentifier: + active: 1 + enabled: + overrideState: 1 + value: 0 + spectralLut: + overrideState: 0 + value: {fileID: 0} + defaultState: 1 + intensity: + overrideState: 1 + value: 0 + fastMode: + overrideState: 0 + value: 0 --- !u!114 &-1752554079016775041 MonoBehaviour: m_ObjectHideFlags: 3 @@ -58,3 +84,4 @@ MonoBehaviour: m_EditorClassIdentifier: settings: - {fileID: -1752554079016775041} + - {fileID: -2309378551457945779} diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index 653bc52d1..8626d9c61 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -891,23 +891,30 @@ namespace HeavenStudio resizable = true, parameters = new() { - new("enable", true, "Enable"), + new("intenStart", new EntityTypes.Float(0f, 1f), "Start Intensity"), + new("intenEnd", new EntityTypes.Float(0f, 1f, 1f), "End Intensity"), new("colorStart", Color.black, "Start Color"), new("colorEnd", Color.black, "Start End"), - - new("intenStart", new EntityTypes.Float(0f, 1f), "Start Intensity"), - new("intenEnd", new EntityTypes.Float(0f, 1f), "End Intensity"), new("smoothStart", new EntityTypes.Float(0.01f, 1f, 0.2f), "Start Smoothness"), new("smoothEnd", new EntityTypes.Float(0.01f, 1f, 0.2f), "End Smoothness"), new("roundStart", new EntityTypes.Float(0f, 1f, 1f), "Start Roundness"), new("roundEnd", new EntityTypes.Float(0f, 1f, 1f), "End Roundness"), + new("rounded", false, "Rounded"), new("ease", Util.EasingFunction.Ease.Linear, "Ease"), - - new("rounded", false, "Rounded") + } + }, + new GameAction("cabb", "Chromatic Abberation") + { + resizable = true, + parameters = new() + { + new("intenStart", new EntityTypes.Float(0f, 1f), "Start Intensity"), + new("intenEnd", new EntityTypes.Float(0f, 1f, 1f), "End Intensity"), + new("ease", Util.EasingFunction.Ease.Linear, "Ease"), } } }), diff --git a/Assets/Scripts/PostProcessingVFX.cs b/Assets/Scripts/PostProcessingVFX.cs index 8ad2d3262..43de9aa12 100644 --- a/Assets/Scripts/PostProcessingVFX.cs +++ b/Assets/Scripts/PostProcessingVFX.cs @@ -12,6 +12,7 @@ namespace HeavenStudio // events private List _vignettes = new(); + private List _cabbs = new(); private void Awake() { @@ -26,12 +27,15 @@ namespace HeavenStudio public void OnBeatChanged(double beat) { _vignettes = EventCaller.GetAllInGameManagerList("vfx", new string[] { "vignette" }); + _cabbs = EventCaller.GetAllInGameManagerList("vfx", new string[] { "cabb" }); UpdateVignette(); + UpdateChromaticAbberations(); } private void Update() { UpdateVignette(); + UpdateChromaticAbberations(); } private void UpdateVignette() @@ -47,7 +51,9 @@ namespace HeavenStudio float clampNormal = Mathf.Clamp01(normalized); var func = Util.EasingFunction.GetEasingFunction((Util.EasingFunction.Ease)e["ease"]); - v.enabled.Override(e["enable"]); + float newIntensity = func(e["intenStart"], e["intenEnd"], clampNormal); + + v.enabled.Override(newIntensity != 0); if (!v.enabled) continue; v.rounded.Override(e["rounded"]); @@ -55,7 +61,6 @@ namespace HeavenStudio v.color.Override(newColor); - float newIntensity = func(e["intenStart"], e["intenEnd"], clampNormal); v.intensity.Override(newIntensity); float newSmoothness = func(e["smoothStart"], e["smoothEnd"], clampNormal); @@ -66,6 +71,25 @@ namespace HeavenStudio } } + private void UpdateChromaticAbberations() + { + if (!_volume.profile.TryGetSettings(out var c)) return; + c.enabled.Override(false); + foreach (var e in _cabbs) + { + float normalized = Conductor.instance.GetPositionFromBeat(e.beat, e.length); + if (normalized < 0) break; + + float clampNormal = Mathf.Clamp01(normalized); + var func = Util.EasingFunction.GetEasingFunction((Util.EasingFunction.Ease)e["ease"]); + + float newIntensity = func(e["intenStart"], e["intenEnd"], clampNormal); + c.enabled.Override(newIntensity != 0); + if (!c.enabled) continue; + c.intensity.Override(newIntensity); + } + } + private Color ColorEase(Color start, Color end, float time, Util.EasingFunction.Function func) { float newR = func(start.r, end.r, time);