bloom added

This commit is contained in:
Rapandrasmus 2023-11-23 19:49:45 +01:00
parent c9e294213d
commit b514f15dc0
3 changed files with 109 additions and 1 deletions

View file

@ -85,3 +85,51 @@ MonoBehaviour:
settings:
- {fileID: -1752554079016775041}
- {fileID: -2309378551457945779}
- {fileID: 8762005197904913450}
--- !u!114 &8762005197904913450
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: 48a79b01ea5641d4aa6daa2e23605641, type: 3}
m_Name: Bloom
m_EditorClassIdentifier:
active: 1
enabled:
overrideState: 1
value: 0
intensity:
overrideState: 1
value: 0
threshold:
overrideState: 1
value: 1
softKnee:
overrideState: 1
value: 0.5
clamp:
overrideState: 0
value: 65472
diffusion:
overrideState: 0
value: 7
anamorphicRatio:
overrideState: 1
value: 0
color:
overrideState: 1
value: {r: 1, g: 1, b: 1, a: 1}
fastMode:
overrideState: 0
value: 0
dirtTexture:
overrideState: 0
value: {fileID: 0}
defaultState: 1
dirtIntensity:
overrideState: 0
value: 0

View file

@ -895,7 +895,7 @@ namespace HeavenStudio
new("intenEnd", new EntityTypes.Float(0f, 1f, 1f), "End Intensity"),
new("colorStart", Color.black, "Start Color"),
new("colorEnd", Color.black, "Start End"),
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"),
@ -914,6 +914,29 @@ namespace HeavenStudio
{
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"),
}
},
new GameAction("bloom", "Bloom")
{
resizable = true,
parameters = new()
{
new("intenStart", new EntityTypes.Float(0f, 100f, 0f), "Start Intensity"),
new("intenEnd", new EntityTypes.Float(0f, 100f, 1f), "End Intensity"),
new("colorStart", Color.white, "Start Tint"),
new("colorEnd", Color.white, "End Tint"),
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"),
}
}

View file

@ -13,6 +13,7 @@ namespace HeavenStudio
// events
private List<RiqEntity> _vignettes = new();
private List<RiqEntity> _cabbs = new();
private List<RiqEntity> _blooms = new();
private void Awake()
{
@ -28,14 +29,18 @@ namespace HeavenStudio
{
_vignettes = EventCaller.GetAllInGameManagerList("vfx", new string[] { "vignette" });
_cabbs = EventCaller.GetAllInGameManagerList("vfx", new string[] { "cabb" });
_blooms = EventCaller.GetAllInGameManagerList("vfx", new string[] { "bloom" });
UpdateVignette();
UpdateChromaticAbberations();
UpdateBlooms();
}
private void Update()
{
UpdateVignette();
UpdateChromaticAbberations();
UpdateBlooms();
}
private void UpdateVignette()
@ -90,6 +95,38 @@ namespace HeavenStudio
}
}
private void UpdateBlooms()
{
if (!_volume.profile.TryGetSettings<Bloom>(out var b)) return;
b.enabled.Override(false);
foreach (var e in _blooms)
{
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);
b.enabled.Override(newIntensity != 0);
if (!b.enabled) continue;
b.intensity.Override(newIntensity);
Color newColor = ColorEase(e["colorStart"], e["colorEnd"], clampNormal, func);
b.color.Override(newColor);
float newThreshold = func(e["thresholdStart"], e["thresholdEnd"], clampNormal);
b.threshold.Override(newThreshold);
float newSoftKnee = func(e["softKneeStart"], e["softKneeEnd"], clampNormal);
b.softKnee.Override(newSoftKnee);
float newAna = func(e["anaStart"], e["anaEnd"], clampNormal);
b.anamorphicRatio.Override(newAna);
}
}
private Color ColorEase(Color start, Color end, float time, Util.EasingFunction.Function func)
{
float newR = func(start.r, end.r, time);