lens distortion added

This commit is contained in:
Rapandrasmus 2023-11-23 20:07:31 +01:00
parent b514f15dc0
commit f574b3f918
3 changed files with 83 additions and 3 deletions

View file

@ -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

View file

@ -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"),
}
}

View file

@ -14,6 +14,7 @@ namespace HeavenStudio
private List<RiqEntity> _vignettes = new();
private List<RiqEntity> _cabbs = new();
private List<RiqEntity> _blooms = new();
private List<RiqEntity> _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<LensDistortion>(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);