后处理+FEEL完全改进

This commit is contained in:
SoulliesOfficial
2025-12-22 18:36:29 -05:00
parent c3914da4ac
commit a2052bfe16
1427 changed files with 193092 additions and 374110 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 02db0b2b0ecd9de4ebd314f53da5198c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,112 @@
using UnityEngine;
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
namespace MoreMountains.FeedbacksForThirdParty
{
[AddComponentMenu("")]
[FeedbackHelp("控制 Advanced Chromatic Aberration 效果。Intensity 支持曲线动画Center 和其他高级参数Extras支持在效果期间覆盖。")]
[FeedbackPath("PostProcess/Advanced Chromatic Aberration")]
public class MMF_AdvancedChromaticAberration : MMF_Feedback
{
public static bool FeedbackTypeAuthorized = true;
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
public override bool EvaluateRequiresSetup() { return (GameObject.FindObjectOfType<MMAdvancedChromaticAberrationShaker>() == null); }
public override string RequiredTargetText { get { return "MMAdvancedChromaticAberrationShaker"; } }
public override string RequiresSetupText { get { return "This feedback requires that a MMAdvancedChromaticAberrationShaker be present in your scene, typically on a Global Volume."; } }
#endif
[MMFInspectorGroup("Intensity Shake", true, 54)]
public float Duration = 0.2f;
public bool RelativeIntensity = false;
public AnimationCurve ShakeIntensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
public float RemapIntensityZero = 0f;
public float RemapIntensityOne = 0.05f;
[MMFInspectorGroup("Center Settings", true, 55)]
[Tooltip("是否修改扩散中心点")]
public bool ModifyCenter = false;
[MMFCondition("ModifyCenter", true)]
[Tooltip("新的扩散中心点 (0.5, 0.5) 为屏幕中心")]
public Vector2 Center = new Vector2(0.5f, 0.5f);
[MMFInspectorGroup("Extra Settings", true, 56)]
[Tooltip("是否修改高级参数 (Split, Dispersion, Jitter, Mask)")]
public bool ModifyExtra = false;
[MMFCondition("ModifyExtra", true)]
[Tooltip("RGB 分离权重")]
public Vector3 ChannelSplit = new Vector3(1f, 0f, -1f);
[MMFCondition("ModifyExtra", true)]
[Tooltip("色散方向打乱强度")]
public float DispersionStrength = 0f;
[MMFCondition("ModifyExtra", true)]
[Tooltip("UV 抖动强度 (Temporal Instability)")]
public float JitterIntensity = 0f;
[MMFCondition("ModifyExtra", true)]
[Tooltip("中心遮罩半径")]
public float MaskRadius = 0.2f;
[MMFCondition("ModifyExtra", true)]
[Tooltip("遮罩边缘硬度")]
public float MaskHardness = 0.2f;
[MMFInspectorGroup("General", true, 57)]
public bool ResetShakerValuesAfterShake = true;
public bool ResetTargetValuesAfterShake = true;
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized) return;
MMAdvancedChromaticAberrationShakeEvent.Trigger(
this,
ShakeIntensity,
FeedbackDuration,
RemapIntensityZero,
RemapIntensityOne,
RelativeIntensity,
feedbacksIntensity,
ChannelData,
ResetShakerValuesAfterShake,
ResetTargetValuesAfterShake,
NormalPlayDirection,
ComputedTimescaleMode,
false, // stop
false, // restore
// Center
ModifyCenter,
Center,
// Extras
ModifyExtra,
ChannelSplit,
DispersionStrength,
JitterIntensity,
MaskRadius,
MaskHardness
);
}
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized) return;
MMAdvancedChromaticAberrationShakeEvent.Trigger(this, ShakeIntensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, stop: true);
}
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized) return;
MMAdvancedChromaticAberrationShakeEvent.Trigger(this, ShakeIntensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, restore: true);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 979b72b70fd22c643a59ff6453baa3f3

View File

