WXGame/box1/Assets/Spine/Runtime/spine-unity/Shaders/CGIncludes/Spine-Skeleton-Tint-Common.cginc

28 lines
778 B
HLSL
Raw Normal View History

2024-10-23 17:55:55 +08:00
#ifndef SKELETON_TINT_COMMON_INCLUDED
#define SKELETON_TINT_COMMON_INCLUDED
2024-11-21 09:35:48 +08:00
float4 fragTintedColor(float4 texColor, float3 darkTintColor, float4 lightTintColorPMA, float lightColorAlpha, float darkColorAlpha) {
2024-10-23 17:55:55 +08:00
2024-11-21 09:35:48 +08:00
float a = texColor.a * lightTintColorPMA.a;
2024-10-23 17:55:55 +08:00
#if !defined(_STRAIGHT_ALPHA_INPUT)
2024-11-21 09:35:48 +08:00
float3 texDarkColor = texColor.a - texColor.rgb;
2024-10-23 17:55:55 +08:00
#else
float3 texDarkColor = (1 - texColor.rgb);
#endif
2024-11-21 09:35:48 +08:00
float3 darkColor = texDarkColor * darkTintColor.rgb * lightColorAlpha;
float3 lightColor = texColor.rgb * lightTintColorPMA.rgb;
2024-10-23 17:55:55 +08:00
float4 fragColor = float4(darkColor + lightColor, a);
#if defined(_STRAIGHT_ALPHA_INPUT)
2024-11-21 09:35:48 +08:00
fragColor.rgb *= texColor.a;
2024-10-23 17:55:55 +08:00
#endif
#if defined(_DARK_COLOR_ALPHA_ADDITIVE)
fragColor.a = a * (1 - darkColorAlpha);
#endif
return fragColor;
}
#endif