Skip to content

Commit c54473f

Browse files
committed
Implementation for non main lights.
1 parent 3305010 commit c54473f

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ float3 UTS_OtherLights(FragInputs input, float3 i_normalDir,
7272
Set_1st_ShadeColor = lerp(Set_1st_ShadeColor, overridingColor.xyz, maskEnabled);
7373
Set_1st_ShadeColor = lerp(Set_1st_ShadeColor, Set_BaseColor, 1.0f - _FirstShadeVisible);
7474
}
75+
float Set_1st_ShadeAlpha = _FirstShadeVisible;
7576
#endif //#ifdef UTS_LAYER_VISIBILITY //v.2.0.5
7677
float4 _2nd_ShadeMap_var = lerp(tex2Dlod(_2nd_ShadeMap, float4(TRANSFORM_TEX(Set_UV0, _2nd_ShadeMap),0.0f,0.0f)), _1st_ShadeMap_var, _Use_1stAs2nd);
7778
float3 Set_2nd_ShadeColor = lerp((_2nd_ShadeColor.rgb * _2nd_ShadeMap_var.rgb * _LightIntensity), ((_2nd_ShadeColor.rgb * _2nd_ShadeMap_var.rgb) * Set_LightColor), _Is_LightColor_2nd_Shade);
@@ -101,7 +102,10 @@ float3 UTS_OtherLights(FragInputs input, float3 i_normalDir,
101102
}
102103
#endif //#ifdef UTS_LAYER_VISIBILITY
103104
float3 finalColor = lerp(Set_BaseColor, lerp(Set_1st_ShadeColor, Set_2nd_ShadeColor, saturate((1.0 + ((_HalfLambert_var - (_ShadeColor_Step - _2ndColorFeatherForMask)) * ((1.0 - _Set_2nd_ShadePosition_var.rgb).r - 1.0)) / (_ShadeColor_Step - (_ShadeColor_Step - _2ndColorFeatherForMask))))), Set_FinalShadowMask); // Final Color
104-
105+
#ifdef UTS_LAYER_VISIBILITY
106+
float Set_2nd_ShadeAlpha = _SecondShadeVisible;
107+
channelOutAlpha = lerp(Set_BaseColorAlpha, lerp(Set_1st_ShadeAlpha, Set_2nd_ShadeAlpha, saturate((1.0 + ((_HalfLambert_var - (_ShadeColor_Step - _2ndColorFeatherForMask)) * ((1.0 - _Set_2nd_ShadePosition_var.rgb).r - 1.0)) / (_ShadeColor_Step - (_ShadeColor_Step - _2ndColorFeatherForMask))))), Set_FinalShadowMask);
108+
#endif
105109
//v.2.0.6: Add HighColor if _Is_Filter_HiCutPointLightColor is False
106110

107111
#ifdef _SYNTHESIZED_TEXTURE
@@ -134,6 +138,7 @@ float3 UTS_OtherLights(FragInputs input, float3 i_normalDir,
134138
if (any(addColor))
135139
{
136140
finalColor = lerp(finalColor, overridingColor.xyz, maskEnabled);
141+
channelOutAlpha = _HighlightVisible;
137142
}
138143

139144
}

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
//[email protected] (Universal RP/HDRP)
44

55
float3 UTS_OtherLightsShadingGrademap(FragInputs input, float3 i_normalDir,
6-
float3 additionalLightColor, float3 lightDirection, float notDirectional, out float channelAlpha)
6+
float3 additionalLightColor, float3 lightDirection, float notDirectional, out float channelOutAlpha)
77
{
8-
channelAlpha = 0.0f;
8+
channelOutAlpha = 1.0f;
99
#ifdef _IS_CLIPPING_MATTE
1010
if (_ClippingMatteMode != 0)
1111
{
@@ -60,7 +60,7 @@ float3 UTS_OtherLightsShadingGrademap(FragInputs input, float3 i_normalDir,
6060
//
6161
float3 Set_BaseColor = lerp((_BaseColor.rgb * _MainTex_var.rgb * _LightIntensity), ((_BaseColor.rgb * _MainTex_var.rgb) * Set_LightColor), _Is_LightColor_Base);
6262
#ifdef UTS_LAYER_VISIBILITY
63-
63+
float Set_BaseColorAlpha = _BaseColorVisible;
6464
float4 overridingColor = lerp(_BaseColorMaskColor, float4(_BaseColorMaskColor.w, _BaseColorMaskColor.w, _BaseColorMaskColor.w, 1.0f), _ComposerMaskMode);
6565
float maskEnabled = max(_BaseColorOverridden, _ComposerMaskMode);
6666
Set_BaseColor = lerp(Set_BaseColor, overridingColor, maskEnabled);
@@ -77,6 +77,7 @@ float3 UTS_OtherLightsShadingGrademap(FragInputs input, float3 i_normalDir,
7777
Set_1st_ShadeColor = lerp(Set_1st_ShadeColor, overridingColor, maskEnabled);
7878
Set_1st_ShadeColor = lerp(Set_1st_ShadeColor, Set_BaseColor, 1.0f - _FirstShadeVisible);
7979
}
80+
float Set_1st_ShadeAlpha = _FirstShadeVisible;
8081
#endif //#ifdef UTS_LAYER_VISIBILITY //v.2.0.5
8182
//v.2.0.5
8283
float4 _2nd_ShadeMap_var = lerp(tex2D(_2nd_ShadeMap, TRANSFORM_TEX(Set_UV0, _2nd_ShadeMap)), _1st_ShadeMap_var, _Use_1stAs2nd);
@@ -135,7 +136,11 @@ float3 UTS_OtherLightsShadingGrademap(FragInputs input, float3 i_normalDir,
135136
Set_ShadeShadowMask
136137
),
137138
Set_FinalShadowMask);
138-
139+
#ifdef UTS_LAYER_VISIBILITY
140+
float Set_2nd_ShadeAlpha = _SecondShadeVisible;
141+
channelOutAlpha =
142+
lerp(Set_BaseColorAlpha, lerp(Set_1st_ShadeAlpha, Set_2nd_ShadeAlpha, Set_ShadeShadowMask), Set_FinalShadowMask);
143+
#endif
139144
//v.2.0.6: Add HighColor if _Is_Filter_HiCutPointLightColor is False
140145
#ifdef _SYNTHESIZED_TEXTURE
141146
float4 _Set_HighColorMask_var = tex2D(_HighColor_TexSynthesized, TRANSFORM_TEX(Set_UV0, _HighColor_TexSynthesized)).aaaa;
@@ -167,6 +172,7 @@ float3 UTS_OtherLightsShadingGrademap(FragInputs input, float3 i_normalDir,
167172
if (any(addColor))
168173
{
169174
finalColor = lerp(finalColor, overridingColor, maskEnabled);
175+
channelOutAlpha = _HighlightVisible;
170176
}
171177
}
172178

0 commit comments

Comments
 (0)