// ───────────────────────────────────────────────────────────────────────────── // WLArcTint.cs — 근접 공용 호(Effect_WLSwingArc) 입자 색을 직업 색으로 (#963 · 2026-10-21) // // PD 원문(#963-①): 「비수공격 1타와 2타 크기를 3타와 4격 공격 수준으로 더 줄이고 푸른 컬러를 녹색 계열로 변경해줘.」 // ■ 실측 — 1·2타 호 = 모든 근접 직업이 같이 쓰는 Effect_WLSwingArc(Simple Stylized Slash vol2 M_slashB_Add/Alp · 재질 색 속성 = 가장자리색뿐) → // 색은 입자 시작색이라 직업 궤적 색(SlashTrailSettings 직업 덮기 colorAdditive)이 닿지 않았다(Play 캡처 · 렌더러 목록). // ■ 처리 — WeaponTrailDriver 호 배치 직후 훅 1줄: 그 직업 덮기의 overrideLook 이 켜져 있으면 호 입자(살아 있는 것 + 다음 분출)의 색을 // colorAdditive 색조(명도 · 알파는 원래 값)로 · 아니면 이 인스턴스의 원래 시작색으로 되돌린다(풀 공유). // ■ 2차(#963 남은 일) — 시작색만 바꾸니 화면은 녹청: 재질 _UseCustomdata_Color 1 이면 셰이더(SH_Master_improved Branch)가 정점색 대신 // 사용자 데이터 2(Custom Data Color · 청록 HDR 그라디언트)를 색으로 쓴다 → 그 그라디언트도 같은 색조로 · 되돌릴 때 원래 값(깊은 복사). // 🔴 Debug.LogError 금지. // ───────────────────────────────────────────────────────────────────────────── using UnityEngine; namespace WL.Combat { public static class WLArcTint { public static int Tinted, Restored; static ParticleSystem.Particle[] s_buf = new ParticleSystem.Particle[256]; static readonly ParticleSystemCustomData[] s_streams = { ParticleSystemCustomData.Custom1, ParticleSystemCustomData.Custom2 }; sealed class Orig : MonoBehaviour { public ParticleSystem[] ps; public ParticleSystem.MinMaxGradient[] col; public bool tinted; public ParticleSystem.MinMaxGradient[,] cd; public bool[,] hasCd; // [입자계, 사용자 데이터 1·2] Color 모드 원래 값 } public static void Apply(GameObject arc, SlashTrailClassOverride cov) { if (arc == null) return; try { var o = arc.GetComponent(); if (o == null) { o = arc.AddComponent(); o.ps = arc.GetComponentsInChildren(true); o.col = new ParticleSystem.MinMaxGradient[o.ps.Length]; o.cd = new ParticleSystem.MinMaxGradient[o.ps.Length, 2]; o.hasCd = new bool[o.ps.Length, 2]; for (int i = 0; i < o.ps.Length; i++) // 원래 값은 깊은 복사 — GetColor 그라디언트는 모듈 값을 그대로 가리켜 색조를 입히면 같이 바뀐다(묵광 복원 실패 실측) { o.col[i] = Copy(o.ps[i].main.startColor); var cdm = o.ps[i].customData; if (!cdm.enabled) continue; for (int k = 0; k < 2; k++) if (cdm.GetMode(s_streams[k]) == ParticleSystemCustomDataMode.Color) { o.hasCd[i, k] = true; o.cd[i, k] = Copy(cdm.GetColor(s_streams[k])); } } } bool want = cov != null && cov.overrideLook; if (!want && !o.tinted) return; float th = 0f, ts = 0f, tv; if (want) Color.RGBToHSV(cov.colorAdditive, out th, out ts, out tv); for (int i = 0; i < o.ps.Length; i++) { var ps = o.ps[i]; if (ps == null) continue; var m = ps.main; var cdm = ps.customData; // 사용자 데이터 색은 나이에 따라 매 프레임 계산 → 살아 있는 입자에도 바로 닿는다 for (int k = 0; k < 2; k++) if (o.hasCd[i, k]) cdm.SetColor(s_streams[k], want ? Retint(o.cd[i, k], th, ts) : o.cd[i, k]); if (!want) { m.startColor = o.col[i]; continue; } m.startColor = Retint(o.col[i], th, ts); int n = ps.GetParticles(s_buf); // 이미 나온 입자(호는 생성 순간 한 번에 분출) for (int k = 0; k < n; k++) { var c = (Color)s_buf[k].startColor; s_buf[k].startColor = Hue(c, th, ts); } if (n > 0) ps.SetParticles(s_buf, n); } o.tinted = want; if (want) Tinted++; else Restored++; } catch (System.Exception) { } } static Color Hue(Color c, float th, float ts) { float h, s, v; Color.RGBToHSV(c, out h, out s, out v); var r = Color.HSVToRGB(th, Mathf.Max(s, ts * 0.6f), v); r.a = c.a; return r; } static Gradient Hue(Gradient g, float th, float ts) { if (g == null) return null; var ng = new Gradient(); var ks = g.colorKeys; for (int k = 0; k < ks.Length; k++) ks[k].color = Hue(ks[k].color, th, ts); ng.SetKeys(ks, g.alphaKeys); ng.mode = g.mode; ng.colorSpace = g.colorSpace; return ng; } static Gradient Clone(Gradient g) { if (g == null) return null; var ng = new Gradient(); ng.SetKeys(g.colorKeys, g.alphaKeys); ng.mode = g.mode; ng.colorSpace = g.colorSpace; return ng; } static ParticleSystem.MinMaxGradient Copy(ParticleSystem.MinMaxGradient g) { switch (g.mode) { case ParticleSystemGradientMode.TwoGradients: return new ParticleSystem.MinMaxGradient(Clone(g.gradientMin), Clone(g.gradientMax)); case ParticleSystemGradientMode.Gradient: case ParticleSystemGradientMode.RandomColor: var r = new ParticleSystem.MinMaxGradient(Clone(g.gradient)); r.mode = g.mode; return r; default: return g; // 단색 · 두 색 = 값 } } static ParticleSystem.MinMaxGradient Retint(ParticleSystem.MinMaxGradient g, float th, float ts) { switch (g.mode) { case ParticleSystemGradientMode.Color: return new ParticleSystem.MinMaxGradient(Hue(g.color, th, ts)); case ParticleSystemGradientMode.TwoColors: return new ParticleSystem.MinMaxGradient(Hue(g.colorMin, th, ts), Hue(g.colorMax, th, ts)); case ParticleSystemGradientMode.TwoGradients: if (g.gradientMin == null || g.gradientMax == null) return g; return new ParticleSystem.MinMaxGradient(Hue(g.gradientMin, th, ts), Hue(g.gradientMax, th, ts)); default: // Gradient · RandomColor(모드 유지) if (g.gradient == null) return g; var r = new ParticleSystem.MinMaxGradient(Hue(g.gradient, th, ts)); r.mode = g.mode; return r; } } } }