lensd and vignette center vfx

This commit is contained in:
Rapandrasmus 2023-11-25 21:02:01 +01:00
parent 0e0adc82dc
commit cef6a5873e
4 changed files with 104 additions and 6 deletions

View file

@ -26,10 +26,10 @@ MonoBehaviour:
overrideState: 1
value: 1
centerX:
overrideState: 0
overrideState: 1
value: 0
centerY:
overrideState: 0
overrideState: 1
value: 0
scale:
overrideState: 0
@ -1394,7 +1394,7 @@ MonoBehaviour:
overrideState: 1
value: {r: 0, g: 0, b: 0, a: 1}
center:
overrideState: 0
overrideState: 1
value: {x: 0.5, y: 0.5}
intensity:
overrideState: 1

View file

@ -10,11 +10,9 @@ using DG.Tweening;
using Starpelly;
using HeavenStudio.Editor.Track;
using System.Text;
namespace HeavenStudio.Editor
{
// I hate the antichrist.
public class GridGameSelector : MonoBehaviour
{
public Minigames.Minigame SelectedMinigame;

View file

@ -523,6 +523,7 @@ namespace HeavenStudio
public EventCallback inactiveFunction = delegate { };
public EventCallback preFunction = delegate { };
public float preFunctionLength = 2.0f;
public string categoryName = string.Empty;
/// <summary>
/// <para>Creates a block that can be used in the editor. The block's function and attributes are defined in the parentheses.</para>
@ -540,7 +541,7 @@ namespace HeavenStudio
/// <param name="hidden">Prevents the block from being shown in the game list. Block will still function normally if it is in the timeline.</param>
/// <param name="preFunction">Runs two beats before this event is reached.</param>
/// <param name="priority">Priority of this event. Higher priority events will be run first.</param>
public GameAction(string actionName, string displayName, float defaultLength = 1, bool resizable = false, List<Param> parameters = null, EventCallback function = null, EventCallback inactiveFunction = null, EventCallback prescheduleFunction = null, bool hidden = false, EventCallback preFunction = null, int priority = 0, float preFunctionLength = 2.0f)
public GameAction(string actionName, string displayName, float defaultLength = 1, bool resizable = false, List<Param> parameters = null, EventCallback function = null, EventCallback inactiveFunction = null, EventCallback prescheduleFunction = null, bool hidden = false, EventCallback preFunction = null, int priority = 0, float preFunctionLength = 2.0f, string categoryName = null)
{
this.actionName = actionName;
if (displayName == String.Empty) this.displayName = actionName;
@ -555,6 +556,7 @@ namespace HeavenStudio
this.preFunction = prescheduleFunction ?? delegate { };
this.priority = priority;
this.preFunctionLength = preFunctionLength;
this.categoryName = categoryName;
//todo: converting to new versions of GameActions
@ -932,6 +934,22 @@ namespace HeavenStudio
}),
}
},
new GameAction("vignetteCenter", "Vignette Center")
{
resizable = true,
parameters = new()
{
new("x1", new EntityTypes.Float(-1f, 2f, 0.5f), "Start X"),
new("y1", new EntityTypes.Float(-1f, 2f, 0.5f), "Start Y"),
new("x2", new EntityTypes.Float(-1f, 2f, 0.5f), "End X"),
new("y2", new EntityTypes.Float(-1f, 2f, 0.5f), "End Y"),
new Param("axis", StaticCamera.ViewAxis.All, "Axis"),
new("ease", Util.EasingFunction.Ease.Linear, "Ease", "", new()
{
new((x, y) => (Util.EasingFunction.Ease)x != Util.EasingFunction.Ease.Instant, new string[] { "x1", "y1" })
}),
}
},
new GameAction("cabb", "Chromatic Abberation")
{
resizable = true,
@ -990,6 +1008,22 @@ namespace HeavenStudio
}),
}
},
new GameAction("lensDCenter", "Lens Distortion Center")
{
resizable = true,
parameters = new()
{
new("x1", new EntityTypes.Float(-1f, 1, 0), "Start X"),
new("y1", new EntityTypes.Float(-1f, 1, 0), "Start Y"),
new("x2", new EntityTypes.Float(-1f, 1, 0), "End X"),
new("y2", new EntityTypes.Float(-1f, 1, 0), "End Y"),
new Param("axis", StaticCamera.ViewAxis.All, "Axis"),
new("ease", Util.EasingFunction.Ease.Linear, "Ease", "", new()
{
new((x, y) => (Util.EasingFunction.Ease)x != Util.EasingFunction.Ease.Instant, new string[] { "x1", "y1" })
}),
}
},
new GameAction("grain", "Grain")
{
resizable = true,

View file

@ -12,9 +12,11 @@ namespace HeavenStudio
// events
private List<RiqEntity> _vignettes = new();
private List<RiqEntity> _vignetteCenters = new();
private List<RiqEntity> _cabbs = new();
private List<RiqEntity> _blooms = new();
private List<RiqEntity> _lensDs = new();
private List<RiqEntity> _lensDCenters = new();
private List<RiqEntity> _grains = new();
private List<RiqEntity> _colorGradings = new();
@ -31,9 +33,11 @@ namespace HeavenStudio
public void OnBeatChanged(double beat)
{
_vignettes = EventCaller.GetAllInGameManagerList("vfx", new string[] { "vignette" });
_vignetteCenters = EventCaller.GetAllInGameManagerList("vfx", new string[] { "vignetteCenter" });
_cabbs = EventCaller.GetAllInGameManagerList("vfx", new string[] { "cabb" });
_blooms = EventCaller.GetAllInGameManagerList("vfx", new string[] { "bloom" });
_lensDs = EventCaller.GetAllInGameManagerList("vfx", new string[] { "lensD" });
_lensDCenters = EventCaller.GetAllInGameManagerList("vfx", new string[] { "lensDCenter" });
_grains = EventCaller.GetAllInGameManagerList("vfx", new string[] { "grain" });
_colorGradings = EventCaller.GetAllInGameManagerList("vfx", new string[] { "colorGrading" });
@ -86,6 +90,36 @@ namespace HeavenStudio
float newRoundness = func(e["roundStart"], e["roundEnd"], clampNormal);
v.roundness.Override(newRoundness);
}
if (!v.enabled) return;
v.center.Override(new Vector2(0.5f, 0.5f));
foreach (var e in _vignetteCenters)
{
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 newX = 0.5f;
float newY = 0.5f;
switch ((StaticCamera.ViewAxis)e["axis"])
{
case StaticCamera.ViewAxis.All:
newX = func(e["x1"], e["x2"], clampNormal);
newY = func(e["y1"], e["y2"], clampNormal);
break;
case StaticCamera.ViewAxis.X:
newX = func(e["x1"], e["x2"], clampNormal);
break;
case StaticCamera.ViewAxis.Y:
newY = func(e["y1"], e["y2"], clampNormal);
break;
}
v.center.Override(new Vector2(newX, newY));
}
}
private void UpdateChromaticAbberations()
@ -162,6 +196,38 @@ namespace HeavenStudio
float newY = func(e["yStart"], e["yEnd"], clampNormal);
l.intensityY.Override(newY);
}
if (!l.enabled) return;
l.centerX.Override(0);
l.centerY.Override(0);
foreach (var e in _lensDCenters)
{
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 newX = 0;
float newY = 0;
switch ((StaticCamera.ViewAxis)e["axis"])
{
case StaticCamera.ViewAxis.All:
newX = func(e["x1"], e["x2"], clampNormal);
newY = func(e["y1"], e["y2"], clampNormal);
break;
case StaticCamera.ViewAxis.X:
newX = func(e["x1"], e["x2"], clampNormal);
break;
case StaticCamera.ViewAxis.Y:
newY = func(e["y1"], e["y2"], clampNormal);
break;
}
l.centerX.Override(newX);
l.centerY.Override(newY);
}
}
private void UpdateGrain()