From f574b3f91838e21e93284bedb24f2380e7b246fb Mon Sep 17 00:00:00 2001 From: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Date: Thu, 23 Nov 2023 20:07:31 +0100 Subject: [PATCH] lens distortion added --- .../PostProcessingVFX/GameCameraProfile.asset | 35 +++++++++++++++++++ Assets/Scripts/Minigames.cs | 22 ++++++++++-- Assets/Scripts/PostProcessingVFX.cs | 29 +++++++++++++++ 3 files changed, 83 insertions(+), 3 deletions(-) diff --git a/Assets/PostProcessingVFX/GameCameraProfile.asset b/Assets/PostProcessingVFX/GameCameraProfile.asset index 72843b86c..d597b0e19 100644 --- a/Assets/PostProcessingVFX/GameCameraProfile.asset +++ b/Assets/PostProcessingVFX/GameCameraProfile.asset @@ -1,5 +1,39 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!114 &-4362154923023080619 +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: 9b77c5407dc277943b591ade9e6b18c5, type: 3} + m_Name: LensDistortion + m_EditorClassIdentifier: + active: 1 + enabled: + overrideState: 1 + value: 0 + intensity: + overrideState: 1 + value: 0 + intensityX: + overrideState: 1 + value: 1 + intensityY: + overrideState: 1 + value: 1 + centerX: + overrideState: 0 + value: 0 + centerY: + overrideState: 0 + value: 0 + scale: + overrideState: 0 + value: 1 --- !u!114 &-2309378551457945779 MonoBehaviour: m_ObjectHideFlags: 3 @@ -86,6 +120,7 @@ MonoBehaviour: - {fileID: -1752554079016775041} - {fileID: -2309378551457945779} - {fileID: 8762005197904913450} + - {fileID: -4362154923023080619} --- !u!114 &8762005197904913450 MonoBehaviour: m_ObjectHideFlags: 3 diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index fe9b56ac1..65b11af83 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -663,7 +663,7 @@ namespace HeavenStudio //temp for testing function = delegate { var e = eventCaller.currentEntity; - Common.SkillStarManager.instance.DoStarIn(e.beat, e.length); + Common.SkillStarManager.instance.DoStarIn(e.beat, e.length); } }, new GameAction("toggle inputs", "Toggle Inputs", 0.5f, true, @@ -896,7 +896,7 @@ namespace HeavenStudio new("colorStart", Color.black, "Start Color"), new("colorEnd", Color.black, "End Color"), - + new("smoothStart", new EntityTypes.Float(0.01f, 1f, 0.2f), "Start Smoothness"), new("smoothEnd", new EntityTypes.Float(0.01f, 1f, 0.2f), "End Smoothness"), @@ -930,13 +930,29 @@ namespace HeavenStudio new("thresholdStart", new EntityTypes.Float(0f, 100f, 1f), "Start Threshold"), new("thresholdEnd", new EntityTypes.Float(0f, 100f, 1f), "End Threshold"), - + new("softKneeStart", new EntityTypes.Float(0f, 1f, 0.5f), "Start Soft Knee"), new("softKneeEnd", new EntityTypes.Float(0f, 1f, 0.5f), "End Soft Knee"), new("anaStart", new EntityTypes.Float(-1f, 1f, 0f), "Start Anamorphic Ratio"), new("anaEnd", new EntityTypes.Float(-1f, 1f, 0f), "End Anamorphic Ratio"), + new("ease", Util.EasingFunction.Ease.Linear, "Ease"), + } + }, + new GameAction("lensD", "Lens Distortion") + { + resizable = true, + parameters = new() + { + new("intenStart", new EntityTypes.Float(-100f, 100f, 0f), "Start Intensity"), + new("intenEnd", new EntityTypes.Float(-100f, 100f, 1f), "End Intensity"), + + new("xStart", new EntityTypes.Float(0f, 1f, 1f), "Start X Multiplier"), + new("yStart", new EntityTypes.Float(0f, 1f, 1f), "Start Y Multiplier"), + new("xEnd", new EntityTypes.Float(0f, 1f, 1f), "End X Multiplier"), + new("yEnd", new EntityTypes.Float(0f, 1f, 1f), "End Y Multiplier"), + new("ease", Util.EasingFunction.Ease.Linear, "Ease"), } } diff --git a/Assets/Scripts/PostProcessingVFX.cs b/Assets/Scripts/PostProcessingVFX.cs index 6673d357b..45c3c35bb 100644 --- a/Assets/Scripts/PostProcessingVFX.cs +++ b/Assets/Scripts/PostProcessingVFX.cs @@ -14,6 +14,7 @@ namespace HeavenStudio private List _vignettes = new(); private List _cabbs = new(); private List _blooms = new(); + private List _lensDs = new(); private void Awake() { @@ -30,10 +31,12 @@ namespace HeavenStudio _vignettes = EventCaller.GetAllInGameManagerList("vfx", new string[] { "vignette" }); _cabbs = EventCaller.GetAllInGameManagerList("vfx", new string[] { "cabb" }); _blooms = EventCaller.GetAllInGameManagerList("vfx", new string[] { "bloom" }); + _lensDs = EventCaller.GetAllInGameManagerList("vfx", new string[] { "lensD" }); UpdateVignette(); UpdateChromaticAbberations(); UpdateBlooms(); + UpdateLensDistortions(); } private void Update() @@ -41,6 +44,7 @@ namespace HeavenStudio UpdateVignette(); UpdateChromaticAbberations(); UpdateBlooms(); + UpdateLensDistortions(); } private void UpdateVignette() @@ -127,6 +131,31 @@ namespace HeavenStudio } } + private void UpdateLensDistortions() + { + if (!_volume.profile.TryGetSettings(out var l)) return; + l.enabled.Override(false); + foreach (var e in _lensDs) + { + 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); + l.enabled.Override(newIntensity != 0); + if (!l.enabled) continue; + l.intensity.Override(newIntensity); + + float newX = func(e["xStart"], e["xEnd"], clampNormal); + l.intensityX.Override(newX); + + float newY = func(e["yStart"], e["yEnd"], clampNormal); + l.intensityY.Override(newY); + } + } + private Color ColorEase(Color start, Color end, float time, Util.EasingFunction.Function func) { float newR = func(start.r, end.r, time);