diff --git a/Assets/NiloToonURP/Shaders/NiloToonCharacterFur.shader b/Assets/NiloToonURP/Shaders/NiloToonCharacterFur.shader index d36cc085..c46f7c50 100644 --- a/Assets/NiloToonURP/Shaders/NiloToonCharacterFur.shader +++ b/Assets/NiloToonURP/Shaders/NiloToonCharacterFur.shader @@ -158,8 +158,8 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character_Fur" ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// [HideInInspector] _PerCharacterBaseColorMultiply("_PerCharacterBaseColorMultiply", Float) = 1 [HideInInspector] _PerCharacterBaseColorTint("_PerCharacterBaseColorTint", Color) = (1, 1, 1, 1) - [HideInInspector] _PerCharacterTintColor("_PerCharacterTintColor", Color) = (1, 1, 1, 1) - [HideInInspector] _PerCharacterAddColor("_PerCharacterAddColor", Color) = (0, 0, 0, 0) + [HideInInspector] _PerCharEffectTintColor("_PerCharEffectTintColor", Color) = (1, 1, 1, 1) + [HideInInspector] _PerCharEffectAddColor("_PerCharEffectAddColor", Color) = (0, 0, 0, 0) [HideInInspector] _PerCharEffectDesaturatePercentage("_PerCharEffectDesaturatePercentage", Range(0,1)) = 0 [HideInInspector] _PerCharEffectLerpColor("_PerCharEffectLerpColor", Color) = (1, 1, 0, 0) @@ -551,6 +551,11 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character_Fur" half alpha = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, input.uv).a * _BaseColor.a; clip(alpha - _Cutoff); + // Apply dither fadeout to shadow casting (must come before dissolve) + #if _NILOTOON_DITHER_FADEOUT + NiloDoDitherFadeoutClip(input.positionCS.xy, 1.0 - _DitherFadeoutAmount * _AllowPerCharacterDitherFadeout); + #endif + // Apply dissolve to shadow casting #if _NILOTOON_DISSOLVE half3 dummyColor = half3(1, 1, 1); @@ -624,6 +629,11 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character_Fur" half alpha = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, input.uv).a * _BaseColor.a; clip(alpha - _Cutoff); + // Apply dither fadeout to depth (must come before dissolve) + #if _NILOTOON_DITHER_FADEOUT + NiloDoDitherFadeoutClip(input.positionCS.xy, 1.0 - _DitherFadeoutAmount * _AllowPerCharacterDitherFadeout); + #endif + // Apply dissolve to depth #if _NILOTOON_DISSOLVE half3 dummyColor = half3(1, 1, 1); @@ -697,6 +707,12 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character_Fur" half alpha = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, input.uv).a * _BaseColor.a; clip(alpha - _Cutoff); + // Apply dither fadeout to depth normals (must come before dissolve) + // This is critical for HBAO/SSAO - without this, AO will render on dithered areas + #if _NILOTOON_DITHER_FADEOUT + NiloDoDitherFadeoutClip(input.positionCS.xy, 1.0 - _DitherFadeoutAmount * _AllowPerCharacterDitherFadeout); + #endif + // Apply dissolve to depth normals #if _NILOTOON_DISSOLVE half3 dummyColor = half3(1, 1, 1); @@ -777,6 +793,11 @@ Shader "Universal Render Pipeline/NiloToon/NiloToon_Character_Fur" half alpha = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, input.uv).a * _BaseColor.a; clip(alpha - _Cutoff); + // Apply dither fadeout to prepass buffer (must come before dissolve) + #if _NILOTOON_DITHER_FADEOUT + NiloDoDitherFadeoutClip(input.positionCS.xy, 1.0 - _DitherFadeoutAmount * _AllowPerCharacterDitherFadeout); + #endif + // Apply dissolve to prepass buffer #if _NILOTOON_DISSOLVE half3 dummyColor = half3(1, 1, 1); diff --git a/Assets/NiloToonURP/Shaders/NiloToonCharacterFur_HLSL/NiloToonCharacterFur_Fragment.hlsl b/Assets/NiloToonURP/Shaders/NiloToonCharacterFur_HLSL/NiloToonCharacterFur_Fragment.hlsl index 2ebfe2ee..c1b8a755 100644 --- a/Assets/NiloToonURP/Shaders/NiloToonCharacterFur_HLSL/NiloToonCharacterFur_Fragment.hlsl +++ b/Assets/NiloToonURP/Shaders/NiloToonCharacterFur_HLSL/NiloToonCharacterFur_Fragment.hlsl @@ -143,17 +143,13 @@ half3 ApplyPerCharacterColorControls(half3 color) color *= _PerCharacterBaseColorMultiply; color *= _PerCharacterBaseColorTint.rgb; - // Tint Color - color *= _PerCharacterTintColor.rgb; - - // Add Color - color += _PerCharacterAddColor.rgb; + // Per-Character Tint & Add Color (set by NiloToonPerCharacterRenderController) + // Matching NiloToonCharacter_Shared.hlsl: color.rgb = color.rgb * _PerCharEffectTintColor + _PerCharEffectAddColor; + color.rgb = color.rgb * _PerCharEffectTintColor + _PerCharEffectAddColor; // Desaturation (matching NiloToonCharacter_Shared.hlsl line 4099) color = lerp(color, Luminance(color), _PerCharEffectDesaturatePercentage); - // Mul Add (already handled above with _PerCharacterTintColor and _PerCharacterAddColor) - // Replace by Color / Lerp Color (matching NiloToonCharacter_Shared.hlsl line 4105) // Uses alpha channel of _PerCharEffectLerpColor as the lerp amount color.rgb = lerp(color.rgb, _PerCharEffectLerpColor.rgb, _PerCharEffectLerpColor.a); diff --git a/Assets/NiloToonURP/Shaders/NiloToonCharacterFur_HLSL/NiloToonCharacterFur_Shared.hlsl b/Assets/NiloToonURP/Shaders/NiloToonCharacterFur_HLSL/NiloToonCharacterFur_Shared.hlsl index 5f0fe867..4c10c322 100644 --- a/Assets/NiloToonURP/Shaders/NiloToonCharacterFur_HLSL/NiloToonCharacterFur_Shared.hlsl +++ b/Assets/NiloToonURP/Shaders/NiloToonCharacterFur_HLSL/NiloToonCharacterFur_Shared.hlsl @@ -149,8 +149,8 @@ CBUFFER_START(UnityPerMaterial) // Per-Character Color Controls half _PerCharacterBaseColorMultiply; half4 _PerCharacterBaseColorTint; - half4 _PerCharacterTintColor; - half4 _PerCharacterAddColor; + half3 _PerCharEffectTintColor; // Set by NiloToonPerCharacterRenderController + half3 _PerCharEffectAddColor; // Set by NiloToonPerCharacterRenderController half _PerCharEffectDesaturatePercentage; half4 _PerCharEffectLerpColor;