using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; namespace YAMO { /// /// NiloToon 캐릭터 셰이더를 사용하는 오브젝트에만 색조 보정을 적용하는 Volume 컴포넌트. /// Unity의 Lift Gamma Gain / Shadows Midtones Highlights와 동일한 파라미터 구조를 사용합니다. /// /// 적용 원리: /// NiloToon의 캐릭터 영역 스텐실(bit7 = 128)을 마스크로 사용하여 /// 캐릭터 픽셀에만 색조 보정을 적용합니다. /// 배경, 소품 등 NiloToon 캐릭터 셰이더를 사용하지 않는 오브젝트에는 영향 없음. /// /// 주의: /// 반투명(Transparent queue) 캐릭터 파츠는 스텐실 마스킹에서 제외됩니다. /// (NiloToon의 CharacterAreaStencilBufferFill pass가 Opaque queue만 처리하기 때문) /// [System.Serializable] [VolumeComponentMenu("NiloToon/Char Tone Adjust (YAMO)")] public class NiloToonCharToneAdjustVolume : VolumeComponent, IPostProcessComponent { // ───────────────────────────────────────────────────────────── // Lift Gamma Gain // 파라미터 형식: Vector4 (R, G, B, W) // 기본값 (1, 1, 1, 0) = 변화 없음 // W 채널 = 전체 채널에 균등 적용되는 글로벌 조절값 // ───────────────────────────────────────────────────────────── [Header("Lift Gamma Gain")] [Tooltip("어두운 영역(Lift) 색조 보정. 기본값 (1,1,1,0) = 변화 없음. W = 전체 밝기 오프셋.")] public Vector4Parameter lift = new Vector4Parameter(new Vector4(1f, 1f, 1f, 0f)); [Tooltip("중간 영역(Gamma) 색조 보정. 기본값 (1,1,1,0) = 변화 없음. 1보다 크면 밝아짐, 작으면 어두워짐.")] public Vector4Parameter gamma = new Vector4Parameter(new Vector4(1f, 1f, 1f, 0f)); [Tooltip("밝은 영역(Gain) 색조 보정. 기본값 (1,1,1,0) = 변화 없음. W = 전체 밝기 배율.")] public Vector4Parameter gain = new Vector4Parameter(new Vector4(1f, 1f, 1f, 0f)); // ───────────────────────────────────────────────────────────── // Shadows Midtones Highlights // ───────────────────────────────────────────────────────────── [Header("Shadows Midtones Highlights")] [Tooltip("어두운 영역(Shadows) 색조 보정. 기본값 (1,1,1,0) = 변화 없음.")] public Vector4Parameter shadows = new Vector4Parameter(new Vector4(1f, 1f, 1f, 0f)); [Tooltip("중간 영역(Midtones) 색조 보정. 기본값 (1,1,1,0) = 변화 없음.")] public Vector4Parameter midtones = new Vector4Parameter(new Vector4(1f, 1f, 1f, 0f)); [Tooltip("밝은 영역(Highlights) 색조 보정. 기본값 (1,1,1,0) = 변화 없음.")] public Vector4Parameter highlights = new Vector4Parameter(new Vector4(1f, 1f, 1f, 0f)); [Header("SMH Range")] [Tooltip("그림자 영역이 시작되는 휘도 값.")] public ClampedFloatParameter shadowsStart = new ClampedFloatParameter(0f, 0f, 1f); [Tooltip("그림자 영역이 끝나는 휘도 값.")] public ClampedFloatParameter shadowsEnd = new ClampedFloatParameter(0.3f, 0f, 1f); [Tooltip("하이라이트 영역이 시작되는 휘도 값.")] public ClampedFloatParameter highlightsStart = new ClampedFloatParameter(0.55f, 0f, 1f); [Tooltip("하이라이트 영역이 끝나는 휘도 값.")] public ClampedFloatParameter highlightsEnd = new ClampedFloatParameter(1f, 0f, 1f); // ───────────────────────────────────────────────────────────── // Color Adjustments // ───────────────────────────────────────────────────────────── [Header("Color Adjustments")] [Tooltip("채도 배율. 0 = 흑백, 1 = 원본, 2 = 과채화.")] public ClampedFloatParameter saturation = new ClampedFloatParameter(1f, 0f, 2f); [Tooltip("노출 보정 (EV 단위). 0 = 변화 없음, 양수 = 밝게, 음수 = 어둡게.")] public ClampedFloatParameter postExposure = new ClampedFloatParameter(0f, -5f, 5f); // ───────────────────────────────────────────────────────────── // Blend // ───────────────────────────────────────────────────────────── [Header("Blend")] [Tooltip("원본과 보정된 색상 사이의 블렌드 강도. 0 = 원본, 1 = 완전 적용.")] public ClampedFloatParameter blendAmount = new ClampedFloatParameter(1f, 0f, 1f); // VolumeComponent 베이스 클래스의 `bool active` 필드를 그대로 사용합니다. // (URP 17: VolumeComponent.active는 bool 타입, Inspector의 컴포넌트 ON/OFF 토글과 연동) public bool IsActive() => active; public bool IsTileCompatible() => false; } }