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