SpritesPixelLit.shader 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. Shader "Spine/Sprite/Pixel Lit"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Main Texture", 2D) = "white" {}
  6. _Color ("Color", Color) = (1,1,1,1)
  7. _BumpScale("Scale", Float) = 1.0
  8. _BumpMap ("Normal Map", 2D) = "bump" {}
  9. [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
  10. _EmissionColor("Color", Color) = (0,0,0,0)
  11. _EmissionMap("Emission", 2D) = "white" {}
  12. _EmissionPower("Emission Power", Float) = 2.0
  13. _Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5
  14. _GlossMapScale("Smoothness Scale", Range(0.0, 1.0)) = 1.0
  15. [Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
  16. _MetallicGlossMap("Metallic", 2D) = "white" {}
  17. _DiffuseRamp ("Diffuse Ramp Texture", 2D) = "gray" {}
  18. _FixedNormal ("Fixed Normal", Vector) = (0,0,1,1)
  19. _Cutoff ("Depth alpha cutoff", Range(0,1)) = 0.5
  20. _ShadowAlphaCutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
  21. _CustomRenderQueue ("Custom Render Queue", Float) = 0.0
  22. _OverlayColor ("Overlay Color", Color) = (0,0,0,0)
  23. _Hue("Hue", Range(-0.5,0.5)) = 0.0
  24. _Saturation("Saturation", Range(0,2)) = 1.0
  25. _Brightness("Brightness", Range(0,2)) = 1.0
  26. _RimPower("Rim Power", Float) = 2.0
  27. _RimColor ("Rim Color", Color) = (1,1,1,1)
  28. _BlendTex ("Blend Texture", 2D) = "white" {}
  29. _BlendAmount ("Blend", Range(0,1)) = 0.0
  30. [HideInInspector] _SrcBlend ("__src", Float) = 1.0
  31. [HideInInspector] _DstBlend ("__dst", Float) = 0.0
  32. [HideInInspector] _RenderQueue ("__queue", Float) = 0.0
  33. [HideInInspector] _Cull ("__cull", Float) = 0.0
  34. [HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
  35. [HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
  36. // Outline properties are drawn via custom editor.
  37. [HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
  38. [HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
  39. [HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
  40. [HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
  41. [HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
  42. [HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
  43. [HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
  44. }
  45. SubShader
  46. {
  47. Tags { "Queue"="Transparent" "RenderType"="Sprite" "AlphaDepth"="False" "CanUseSpriteAtlas"="True" "IgnoreProjector"="True" }
  48. LOD 200
  49. Stencil {
  50. Ref[_StencilRef]
  51. Comp[_StencilComp]
  52. Pass Keep
  53. }
  54. Pass
  55. {
  56. Name "FORWARD"
  57. Tags { "LightMode" = "ForwardBase" }
  58. Blend [_SrcBlend] [_DstBlend]
  59. // Note: ZWrite needs to be enabled for following ForwardAdd pass, otherwise parts will look as if shining through by getting lit.
  60. ZWrite On
  61. ZTest LEqual
  62. Cull [_Cull]
  63. CGPROGRAM
  64. #pragma target 3.0
  65. #pragma shader_feature _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _MULTIPLYBLEND _MULTIPLYBLEND_X2
  66. #pragma shader_feature _ _FIXED_NORMALS_VIEWSPACE _FIXED_NORMALS_VIEWSPACE_BACKFACE _FIXED_NORMALS_MODELSPACE _FIXED_NORMALS_MODELSPACE_BACKFACE _FIXED_NORMALS_WORLDSPACE
  67. #pragma shader_feature _ _SPECULAR _SPECULAR_GLOSSMAP
  68. #pragma shader_feature _NORMALMAP
  69. #pragma shader_feature _ALPHA_CLIP
  70. #pragma shader_feature _EMISSION
  71. #pragma shader_feature _RIM_LIGHTING
  72. #pragma shader_feature _DIFFUSE_RAMP
  73. #pragma shader_feature _ _FULLRANGE_HARD_RAMP _FULLRANGE_SOFT_RAMP _OLD_HARD_RAMP _OLD_SOFT_RAMP
  74. #pragma shader_feature _COLOR_ADJUST
  75. #pragma shader_feature _TEXTURE_BLEND
  76. #pragma shader_feature _SPHERICAL_HARMONICS
  77. #pragma shader_feature _FOG
  78. #pragma multi_compile_fwdbase
  79. #pragma fragmentoption ARB_precision_hint_fastest
  80. #pragma multi_compile_fog
  81. #pragma multi_compile _ PIXELSNAP_ON
  82. #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
  83. #pragma vertex vert
  84. #pragma fragment fragBase
  85. #include "CGIncludes/SpritePixelLighting.cginc"
  86. ENDCG
  87. }
  88. Pass
  89. {
  90. Name "FORWARD_DELTA"
  91. Tags { "LightMode" = "ForwardAdd" }
  92. Blend [_SrcBlend] One
  93. ZWrite Off
  94. ZTest LEqual
  95. Cull [_Cull]
  96. CGPROGRAM
  97. #pragma target 3.0
  98. #pragma shader_feature _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _MULTIPLYBLEND _MULTIPLYBLEND_X2
  99. #pragma shader_feature _ _FIXED_NORMALS_VIEWSPACE _FIXED_NORMALS_VIEWSPACE_BACKFACE _FIXED_NORMALS_MODELSPACE _FIXED_NORMALS_MODELSPACE_BACKFACE _FIXED_NORMALS_WORLDSPACE
  100. #pragma shader_feature _ _SPECULAR _SPECULAR_GLOSSMAP
  101. #pragma shader_feature _NORMALMAP
  102. #pragma shader_feature _ALPHA_CLIP
  103. #pragma shader_feature _DIFFUSE_RAMP
  104. #pragma shader_feature _ _FULLRANGE_HARD_RAMP _FULLRANGE_SOFT_RAMP _OLD_HARD_RAMP _OLD_SOFT_RAMP
  105. #pragma shader_feature _COLOR_ADJUST
  106. #pragma shader_feature _TEXTURE_BLEND
  107. #pragma shader_feature _FOG
  108. #pragma multi_compile_fwdadd_fullshadows
  109. #pragma fragmentoption ARB_precision_hint_fastest
  110. #pragma multi_compile_fog
  111. #pragma multi_compile _ PIXELSNAP_ON
  112. #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
  113. #pragma vertex vert
  114. #pragma fragment fragAdd
  115. #include "CGIncludes/SpritePixelLighting.cginc"
  116. ENDCG
  117. }
  118. Pass
  119. {
  120. Name "ShadowCaster"
  121. Tags { "LightMode"="ShadowCaster" }
  122. Offset 1, 1
  123. Fog { Mode Off }
  124. ZWrite On
  125. ZTest LEqual
  126. Cull Off
  127. Lighting Off
  128. CGPROGRAM
  129. #pragma fragmentoption ARB_precision_hint_fastest
  130. #pragma multi_compile_shadowcaster
  131. #pragma multi_compile _ PIXELSNAP_ON
  132. #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
  133. #pragma vertex vert
  134. #pragma fragment frag
  135. #include "CGIncludes/SpriteShadows.cginc"
  136. ENDCG
  137. }
  138. }
  139. FallBack "Spine/Sprite/Unlit"
  140. CustomEditor "SpineSpriteShaderGUI"
  141. }