vignette effect
This commit is contained in:
parent
c484f49224
commit
e08a459492
|
|
@ -1,5 +1,49 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &-1752554079016775041
|
||||
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: 40b924e2dad56384a8df2a1e111bb675, type: 3}
|
||||
m_Name: Vignette
|
||||
m_EditorClassIdentifier:
|
||||
active: 1
|
||||
enabled:
|
||||
overrideState: 1
|
||||
value: 0
|
||||
mode:
|
||||
overrideState: 1
|
||||
value: 0
|
||||
color:
|
||||
overrideState: 1
|
||||
value: {r: 0, g: 0, b: 0, a: 1}
|
||||
center:
|
||||
overrideState: 1
|
||||
value: {x: 0.5, y: 0.5}
|
||||
intensity:
|
||||
overrideState: 1
|
||||
value: 0
|
||||
smoothness:
|
||||
overrideState: 1
|
||||
value: 0.2
|
||||
roundness:
|
||||
overrideState: 1
|
||||
value: 1
|
||||
rounded:
|
||||
overrideState: 1
|
||||
value: 0
|
||||
mask:
|
||||
overrideState: 0
|
||||
value: {fileID: 0}
|
||||
defaultState: 1
|
||||
opacity:
|
||||
overrideState: 0
|
||||
value: 1
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -12,4 +56,5 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 8e6292b2c06870d4495f009f912b9600, type: 3}
|
||||
m_Name: GameCameraProfile
|
||||
m_EditorClassIdentifier:
|
||||
settings: []
|
||||
settings:
|
||||
- {fileID: -1752554079016775041}
|
||||
|
|
|
|||
|
|
@ -884,6 +884,32 @@ namespace HeavenStudio
|
|||
new Param("instantOff", false, "Instant Hide", "Skip the hide animation?"),
|
||||
}
|
||||
),
|
||||
|
||||
// Post Processing VFX
|
||||
new GameAction("vignette", "Vignette")
|
||||
{
|
||||
resizable = true,
|
||||
parameters = new()
|
||||
{
|
||||
new("enable", true, "Enable"),
|
||||
|
||||
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("ease", Util.EasingFunction.Ease.Linear, "Ease"),
|
||||
|
||||
new("rounded", false, "Rounded")
|
||||
}
|
||||
}
|
||||
}),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,79 @@
|
|||
using Jukebox;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.PostProcessing;
|
||||
|
||||
public class PostProcessingVFX : MonoBehaviour
|
||||
namespace HeavenStudio
|
||||
{
|
||||
private PostProcessVolume _volume;
|
||||
|
||||
// events
|
||||
|
||||
|
||||
private void Awake()
|
||||
public class PostProcessingVFX : MonoBehaviour
|
||||
{
|
||||
_volume = GetComponent<PostProcessVolume>();
|
||||
private PostProcessVolume _volume;
|
||||
|
||||
// events
|
||||
private List<RiqEntity> _vignettes = new();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_volume = GetComponent<PostProcessVolume>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GameManager.instance.onBeatChanged += OnBeatChanged;
|
||||
}
|
||||
|
||||
public void OnBeatChanged(double beat)
|
||||
{
|
||||
_vignettes = EventCaller.GetAllInGameManagerList("vfx", new string[] { "vignette" });
|
||||
UpdateVignette();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
UpdateVignette();
|
||||
}
|
||||
|
||||
private void UpdateVignette()
|
||||
{
|
||||
if (!_volume.profile.TryGetSettings<Vignette>(out var v)) return;
|
||||
|
||||
v.enabled.Override(false);
|
||||
foreach (var e in _vignettes)
|
||||
{
|
||||
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"]);
|
||||
|
||||
v.enabled.Override(e["enable"]);
|
||||
if (!v.enabled) continue;
|
||||
v.rounded.Override(e["rounded"]);
|
||||
|
||||
Color newColor = ColorEase(e["colorStart"], e["colorEnd"], clampNormal, func);
|
||||
|
||||
v.color.Override(newColor);
|
||||
|
||||
float newIntensity = func(e["intenStart"], e["intenEnd"], clampNormal);
|
||||
v.intensity.Override(newIntensity);
|
||||
|
||||
float newSmoothness = func(e["smoothStart"], e["smoothEnd"], clampNormal);
|
||||
v.smoothness.Override(newSmoothness);
|
||||
|
||||
float newRoundness = func(e["roundStart"], e["roundEnd"], clampNormal);
|
||||
v.roundness.Override(newRoundness);
|
||||
}
|
||||
}
|
||||
|
||||
private Color ColorEase(Color start, Color end, float time, Util.EasingFunction.Function func)
|
||||
{
|
||||
float newR = func(start.r, end.r, time);
|
||||
float newG = func(start.g, end.g, time);
|
||||
float newB = func(start.b, end.b, time);
|
||||
|
||||
return new Color(newR, newG, newB, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue