Spine-Skeleton-Tint-Common.cginc 780 B

123456789101112131415161718192021222324252627
  1. #ifndef SKELETON_TINT_COMMON_INCLUDED
  2. #define SKELETON_TINT_COMMON_INCLUDED
  3. float4 fragTintedColor(float4 texColor, float3 darkTintColor, float4 lightTintColorPMA, float lightColorAlpha, float darkColorAlpha) {
  4. float a = texColor.a * lightTintColorPMA.a;
  5. #if !defined(_STRAIGHT_ALPHA_INPUT)
  6. float3 texDarkColor = (texColor.a - texColor.rgb);
  7. #else
  8. float3 texDarkColor = (1 - texColor.rgb);
  9. #endif
  10. float3 darkColor = texDarkColor * darkTintColor.rgb * lightColorAlpha;
  11. float3 lightColor = texColor.rgb * lightTintColorPMA.rgb;
  12. float4 fragColor = float4(darkColor + lightColor, a);
  13. #if defined(_STRAIGHT_ALPHA_INPUT)
  14. fragColor.rgb *= texColor.a;
  15. #endif
  16. #if defined(_DARK_COLOR_ALPHA_ADDITIVE)
  17. fragColor.a = a * (1 - darkColorAlpha);
  18. #endif
  19. return fragColor;
  20. }
  21. #endif