Skip to content

Commit c359284

Browse files
committed
Apply alpha value in the shader when compositor mode is enabled.
1 parent 53065e2 commit c359284

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

com.unity.toonshader/Runtime/HDRP/Shaders/ShaderPassForwardUTS.hlsl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ PackedVaryingsToPS VertTesselation(VaryingsToDS input)
6464
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/TessellationShare.hlsl"
6565
#endif
6666

67-
67+
float ApplyChannelAlpha( float alpha)
68+
{
69+
return lerp(1.0, alpha, _ComposerMaskMode);
70+
}
6871

6972
float3 GetLightColor(LightLoopContext context, FragInputs input, PositionInputs posInput,
7073
float3 V, BuiltinData builtinData,
@@ -528,12 +531,12 @@ void Frag(PackedVaryingsToPS packedInput,
528531
//v.2.0.4
529532
#ifdef _IS_TRANSCLIPPING_OFF
530533

531-
outColor = float4(finalColor, 1 * channelAlpha);
534+
outColor = float4(finalColor, 1 * ApplyChannelAlpha(channelAlpha));
532535

533536
#elif _IS_TRANSCLIPPING_ON
534537
float Set_Opacity = saturate((inverseClipping + _Tweak_transparency));
535538

536-
outColor = float4(finalColor, Set_Opacity * channelAlpha );
539+
outColor = float4(finalColor, Set_Opacity * ApplyChannelAlpha(channelAlpha));
537540

538541
#endif
539542

@@ -542,17 +545,17 @@ void Frag(PackedVaryingsToPS packedInput,
542545
#ifdef _IS_CLIPPING_OFF
543546
//DoubleShadeWithFeather
544547

545-
outColor = float4(finalColor, 1 * channelAlpha);
548+
outColor = float4(finalColor, 1 * ApplyChannelAlpha(channelAlpha));
546549

547550
#elif _IS_CLIPPING_MODE
548551
//DoubleShadeWithFeather_Clipping
549552

550-
outColor = float4(finalColor, 1 * channelAlpha);
553+
outColor = float4(finalColor, 1 * ApplyChannelAlpha(channelAlpha));
551554

552555
#elif _IS_CLIPPING_TRANSMODE
553556
//DoubleShadeWithFeather_TransClipping
554557
float Set_Opacity = saturate((inverseClipping + _Tweak_transparency));
555-
outColor = float4(finalColor, Set_Opacity * channelAlpha);
558+
outColor = float4(finalColor, Set_Opacity * ApplyChannelAlpha(channelAlpha));
556559
#endif
557560

558561
#endif //#if defined(_SHADINGGRADEMAP)

0 commit comments

Comments
 (0)