@@ -0,0 +1,110 @@
using UnityEngine;
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
namespace MoreMountains.FeedbacksForThirdParty
{
[AddComponentMenu("")]
[FeedbackHelp("控制 Advanced Vignette 效果。用于制作受击暗角、环境压抑效果等。")]
[FeedbackPath("PostProcess/Advanced Vignette")]
public class MMF_AdvancedVignette : MMF_Feedback
{
public static bool FeedbackTypeAuthorized = true;
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
public override bool EvaluateRequiresSetup() { return (GameObject.FindObjectOfType<MMAdvancedVignetteShaker>() == null); }
public override string RequiredTargetText { get { return "MMAdvancedVignetteShaker"; } }
public override string RequiresSetupText { get { return "This feedback requires a MMAdvancedVignetteShaker on your Volume."; } }
#endif
[MMFInspectorGroup("Intensity Shake", true, 54)]
public float Duration = 0.2f;
public bool RelativeIntensity = false;
public AnimationCurve ShakeIntensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
public float RemapIntensityZero = 0f;
public float RemapIntensityOne = 1f;
[MMFInspectorGroup("Center Settings", true, 55)]
public bool ModifyCenter = false;
[MMFCondition("ModifyCenter", true)]
public Vector2 Center = new Vector2(0.5f, 0.5f);
[MMFInspectorGroup("Color Settings", true, 56)]
public bool ModifyColors = false;
[MMFCondition("ModifyColors", true)]
[Tooltip("边缘最暗处的颜色")]
public Color ColorOuter = Color.black;
[MMFCondition("ModifyColors", true)]
[Tooltip("暗角过渡区的颜色")]
public Color ColorInner = Color.black;
[MMFInspectorGroup("Extra Settings", true, 57)]
public bool ModifyExtra = false;
[MMFCondition("ModifyExtra", true)]
[Tooltip("柔和度 (0.01 - 1)")]
public float Smoothness = 0.5f;
[MMFCondition("ModifyExtra", true)]
[Tooltip("圆度 (0 = 方形, 1 = 圆形)")]
public float Roundness = 1f;
[MMFInspectorGroup("General", true, 58)]
public bool ResetShakerValuesAfterShake = true;
public bool ResetTargetValuesAfterShake = true;
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized) return;
MMAdvancedVignetteShakeEvent.Trigger(
this,
ShakeIntensity,
FeedbackDuration,
RemapIntensityZero,
RemapIntensityOne,
RelativeIntensity,
feedbacksIntensity,
ChannelData,
ResetShakerValuesAfterShake,
ResetTargetValuesAfterShake,
NormalPlayDirection,
ComputedTimescaleMode,
false, // stop
false, // restore
// Center
ModifyCenter,
Center,
// Colors
ModifyColors,
ColorOuter,
ColorInner,
// Extras
ModifyExtra,
Smoothness,
Roundness
);
}
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized) return;
MMAdvancedVignetteShakeEvent.Trigger(this, ShakeIntensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, stop: true);
}
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized) return;
MMAdvancedVignetteShakeEvent.Trigger(this, ShakeIntensity, FeedbackDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, restore: true);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f07981798459b6a488d6269c7263522a

View File

@@ -0,0 +1,100 @@
using UnityEngine;
using MoreMountains.Feedbacks;
namespace MoreMountains.FeedbacksForThirdParty
{
[AddComponentMenu("")]
[FeedbackHelp("This feedback allows you to control the Blur Radius of your custom Radial Blur effect over time, and optionally set the Blur Center.")]
[FeedbackPath("PostProcess/Radial Blur")]
public class MMF_RadialBlur : MMF_Feedback
{
public static bool FeedbackTypeAuthorized = true;
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
public override bool EvaluateRequiresSetup() { return (GameObject.FindObjectOfType<MMRadialBlurShaker>() == null); }
public override string RequiredTargetText { get { return "MMRadialBlurShaker"; } }
public override string RequiresSetupText { get { return "This feedback requires that a MMRadialBlurShaker be present in your scene, typically on a Global Volume."; } }
#endif
[MMFInspectorGroup("Radial Blur Intensity", true, 45)]
[Tooltip("震动持续时间")]
public float ShakeDuration = 0.2f;
[Tooltip("是否使用相对值")]
public bool RelativeIntensity = false;
[Tooltip("震动曲线")]
public AnimationCurve ShakeIntensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
[Tooltip("曲线 0 对应的模糊半径")]
public float RemapIntensityZero = 0f;
[Tooltip("曲线 1 对应的模糊半径")]
public float RemapIntensityOne = 0.5f;
// --- 新增部分:中心点控制 ---
[MMFInspectorGroup("Radial Center", true, 46)]
[Tooltip("是否修改模糊中心。如果关闭,将使用当前 Volume 的设置(通常为 0.5, 0.5)。")]
public bool ModifyCenter = true; // 默认开启
[Tooltip("模糊中心的屏幕坐标 (0-1)。(0.5, 0.5) 为屏幕正中心。")]
[MMFCondition("ModifyCenter", true)]
public Vector2 TargetCenter = new Vector2(0.5f, 0.5f);
// ---------------------------
[MMFInspectorGroup("Settings", true, 47)]
[Tooltip("结束后重置 Shaker")]
public bool ResetShakerValuesAfterShake = true;
[Tooltip("结束后重置目标值 (Blur Radius 和 Center)")]
public bool ResetTargetValuesAfterShake = true;
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized) return;
MMRadialBlurShakeEvent.Trigger(
this,
ShakeIntensity,
ShakeDuration,
RemapIntensityZero,
RemapIntensityOne,
RelativeIntensity,
feedbacksIntensity,
ChannelData,
ResetShakerValuesAfterShake,
ResetTargetValuesAfterShake,
NormalPlayDirection,
ComputedTimescaleMode,
false, // stop
false, // restore
ModifyCenter, // 传递 modifyCenter
TargetCenter // 传递 Vector2 center
);
}
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized) return;
MMRadialBlurShakeEvent.Trigger(
this, ShakeIntensity, ShakeDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity,
feedbacksIntensity, ChannelData, ResetShakerValuesAfterShake, ResetTargetValuesAfterShake,
NormalPlayDirection, ComputedTimescaleMode, stop: true
);
}
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized) return;
MMRadialBlurShakeEvent.Trigger(
this, ShakeIntensity, ShakeDuration, RemapIntensityZero, RemapIntensityOne, RelativeIntensity,
1.0f, ChannelData, ResetShakerValuesAfterShake, ResetTargetValuesAfterShake,
NormalPlayDirection, ComputedTimescaleMode, restore: true
);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6fb5a79c3eeee014d871040588e4abc9

