You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
4.2 KiB

  1. Shader "TextMeshPro/Distance Field (Surface)" {
  2. Properties {
  3. _FaceTex ("Fill Texture", 2D) = "white" {}
  4. _FaceUVSpeedX ("Face UV Speed X", Range(-5, 5)) = 0.0
  5. _FaceUVSpeedY ("Face UV Speed Y", Range(-5, 5)) = 0.0
  6. _FaceColor ("Fill Color", Color) = (1,1,1,1)
  7. _FaceDilate ("Face Dilate", Range(-1,1)) = 0
  8. _OutlineColor ("Outline Color", Color) = (0,0,0,1)
  9. _OutlineTex ("Outline Texture", 2D) = "white" {}
  10. _OutlineUVSpeedX ("Outline UV Speed X", Range(-5, 5)) = 0.0
  11. _OutlineUVSpeedY ("Outline UV Speed Y", Range(-5, 5)) = 0.0
  12. _OutlineWidth ("Outline Thickness", Range(0, 1)) = 0
  13. _OutlineSoftness ("Outline Softness", Range(0,1)) = 0
  14. _Bevel ("Bevel", Range(0,1)) = 0.5
  15. _BevelOffset ("Bevel Offset", Range(-0.5,0.5)) = 0
  16. _BevelWidth ("Bevel Width", Range(-.5,0.5)) = 0
  17. _BevelClamp ("Bevel Clamp", Range(0,1)) = 0
  18. _BevelRoundness ("Bevel Roundness", Range(0,1)) = 0
  19. _BumpMap ("Normalmap", 2D) = "bump" {}
  20. _BumpOutline ("Bump Outline", Range(0,1)) = 0.5
  21. _BumpFace ("Bump Face", Range(0,1)) = 0.5
  22. _ReflectFaceColor ("Face Color", Color) = (0,0,0,1)
  23. _ReflectOutlineColor ("Outline Color", Color) = (0,0,0,1)
  24. _Cube ("Reflection Cubemap", Cube) = "black" { /* TexGen CubeReflect */ }
  25. _EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0)
  26. _SpecColor ("Specular Color", Color) = (0,0,0,1)
  27. _FaceShininess ("Face Shininess", Range(0,1)) = 0
  28. _OutlineShininess ("Outline Shininess", Range(0,1)) = 0
  29. _GlowColor ("Color", Color) = (0, 1, 0, 0.5)
  30. _GlowOffset ("Offset", Range(-1,1)) = 0
  31. _GlowInner ("Inner", Range(0,1)) = 0.05
  32. _GlowOuter ("Outer", Range(0,1)) = 0.05
  33. _GlowPower ("Falloff", Range(1, 0)) = 0.75
  34. _WeightNormal ("Weight Normal", float) = 0
  35. _WeightBold ("Weight Bold", float) = 0.5
  36. // Should not be directly exposed to the user
  37. _ShaderFlags ("Flags", float) = 0
  38. _ScaleRatioA ("Scale RatioA", float) = 1
  39. _ScaleRatioB ("Scale RatioB", float) = 1
  40. _ScaleRatioC ("Scale RatioC", float) = 1
  41. _MainTex ("Font Atlas", 2D) = "white" {}
  42. _TextureWidth ("Texture Width", float) = 512
  43. _TextureHeight ("Texture Height", float) = 512
  44. _GradientScale ("Gradient Scale", float) = 5.0
  45. _ScaleX ("Scale X", float) = 1.0
  46. _ScaleY ("Scale Y", float) = 1.0
  47. _PerspectiveFilter ("Perspective Correction", Range(0, 1)) = 0.875
  48. _Sharpness ("Sharpness", Range(-1,1)) = 0
  49. _VertexOffsetX ("Vertex OffsetX", float) = 0
  50. _VertexOffsetY ("Vertex OffsetY", float) = 0
  51. //_MaskCoord ("Mask Coords", vector) = (0,0,0,0)
  52. //_MaskSoftness ("Mask Softness", float) = 0
  53. }
  54. SubShader {
  55. Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
  56. LOD 300
  57. Cull [_CullMode]
  58. CGPROGRAM
  59. #pragma surface PixShader BlinnPhong alpha:blend vertex:VertShader nolightmap nodirlightmap
  60. #pragma target 3.0
  61. #pragma shader_feature __ GLOW_ON
  62. #pragma glsl
  63. #include "TMPro_Properties.cginc"
  64. #include "TMPro.cginc"
  65. half _FaceShininess;
  66. half _OutlineShininess;
  67. struct Input
  68. {
  69. fixed4 color : COLOR;
  70. float2 uv_MainTex;
  71. float2 uv2_FaceTex;
  72. float2 uv2_OutlineTex;
  73. float2 param; // Weight, Scale
  74. float3 viewDirEnv;
  75. };
  76. #define BEVEL_ON 1
  77. #include "TMPro_Surface.cginc"
  78. ENDCG
  79. // Pass to render object as a shadow caster
  80. Pass
  81. {
  82. Name "Caster"
  83. Tags { "LightMode" = "ShadowCaster" }
  84. Offset 1, 1
  85. Fog {Mode Off}
  86. ZWrite On
  87. ZTest LEqual
  88. Cull Off
  89. CGPROGRAM
  90. #pragma vertex vert
  91. #pragma fragment frag
  92. #pragma multi_compile_shadowcaster
  93. #include "UnityCG.cginc"
  94. struct v2f {
  95. V2F_SHADOW_CASTER;
  96. float2 uv : TEXCOORD1;
  97. float2 uv2 : TEXCOORD3;
  98. float alphaClip : TEXCOORD2;
  99. };
  100. uniform float4 _MainTex_ST;
  101. uniform float4 _OutlineTex_ST;
  102. float _OutlineWidth;
  103. float _FaceDilate;
  104. float _ScaleRatioA;
  105. v2f vert( appdata_base v )
  106. {
  107. v2f o;
  108. TRANSFER_SHADOW_CASTER(o)
  109. o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
  110. o.uv2 = TRANSFORM_TEX(v.texcoord, _OutlineTex);
  111. o.alphaClip = (1.0 - _OutlineWidth * _ScaleRatioA - _FaceDilate * _ScaleRatioA) / 2;
  112. return o;
  113. }
  114. uniform sampler2D _MainTex;
  115. float4 frag(v2f i) : COLOR
  116. {
  117. fixed4 texcol = tex2D(_MainTex, i.uv).a;
  118. clip(texcol.a - i.alphaClip);
  119. SHADOW_CASTER_FRAGMENT(i)
  120. }
  121. ENDCG
  122. }
  123. }
  124. CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI"
  125. }