feat(huoshan): 新增屏幕glitch shader与强度驱动

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-25 15:56:41 +08:00
co-authored by Cursor
parent 1620c25f82
commit e2461ff0e5
8 changed files with 803 additions and 2 deletions
@@ -74,6 +74,40 @@ public class SpriteNoiseGlitchController : MonoBehaviour
public CompositeMode CurrentCompositeMode => _compositeMode;
/// <summary>
/// 仅对齐位置/尺寸与 sortingOrder,不改 Layer。
/// glitch_transition 的 noise 必须留在 Default;若改成 HuoshanScreen 会进 VolFx 叠在粒子上。
/// </summary>
public void ConfigureOverlayFor(SpriteRenderer targetRenderer, int sortingOrderOffset = 1)
{
EnsureRuntimeObjects();
if (_renderer == null || _renderer.sprite == null || targetRenderer == null)
return;
_renderer.sortingLayerID = targetRenderer.sortingLayerID;
_renderer.sortingOrder = targetRenderer.sortingOrder + sortingOrderOffset;
Bounds targetBounds = targetRenderer.bounds;
Bounds overlayBounds = _renderer.bounds;
if (targetBounds.size.x <= Mathf.Epsilon ||
targetBounds.size.y <= Mathf.Epsilon ||
overlayBounds.size.x <= Mathf.Epsilon ||
overlayBounds.size.y <= Mathf.Epsilon)
{
return;
}
Vector3 position = transform.position;
position.x = targetBounds.center.x;
position.y = targetBounds.center.y;
transform.position = position;
Vector3 scale = transform.localScale;
scale.x *= targetBounds.size.x / overlayBounds.size.x;
scale.y *= targetBounds.size.y / overlayBounds.size.y;
transform.localScale = scale;
}
private void Awake()
{
_renderer = GetComponent<SpriteRenderer>();