Mask.shader 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**
  2. * Copyright(c) Live2D Inc. All rights reserved.
  3. *
  4. * Use of this source code is governed by the Live2D Open Software license
  5. * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
  6. */
  7. Shader "Live2D Cubism/Mask"
  8. {
  9. Properties
  10. {
  11. // Culling setting.
  12. _Cull("Culling", Int) = 0
  13. }
  14. SubShader
  15. {
  16. Tags
  17. {
  18. "Queue" = "Transparent"
  19. "IgnoreProjector" = "True"
  20. "RenderType" = "Transparent"
  21. }
  22. BindChannels{ Bind "Vertex", vertex Bind "texcoord", texcoord Bind "Color", color }
  23. LOD 100
  24. ZWrite Off
  25. Lighting Off
  26. Cull [_Cull]
  27. Blend One One
  28. Pass
  29. {
  30. CGPROGRAM
  31. #pragma vertex vert
  32. #pragma fragment frag
  33. #define CUBISM_MASK_ON
  34. #include "UnityCG.cginc"
  35. #include "CubismCG.cginc"
  36. struct appdata_t
  37. {
  38. float4 vertex : POSITION;
  39. fixed4 color : COLOR;
  40. float2 texcoord : TEXCOORD0;
  41. };
  42. struct v2f
  43. {
  44. float4 vertex : SV_POSITION;
  45. fixed4 color : COLOR;
  46. float2 texcoord : TEXCOORD0;
  47. };
  48. CUBISM_SHADER_VARIABLES
  49. v2f vert(appdata_t IN)
  50. {
  51. v2f OUT;
  52. CUBISM_TO_MASK_CLIP_POS(IN, OUT);
  53. OUT.color = IN.color;
  54. OUT.texcoord = IN.texcoord;
  55. return OUT;
  56. }
  57. sampler2D _MainTex;
  58. fixed4 frag(v2f IN) : SV_Target
  59. {
  60. return CUBISM_MASK_CHANNEL * tex2D(_MainTex, IN.texcoord).a;
  61. }
  62. ENDCG
  63. }
  64. }
  65. }