Unlit.shader 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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/Unlit"
  8. {
  9. Properties
  10. {
  11. // Texture and model opacity settings.
  12. [PerRendererData] _MainTex("Main Texture", 2D) = "white" {}
  13. [PerRendererData] cubism_ModelOpacity("Model Opacity", Float) = 1
  14. // Blend settings.
  15. _SrcColor("Source Color", Int) = 0
  16. _DstColor("Destination Color", Int) = 0
  17. _SrcAlpha("Source Alpha", Int) = 0
  18. _DstAlpha("Destination Alpha", Int) = 0
  19. // Culling setting.
  20. _Cull("Culling", Int) = 0
  21. // Mask settings.
  22. [Toggle(CUBISM_MASK_ON)] cubism_MaskOn("Mask?", Int) = 0
  23. [Toggle(CUBISM_INVERT_ON)] cubism_InvertOn("Inverted?", Int) = 0
  24. [PerRendererData] cubism_MaskTexture("cubism_Internal", 2D) = "white" {}
  25. [PerRendererData] cubism_MaskTile("cubism_Internal", Vector) = (0, 0, 0, 0)
  26. [PerRendererData] cubism_MaskTransform("cubism_Internal", Vector) = (0, 0, 0, 0)
  27. }
  28. SubShader
  29. {
  30. Tags
  31. {
  32. "Queue" = "Transparent"
  33. "IgnoreProjector" = "True"
  34. "RenderType" = "Transparent"
  35. "PreviewType" = "Plane"
  36. "CanUseSpriteAtlas" = "True"
  37. }
  38. Cull [_Cull]
  39. Lighting Off
  40. ZWrite Off
  41. Blend [_SrcColor][_DstColor], [_SrcAlpha][_DstAlpha]
  42. Pass
  43. {
  44. CGPROGRAM
  45. #pragma vertex vert
  46. #pragma fragment frag
  47. #pragma multi_compile CUBISM_MASK_ON CUBISM_MASK_OFF CUBISM_INVERT_ON
  48. #include "UnityCG.cginc"
  49. #include "CubismCG.cginc"
  50. struct appdata
  51. {
  52. float4 vertex : POSITION;
  53. float4 color : COLOR;
  54. float2 texcoord : TEXCOORD0;
  55. UNITY_VERTEX_INPUT_INSTANCE_ID
  56. };
  57. struct v2f
  58. {
  59. float4 vertex : SV_POSITION;
  60. fixed4 color : COLOR;
  61. float2 texcoord : TEXCOORD0;
  62. UNITY_VERTEX_OUTPUT_STEREO
  63. // Add Cubism specific vertex output data.
  64. CUBISM_VERTEX_OUTPUT
  65. };
  66. sampler2D _MainTex;
  67. // Include Cubism specific shader variables.
  68. CUBISM_SHADER_VARIABLES
  69. v2f vert (appdata IN)
  70. {
  71. v2f OUT;
  72. UNITY_SETUP_INSTANCE_ID(IN);
  73. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
  74. OUT.vertex = UnityObjectToClipPos(IN.vertex);
  75. OUT.texcoord = IN.texcoord;
  76. OUT.color = IN.color;
  77. // Initialize Cubism specific vertex output data.
  78. CUBISM_INITIALIZE_VERTEX_OUTPUT(IN, OUT);
  79. return OUT;
  80. }
  81. fixed4 frag (v2f IN) : SV_Target
  82. {
  83. fixed4 OUT = tex2D(_MainTex, IN.texcoord) * IN.color;
  84. // Apply Cubism alpha to color.
  85. CUBISM_APPLY_ALPHA(IN, OUT);
  86. return OUT;
  87. }
  88. ENDCG
  89. }
  90. }
  91. }