From 650aa14f89e4f58ef9f2d08c2f400166c87fcc1a Mon Sep 17 00:00:00 2001 From: Vladislav Kantaev Date: Wed, 25 May 2022 19:34:29 +0300 Subject: [PATCH] Fix specular visible in shadow [bce08a42e253b578cfd6f402570719600e57ecb4 backport] --- .../DELTation/ToonShader/Shaders/ToonShaderForwardPass.hlsl | 1 + .../Assets/DELTation/ToonShader/Shaders/ToonShaderUtils.hlsl | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Packages/com.deltation.toon-shader/Assets/DELTation/ToonShader/Shaders/ToonShaderForwardPass.hlsl b/Packages/com.deltation.toon-shader/Assets/DELTation/ToonShader/Shaders/ToonShaderForwardPass.hlsl index ad23a88..23d335c 100644 --- a/Packages/com.deltation.toon-shader/Assets/DELTation/ToonShader/Shaders/ToonShaderForwardPass.hlsl +++ b/Packages/com.deltation.toon-shader/Assets/DELTation/ToonShader/Shaders/ToonShaderForwardPass.hlsl @@ -180,6 +180,7 @@ half4 frag(const v2f input) : SV_Target half3 specular_color = 0; #ifdef _SPECULAR specular_color = get_specular_color(main_light.color, view_direction_ws, normal_ws, tangent_ws, light_direction_ws); + specular_color *= main_light_attenuation; #endif #if defined(TOON_ADDITIONAL_LIGHTS) diff --git a/Packages/com.deltation.toon-shader/Assets/DELTation/ToonShader/Shaders/ToonShaderUtils.hlsl b/Packages/com.deltation.toon-shader/Assets/DELTation/ToonShader/Shaders/ToonShaderUtils.hlsl index 2f7cb70..261ac2d 100644 --- a/Packages/com.deltation.toon-shader/Assets/DELTation/ToonShader/Shaders/ToonShaderUtils.hlsl +++ b/Packages/com.deltation.toon-shader/Assets/DELTation/ToonShader/Shaders/ToonShaderUtils.hlsl @@ -211,12 +211,11 @@ inline void additional_lights(const half4 position_cs, const float3 position_ws, #else ramp_color *= brightness; #endif - const half attenuation_step = step(0.001, attenuation); - diffuse_color += ramp_color * attenuation_step; + diffuse_color += ramp_color; #ifdef TOON_ADDITIONAL_LIGHTS_SPECULAR specular_color += get_specular_color(light.color, view_direction_ws, normal_ws, tangent_ws, light.direction) * - attenuation_step; + attenuation; #endif } }