View File

@@ -0,0 +1,83 @@
using UnityEngine;
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
namespace MoreMountains.FeedbacksForThirdParty
{
[AddComponentMenu("")]
[FeedbackHelp("控制 Strobe Flash (黑白闪) 效果。在 Duration 期间会自动开启 Auto Flash结束后关闭。")]
[FeedbackPath("PostProcess/Strobe Flash")]
public class MMF_StrobeFlash : MMF_Feedback
{
public static bool FeedbackTypeAuthorized = true;
#if UNITY_EDITOR
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.PostProcessColor; } }
public override bool EvaluateRequiresSetup() { return (GameObject.FindObjectOfType<MMStrobeFlashShaker>() == null); }
public override string RequiredTargetText { get { return "MMStrobeFlashShaker"; } }
public override string RequiresSetupText { get { return "This feedback requires a MMStrobeFlashShaker on your Volume."; } }
#endif
[MMFInspectorGroup("Strobe Settings", true, 54)]
[Tooltip("闪烁持续时间")]
public float Duration = 0.5f;
[MMFInspectorGroup("Extra Settings", true, 55)]
[Tooltip("是否修改频率和颜色")]
public bool ModifyExtra = false;
[MMFCondition("ModifyExtra", true)]
[Tooltip("闪烁频率")]
public float Frequency = 15f;
[MMFCondition("ModifyExtra", true)]
[Tooltip("高亮颜色 (通常为白色)")]
public Color ColorHigh = Color.white;
[MMFCondition("ModifyExtra", true)]
[Tooltip("暗部颜色 (通常为黑色)")]
public Color ColorLow = Color.black;
[MMFInspectorGroup("General", true, 56)]
public bool ResetShakerValuesAfterShake = true;
public bool ResetTargetValuesAfterShake = true;
public override float FeedbackDuration { get { return ApplyTimeMultiplier(Duration); } set { Duration = value; } }
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized) return;
MMStrobeFlashShakeEvent.Trigger(
this,
FeedbackDuration,
feedbacksIntensity,
ChannelData,
ResetShakerValuesAfterShake,
ResetTargetValuesAfterShake,
NormalPlayDirection,
ComputedTimescaleMode,
false, // stop
false, // restore
// Extra Params
ModifyExtra,
Frequency,
ColorHigh,
ColorLow
);
}
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
{
if (!Active || !FeedbackTypeAuthorized) return;
MMStrobeFlashShakeEvent.Trigger(this, Duration, stop: true);
}
protected override void CustomRestoreInitialValues()
{
if (!Active || !FeedbackTypeAuthorized) return;
MMStrobeFlashShakeEvent.Trigger(this, Duration, restore: true);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: eaa5f33ff82bdc144b4a1b20ee37d88c

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b5e239d71a98e5c41b4a3f96adb1c3b1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,219 @@
using UnityEngine;
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
using UnityEngine.Rendering;
// 引入你的 PostProcess 命名空间
using SLSFramework.Rendering.PostProcessing;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// 事件定义:携带所有必要的参数
/// </summary>
public struct MMAdvancedChromaticAberrationShakeEvent
{
public static void Register(Delegate callback) { OnEvent += callback; }
public static void Unregister(Delegate callback) { OnEvent -= callback; }
public delegate void Delegate(MMF_Feedback source, AnimationCurve intensityCurve, float duration, float remapMin, float remapMax, bool relativeIntensity = false,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true,
TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false,
// Center
bool modifyCenter = false, Vector2 center = default,
// Extras
bool modifyExtra = false, Vector3 channelSplit = default, float dispersionStrength = 0f, float jitterIntensity = 0f, float maskRadius = 0.2f, float maskHardness = 0.2f);
public static event Delegate OnEvent;
public static void Trigger(MMF_Feedback source, AnimationCurve intensityCurve, float duration, float remapMin, float remapMax, bool relativeIntensity = false,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true,
TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false,
bool modifyCenter = false, Vector2 center = default,
bool modifyExtra = false, Vector3 channelSplit = default, float dispersionStrength = 0f, float jitterIntensity = 0f, float maskRadius = 0.2f, float maskHardness = 0.2f)
{
OnEvent?.Invoke(source, intensityCurve, duration, remapMin, remapMax, relativeIntensity, feedbacksIntensity, channelData, resetShakerValuesAfterShake, resetTargetValuesAfterShake, forwardDirection, timescaleMode, stop, restore,
modifyCenter, center, modifyExtra, channelSplit, dispersionStrength, jitterIntensity, maskRadius, maskHardness);
}
}
/// <summary>
/// Shaker: 控制 Advanced Chromatic Aberration
/// </summary>
[AddComponentMenu("More Mountains/Feedbacks/Shakers/PostProcessing/MM Advanced Chromatic Aberration Shaker")]
[RequireComponent(typeof(Volume))]
public class MMAdvancedChromaticAberrationShaker : MMShaker
{
[MMInspectorGroup("Intensity", true, 53)]
[Tooltip("是否在现有 Intensity 基础上叠加")]
public bool RelativeIntensity = false;
[Tooltip("Intensity 的震动曲线")]
public AnimationCurve ShakeIntensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
[Tooltip("曲线 0 对应的值")]
public float RemapIntensityZero = 0f;
[Tooltip("曲线 1 对应的值")]
public float RemapIntensityOne = 1f;
protected Volume _volume;
protected AdvancedChromaticAberration _aca;
// 初始值存储
protected float _initialIntensity;
protected Vector2 _initialCenter;
protected Vector3 _initialSplit;
protected float _initialDispersion;
protected float _initialJitter;
protected float _initialMaskRadius;
protected float _initialMaskHardness;
// 运行时目标值存储
protected bool _modifyCenter;
protected Vector2 _targetCenter;
protected bool _modifyExtra;
protected Vector3 _targetSplit;
protected float _targetDispersion;
protected float _targetJitter;
protected float _targetMaskRadius;
protected float _targetMaskHardness;
// Shaker 复位备份
protected float _originalShakeDuration;
protected bool _originalRelativeIntensity;
protected AnimationCurve _originalShakeIntensity;
protected float _originalRemapIntensityZero;
protected float _originalRemapIntensityOne;
protected override void Initialization()
{
base.Initialization();
_volume = GetComponent<Volume>();
if (!_volume.profile.TryGet(out _aca))
{
Debug.LogWarning("MMAdvancedChromaticAberrationShaker : No AdvancedChromaticAberration found in Volume on " + name);
}
}
protected override void GrabInitialValues()
{
if (_aca != null)
{
_initialIntensity = _aca.intensity.value;
_initialCenter = _aca.center.value;
_initialSplit = _aca.channelSplit.value;
_initialDispersion = _aca.dispersionStrength.value;
_initialJitter = _aca.jitterIntensity.value;
_initialMaskRadius = _aca.maskRadius.value;
_initialMaskHardness = _aca.maskHardness.value;
}
}
protected override void Shake()
{
if (_aca == null) return;
// 1. 驱动 Intensity (带有 Curve 动画)
float newIntensity = ShakeFloat(ShakeIntensity, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, _initialIntensity);
_aca.intensity.value = newIntensity;
// 2. 驱动 Center (如果启用,强制设为目标值)
if (_modifyCenter)
{
_aca.center.value = _targetCenter;
}
// 3. 驱动 Extras (如果启用,强制设为目标值)
if (_modifyExtra)
{
_aca.channelSplit.value = _targetSplit;
_aca.dispersionStrength.value = _targetDispersion;
_aca.jitterIntensity.value = _targetJitter;
_aca.maskRadius.value = _targetMaskRadius;
_aca.maskHardness.value = _targetMaskHardness;
}
}
protected override void ResetTargetValues()
{
base.ResetTargetValues();
if (_aca != null)
{
_aca.intensity.value = _initialIntensity;
_aca.center.value = _initialCenter;
_aca.channelSplit.value = _initialSplit;
_aca.dispersionStrength.value = _initialDispersion;
_aca.jitterIntensity.value = _initialJitter;
_aca.maskRadius.value = _initialMaskRadius;
_aca.maskHardness.value = _initialMaskHardness;
}
}
protected override void ResetShakerValues()
{
base.ResetShakerValues();
ShakeDuration = _originalShakeDuration;
ShakeIntensity = _originalShakeIntensity;
RemapIntensityZero = _originalRemapIntensityZero;
RemapIntensityOne = _originalRemapIntensityOne;
RelativeIntensity = _originalRelativeIntensity;
_modifyCenter = false;
_modifyExtra = false;
}
public virtual void OnEvent(MMF_Feedback source, AnimationCurve intensityCurve, float duration, float remapMin, float remapMax, bool relativeIntensity = false,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true,
TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false,
bool modifyCenter = false, Vector2 center = default,
bool modifyExtra = false, Vector3 channelSplit = default, float dispersionStrength = 0f, float jitterIntensity = 0f, float maskRadius = 0.2f, float maskHardness = 0.2f)
{
if (!CheckEventAllowed(channelData)) return;
if (stop) { Stop(); return; }
if (restore) { ResetTargetValues(); return; }
if (resetShakerValuesAfterShake)
{
_originalShakeDuration = ShakeDuration;
_originalShakeIntensity = ShakeIntensity;
_originalRemapIntensityZero = RemapIntensityZero;
_originalRemapIntensityOne = RemapIntensityOne;
_originalRelativeIntensity = RelativeIntensity;
}
if (!OnlyUseShakerValues)
{
TimescaleMode = timescaleMode;
ShakeDuration = duration;
ShakeIntensity = intensityCurve;
RemapIntensityZero = remapMin * feedbacksIntensity;
RemapIntensityOne = remapMax * feedbacksIntensity;
RelativeIntensity = relativeIntensity;
ForwardDirection = forwardDirection;
// 接收额外参数
_modifyCenter = modifyCenter;
_targetCenter = center;
_modifyExtra = modifyExtra;
_targetSplit = channelSplit;
_targetDispersion = dispersionStrength;
_targetJitter = jitterIntensity;
_targetMaskRadius = maskRadius;
_targetMaskHardness = maskHardness;
}
Play(source);
}
public override void StartListening()
{
base.StartListening();
MMAdvancedChromaticAberrationShakeEvent.Register(OnEvent);
}
public override void StopListening()
{
base.StopListening();
MMAdvancedChromaticAberrationShakeEvent.Unregister(OnEvent);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 83e1b594d698f9449ac7adafb9976fec

View File

@@ -0,0 +1,224 @@
using UnityEngine;
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
using UnityEngine.Rendering;
// 引入你的命名空间
using SLSFramework.Rendering.PostProcessing;
namespace MoreMountains.FeedbacksForThirdParty
{
/// <summary>
/// 事件定义:携带 Advanced Vignette 所需的所有参数
/// </summary>
public struct MMAdvancedVignetteShakeEvent
{
public static void Register(Delegate callback) { OnEvent += callback; }
public static void Unregister(Delegate callback) { OnEvent -= callback; }
public delegate void Delegate(MMF_Feedback source, AnimationCurve intensityCurve, float duration, float remapMin, float remapMax, bool relativeIntensity = false,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true,
TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false,
// Custom Params
bool modifyCenter = false, Vector2 center = default,
bool modifyColors = false, Color colorOuter = default, Color colorInner = default,
bool modifyExtra = false, float smoothness = 0.5f, float roundness = 1f);
public static event Delegate OnEvent;
public static void Trigger(MMF_Feedback source, AnimationCurve intensityCurve, float duration, float remapMin, float remapMax, bool relativeIntensity = false,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true,
TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false,
bool modifyCenter = false, Vector2 center = default,
bool modifyColors = false, Color colorOuter = default, Color colorInner = default,
bool modifyExtra = false, float smoothness = 0.5f, float roundness = 1f)
{
OnEvent?.Invoke(source, intensityCurve, duration, remapMin, remapMax, relativeIntensity, feedbacksIntensity, channelData, resetShakerValuesAfterShake, resetTargetValuesAfterShake, forwardDirection, timescaleMode, stop, restore,
modifyCenter, center, modifyColors, colorOuter, colorInner, modifyExtra, smoothness, roundness);
}
}
/// <summary>
/// Shaker: 控制 Advanced Vignette 效果
/// </summary>
[AddComponentMenu("More Mountains/Feedbacks/Shakers/PostProcessing/MM Advanced Vignette Shaker")]
[RequireComponent(typeof(Volume))]
public class MMAdvancedVignetteShaker : MMShaker
{
[MMInspectorGroup("Intensity", true, 53)]
[Tooltip("是否在现有 Intensity 基础上叠加")]
public bool RelativeIntensity = false;
[Tooltip("Intensity 的震动曲线")]
public AnimationCurve ShakeIntensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
[Tooltip("曲线 0 对应的值")]
public float RemapIntensityZero = 0f;
[Tooltip("曲线 1 对应的值")]
public float RemapIntensityOne = 1f;
protected Volume _volume;
protected AdvancedVignette _vignette;
// 初始值存储
protected float _initialIntensity;
protected Vector2 _initialCenter;
protected Color _initialColorOuter;
protected Color _initialColorInner;
protected float _initialSmoothness;
protected float _initialRoundness;
// 运行时目标值
protected bool _modifyCenter;
protected Vector2 _targetCenter;
protected bool _modifyColors;
protected Color _targetColorOuter;
protected Color _targetColorInner;
protected bool _modifyExtra;
protected float _targetSmoothness;
protected float _targetRoundness;
// Shaker 状态备份
protected float _originalShakeDuration;
protected bool _originalRelativeIntensity;
protected AnimationCurve _originalShakeIntensity;
protected float _originalRemapIntensityZero;
protected float _originalRemapIntensityOne;
protected override void Initialization()
{
base.Initialization();
_volume = GetComponent<Volume>();
if (!_volume.profile.TryGet(out _vignette))
{
Debug.LogWarning("MMAdvancedVignetteShaker : No AdvancedVignette found in Volume on " + name);
}
}
protected override void GrabInitialValues()
{
if (_vignette != null)
{
_initialIntensity = _vignette.intensity.value;
_initialCenter = _vignette.center.value;
_initialColorOuter = _vignette.colorOuter.value;
_initialColorInner = _vignette.colorInner.value;
_initialSmoothness = _vignette.smoothness.value;
_initialRoundness = _vignette.roundness.value;
}
}
protected override void Shake()
{
if (_vignette == null) return;
// 1. 驱动 Intensity
float newIntensity = ShakeFloat(ShakeIntensity, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, _initialIntensity);
_vignette.intensity.value = newIntensity;
// 2. 驱动 Center
if (_modifyCenter)
{
_vignette.center.value = _targetCenter;
}
// 3. 驱动 Colors
if (_modifyColors)
{
_vignette.colorOuter.value = _targetColorOuter;
_vignette.colorInner.value = _targetColorInner;
}
// 4. 驱动 Extra (Smoothness, Roundness)
if (_modifyExtra)
{
_vignette.smoothness.value = _targetSmoothness;
_vignette.roundness.value = _targetRoundness;
}
}
protected override void ResetTargetValues()
{
base.ResetTargetValues();
if (_vignette != null)
{
_vignette.intensity.value = _initialIntensity;
_vignette.center.value = _initialCenter;
_vignette.colorOuter.value = _initialColorOuter;
_vignette.colorInner.value = _initialColorInner;
_vignette.smoothness.value = _initialSmoothness;
_vignette.roundness.value = _initialRoundness;
}
}
protected override void ResetShakerValues()
{
base.ResetShakerValues();
ShakeDuration = _originalShakeDuration;
ShakeIntensity = _originalShakeIntensity;
RemapIntensityZero = _originalRemapIntensityZero;
RemapIntensityOne = _originalRemapIntensityOne;
RelativeIntensity = _originalRelativeIntensity;
_modifyCenter = false;
_modifyColors = false;
_modifyExtra = false;
}
public virtual void OnEvent(MMF_Feedback source, AnimationCurve intensityCurve, float duration, float remapMin, float remapMax, bool relativeIntensity = false,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true,
TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false,
bool modifyCenter = false, Vector2 center = default,
bool modifyColors = false, Color colorOuter = default, Color colorInner = default,
bool modifyExtra = false, float smoothness = 0.5f, float roundness = 1f)
{
if (!CheckEventAllowed(channelData)) return;
if (stop) { Stop(); return; }
if (restore) { ResetTargetValues(); return; }
if (resetShakerValuesAfterShake)
{
_originalShakeDuration = ShakeDuration;
_originalShakeIntensity = ShakeIntensity;
_originalRemapIntensityZero = RemapIntensityZero;
_originalRemapIntensityOne = RemapIntensityOne;
_originalRelativeIntensity = RelativeIntensity;
}
if (!OnlyUseShakerValues)
{
TimescaleMode = timescaleMode;
ShakeDuration = duration;
ShakeIntensity = intensityCurve;
RemapIntensityZero = remapMin * feedbacksIntensity;
RemapIntensityOne = remapMax * feedbacksIntensity;
RelativeIntensity = relativeIntensity;
ForwardDirection = forwardDirection;
_modifyCenter = modifyCenter;
_targetCenter = center;
_modifyColors = modifyColors;
_targetColorOuter = colorOuter;
_targetColorInner = colorInner;
_modifyExtra = modifyExtra;
_targetSmoothness = smoothness;
_targetRoundness = roundness;
}
Play(source);
}
public override void StartListening()
{
base.StartListening();
MMAdvancedVignetteShakeEvent.Register(OnEvent);
}
public override void StopListening()
{
base.StopListening();
MMAdvancedVignetteShakeEvent.Unregister(OnEvent);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 11b930e92331e8c48b320c5d04808814

View File

@@ -0,0 +1,187 @@
using UnityEngine;
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
using UnityEngine.Rendering;
using SLSFramework.Rendering.PostProcessing;
namespace MoreMountains.FeedbacksForThirdParty
{
public struct MMRadialBlurShakeEvent
{
public static void Register(Delegate callback) { OnEvent += callback; }
public static void Unregister(Delegate callback) { OnEvent -= callback; }
// 修改点:在参数列表中增加了 modifyCenter 和 center
public delegate void Delegate(MMF_Feedback source, AnimationCurve distortionCurve, float duration, float remapMin, float remapMax, bool relativeDistortion = false,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true,
TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false,
bool modifyCenter = false, Vector2 center = default); // 新增参数放在最后,带默认值以保持兼容性
public static event Delegate OnEvent;
public static void Trigger(MMF_Feedback source, AnimationCurve distortionCurve, float duration, float remapMin, float remapMax, bool relativeDistortion = false,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true,
TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false,
bool modifyCenter = false, Vector2 center = default)
{
OnEvent?.Invoke(source, distortionCurve, duration, remapMin, remapMax, relativeDistortion, feedbacksIntensity, channelData, resetShakerValuesAfterShake, resetTargetValuesAfterShake, forwardDirection, timescaleMode, stop, restore, modifyCenter, center);
}
}
[AddComponentMenu("More Mountains/Feedbacks/Shakers/PostProcessing/MM Radial Blur Shaker")]
[RequireComponent(typeof(Volume))]
public class MMRadialBlurShaker : MMShaker
{
[MMInspectorGroup("Radial Blur", true, 52)]
[Tooltip("是否在现有值的基础上叠加")]
public bool RelativeIntensity = false;
[Tooltip("模糊强度的震动曲线")]
public AnimationCurve ShakeIntensity = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
[Tooltip("曲线 0 对应的 Blur Radius 值")]
public float RemapIntensityZero = 0f;
[Tooltip("曲线 1 对应的 Blur Radius 值")]
public float RemapIntensityOne = 1f;
protected Volume _volume;
protected RadialBlur _radialBlur;
// 初始值记录
protected float _initialIntensity;
protected float _initialCenterX;
protected float _initialCenterY;
// 震动时的临时变量
protected bool _modifyCenter;
protected Vector2 _targetCenter;
protected float _originalShakeDuration;
protected bool _originalRelativeIntensity;
protected AnimationCurve _originalShakeIntensity;
protected float _originalRemapIntensityZero;
protected float _originalRemapIntensityOne;
protected override void Initialization()
{
base.Initialization();
_volume = this.gameObject.GetComponent<Volume>();
if (_volume.profile.TryGet<RadialBlur>(out _radialBlur))
{
// 获取成功
}
else
{
Debug.LogWarning("MMRadialBlurShaker : No RadialBlur Override found in the Volume on " + this.name);
}
}
protected override void GrabInitialValues()
{
if (_radialBlur != null)
{
_initialIntensity = _radialBlur.blurRadius.value;
_initialCenterX = _radialBlur.radialCenterX.value;
_initialCenterY = _radialBlur.radialCenterY.value;
}
}
protected override void Shake()
{
if (_radialBlur == null) return;
// 1. 处理模糊强度 (Radius)
float newIntensity = ShakeFloat(ShakeIntensity, RemapIntensityZero, RemapIntensityOne, RelativeIntensity, _initialIntensity);
_radialBlur.blurRadius.value = newIntensity;
// 2. 处理模糊中心 (Center) - 新增逻辑
// 只有当 Feedback 要求修改中心时才覆盖,否则保持原样 (通常是 0.5)
if (_modifyCenter)
{
_radialBlur.radialCenterX.value = _targetCenter.x;
_radialBlur.radialCenterY.value = _targetCenter.y;
}
else
{
// 如果不修改,我们强制设为默认中心(0.5, 0.5)或者初始值?
// 根据你的描述:如果不开启,默认中心为(0.5,0.5)。
// 为了保险这里可以不做操作保留Volume当前值也可以强制复位。
// 建议不做操作让ResetTargetValues去负责恢复。
}
}
protected override void ResetTargetValues()
{
base.ResetTargetValues();
if (_radialBlur != null)
{
_radialBlur.blurRadius.value = _initialIntensity;
// 复位中心点
_radialBlur.radialCenterX.value = _initialCenterX;
_radialBlur.radialCenterY.value = _initialCenterY;
}
}
protected override void ResetShakerValues()
{
base.ResetShakerValues();
ShakeDuration = _originalShakeDuration;
ShakeIntensity = _originalShakeIntensity;
RemapIntensityZero = _originalRemapIntensityZero;
RemapIntensityOne = _originalRemapIntensityOne;
RelativeIntensity = _originalRelativeIntensity;
// 震动结束,重置 modifyCenter 标记,防止后续影响
_modifyCenter = false;
}
public virtual void OnMMRadialBlurShakeEvent(MMF_Feedback source, AnimationCurve distortionCurve, float duration, float remapMin, float remapMax, bool relativeDistortion = false,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true,
TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false,
bool modifyCenter = false, Vector2 center = default)
{
if (!CheckEventAllowed(channelData)) return;
if (stop) { Stop(); return; }
if (restore) { ResetTargetValues(); return; }
if (!Interruptible && Shaking) return;
_resetShakerValuesAfterShake = resetShakerValuesAfterShake;
_resetTargetValuesAfterShake = resetTargetValuesAfterShake;
if (resetShakerValuesAfterShake)
{
_originalShakeDuration = ShakeDuration;
_originalShakeIntensity = ShakeIntensity;
_originalRemapIntensityZero = RemapIntensityZero;
_originalRemapIntensityOne = RemapIntensityOne;
_originalRelativeIntensity = RelativeIntensity;
}
if (!OnlyUseShakerValues)
{
TimescaleMode = timescaleMode;
ShakeDuration = duration;
ShakeIntensity = distortionCurve;
RemapIntensityZero = remapMin * feedbacksIntensity;
RemapIntensityOne = remapMax * feedbacksIntensity;
RelativeIntensity = relativeDistortion;
ForwardDirection = forwardDirection;
// 接收并存储中心点参数
_modifyCenter = modifyCenter;
_targetCenter = center;
}
Play(source);
}
public override void StartListening()
{
base.StartListening();
MMRadialBlurShakeEvent.Register(OnMMRadialBlurShakeEvent);
}
public override void StopListening()
{
base.StopListening();
MMRadialBlurShakeEvent.Unregister(OnMMRadialBlurShakeEvent);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: d41e65444be95a7469ed5fab9af1d3a2

View File

@@ -0,0 +1,188 @@
using UnityEngine;
using MoreMountains.Feedbacks;
using MoreMountains.Tools;
using UnityEngine.Rendering;
using SLSFramework.Rendering.PostProcessing;
namespace MoreMountains.FeedbacksForThirdParty
{
public struct MMStrobeFlashShakeEvent
{
public static void Register(Delegate callback) { OnEvent += callback; }
public static void Unregister(Delegate callback) { OnEvent -= callback; }
public delegate void Delegate(MMF_Feedback source, float duration,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true,
TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false,
bool modifyExtra = false, float frequency = 15f, Color colorHigh = default, Color colorLow = default);
public static event Delegate OnEvent;
public static void Trigger(MMF_Feedback source, float duration,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true,
TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false,
bool modifyExtra = false, float frequency = 15f, Color colorHigh = default, Color colorLow = default)
{
OnEvent?.Invoke(source, duration, feedbacksIntensity, channelData, resetShakerValuesAfterShake, resetTargetValuesAfterShake, forwardDirection, timescaleMode, stop, restore,
modifyExtra, frequency, colorHigh, colorLow);
}
}
[AddComponentMenu("More Mountains/Feedbacks/Shakers/PostProcessing/MM Strobe Flash Shaker")]
[RequireComponent(typeof(Volume))]
public class MMStrobeFlashShaker : MMShaker
{
[MMInspectorGroup("Strobe Settings", true, 53)]
[Tooltip("如果勾选,震动结束后会强制关闭 Effect无论初始状态是什么。建议勾选。")]
public bool ForceOffAfterShake = true;
[MMInspectorGroup("Debug Info", true, 54)]
[MMReadOnly]
public bool IsActive = false;
protected Volume _volume;
protected StrobeFlash _strobe;
protected bool _initialEnableEffect;
protected bool _initialAutoFlash;
protected float _initialFrequency;
protected Color _initialColorHigh;
protected Color _initialColorLow;
protected bool _modifyExtra;
protected float _targetFrequency;
protected Color _targetColorHigh;
protected Color _targetColorLow;
protected float _originalShakeDuration;
protected override void Initialization()
{
base.Initialization();
_volume = GetComponent<Volume>();
if (!_volume.profile.TryGet(out _strobe))
{
Debug.LogWarning("MMStrobeFlashShaker : No StrobeFlash found in Volume on " + name);
}
}
protected override void GrabInitialValues()
{
if (_strobe != null)
{
_initialEnableEffect = _strobe.enableEffect.value;
_initialAutoFlash = _strobe.autoFlash.value;
_initialFrequency = _strobe.frequency.value;
_initialColorHigh = _strobe.colorHigh.value;
_initialColorLow = _strobe.colorLow.value;
}
}
protected override void Shake()
{
if (_strobe == null) return;
// 强制开启
_strobe.enableEffect.value = true;
_strobe.autoFlash.value = true;
IsActive = true;
if (_modifyExtra)
{
_strobe.frequency.value = _targetFrequency;
_strobe.colorHigh.value = _targetColorHigh;
_strobe.colorLow.value = _targetColorLow;
}
}
// 确保 Stop 被调用时执行复位
public override void Stop()
{
base.Stop();
// base.Stop() 会调用 ResetTargetValues但为了保险再次确保状态
IsActive = false;
}
protected override void ResetTargetValues()
{
base.ResetTargetValues();
IsActive = false;
if (_strobe != null)
{
// [关键修改] 如果开启了强制关闭,直接设为 false否则恢复初始值
if (ForceOffAfterShake)
{
_strobe.enableEffect.value = false;
_strobe.autoFlash.value = false;
}
else
{
_strobe.enableEffect.value = _initialEnableEffect;
_strobe.autoFlash.value = _initialAutoFlash;
}
_strobe.frequency.value = _initialFrequency;
_strobe.colorHigh.value = _initialColorHigh;
_strobe.colorLow.value = _initialColorLow;
}
}
protected override void ResetShakerValues()
{
base.ResetShakerValues();
ShakeDuration = _originalShakeDuration;
_modifyExtra = false;
}
// 增加 OnDisable 处理,防止游戏物体被禁用时状态残留
protected virtual void OnDisable()
{
if (IsActive)
{
ResetTargetValues();
}
}
public virtual void OnEvent(MMF_Feedback source, float duration,
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true,
TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false,
bool modifyExtra = false, float frequency = 15f, Color colorHigh = default, Color colorLow = default)
{
if (!CheckEventAllowed(channelData)) return;
if (stop) { Stop(); return; }
if (restore) { ResetTargetValues(); return; }
if (resetShakerValuesAfterShake)
{
_originalShakeDuration = ShakeDuration;
}
if (!OnlyUseShakerValues)
{
TimescaleMode = timescaleMode;
ShakeDuration = duration;
_modifyExtra = modifyExtra;
_targetFrequency = frequency;
_targetColorHigh = colorHigh;
_targetColorLow = colorLow;
}
// 你的框架修改:传入 source
Play(source);
}
public override void StartListening()
{
base.StartListening();
MMStrobeFlashShakeEvent.Register(OnEvent);
}
public override void StopListening()
{
base.StopListening();
MMStrobeFlashShakeEvent.Unregister(OnEvent);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b009481b9292ba746a63d75b2e91e6c5