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.

155 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. _VertexOffsetX ("Vertex OffsetX", float) = 0
  49. _VertexOffsetY ("Vertex OffsetY", float) = 0
  50. //_MaskCoord ("Mask Coords", vector) = (0,0,0,0)
  51. //_MaskSoftness ("Mask Softness", float) = 0
  52. }
  53. SubShader {
  54. Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
  55. LOD 300
  56. Cull [_CullMode]
  57. CGPROGRAM
  58. #pragma surface PixShader BlinnPhong alpha:blend vertex:VertShader nolightmap nodirlightmap
  59. #pragma target 3.0
  60. #pragma shader_feature __ GLOW_ON
  61. #pragma glsl
  62. #include "TMPro_Properties.cginc"
  63. #include "TMPro.cginc"
  64. half _FaceShininess;
  65. half _OutlineShininess;
  66. struct Input
  67. {
  68. fixed4 color : COLOR;
  69. float2 uv_MainTex;
  70. float2 uv2_FaceTex;
  71. float2 uv2_OutlineTex;
  72. float2 param; // Weight, Scale
  73. float3 viewDirEnv;
  74. };
  75. #define BEVEL_ON 1
  76. #include "TMPro_Surface.cginc"
  77. ENDCG
  78. // Pass to render object as a shadow caster
  79. Pass
  80. {
  81. Name "Caster"
  82. Tags { "LightMode" = "ShadowCaster" }
  83. Offset 1, 1
  84. Fog {Mode Off}
  85. ZWrite On
  86. ZTest LEqual
  87. Cull Off
  88. CGPROGRAM
  89. #pragma vertex vert
  90. #pragma fragment frag
  91. #pragma multi_compile_shadowcaster
  92. #include "UnityCG.cginc"
  93. struct v2f {
  94. V2F_SHADOW_CASTER;
  95. float2 uv : TEXCOORD1;
  96. float2 uv2 : TEXCOORD3;
  97. float alphaClip : TEXCOORD2;
  98. };
  99. uniform float4 _MainTex_ST;
  100. uniform float4 _OutlineTex_ST;
  101. float _OutlineWidth;
  102. float _FaceDilate;
  103. float _ScaleRatioA;
  104. v2f vert( appdata_base v )
  105. {
  106. v2f o;
  107. TRANSFER_SHADOW_CASTER(o)
  108. o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
  109. o.uv2 = TRANSFORM_TEX(v.texcoord, _OutlineTex);
  110. o.alphaClip = (1.0 - _OutlineWidth * _ScaleRatioA - _FaceDilate * _ScaleRatioA) / 2;
  111. return o;
  112. }
  113. uniform sampler2D _MainTex;
  114. float4 frag(v2f i) : COLOR
  115. {
  116. fixed4 texcol = tex2D(_MainTex, i.uv).a;
  117. clip(texcol.a - i.alphaClip);
  118. SHADOW_CASTER_FRAGMENT(i)
  119. }
  120. ENDCG
  121. }
  122. }
  123. CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI"
  124. }