Shader “Custom/3D Text Standard” {
Properties {
_Color (“Color”, Color) = (1,1,1,1)
_MainTex (“Albedo (RGB)”, 2D) = “white” {}
_BumpMap (“Normal Map”, 2D) = “bump” {}
_FontTex (“Font Texture”, 2D) = “white” {}
_Glossiness (“Smoothness”, Range(0,1)) = 0.5
_Metallic (“Metallic”, Range(0,1)) = 0.0
_Cutoff (“Cutoff”, Range(0,1)) = 0.5
}
SubShader {
Tags { “RenderType”=“Opaque” }
LOD 200
Cull Off
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows vertex:vert
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
float4 _MainTex_ST;
sampler2D _BumpMap;
float4 _BumpMap_ST;
sampler2D _FontTex;
struct Input {
float2 uv_FontTex;
float3 localPos;
};
half _Glossiness;
half _Metallic;
half _Cutoff;
fixed4 _Color;
void vert (inout appdata_tan v, out Input o) {
UNITY_INITIALIZE_OUTPUT (Input, o);
half3 worldPos = mul (unity_ObjectToWorld, v.vertex);
half3 viewDir = worldPos - _WorldSpaceCameraPos;
half3 worldNorm = mul (unity_ObjectToWorld, float4 (v.normal, 0));
v.normal *= dot (viewDir, worldNorm) < 0 ? 1 : -1;
o.localPos = v.vertex;
}
void surf (Input IN, inout SurfaceOutputStandard o) {
//float2 uv = dot (IN.norm, float3 (0, 0, 1)) < 0 ? lerp (IN.worldPos.xy, IN.worldPos.zy, dot (IN.norm, float3 (0, 0, 1))) : lerp (IN.worldPos.zy, IN.worldPos.xy, -dot (IN.norm, float3 (0, 0, 1)));
//uv = dot (IN.worldNorm, float3 (0, 1, 0)) < 0 ? lerp (IN.worldPos.xz, uv, dot (IN.worldNorm, float3 (0, 1, 0))) : lerp (uv, IN.worldPos.xz, -dot (IN.worldNorm, float3 (0, 1, 0)));
IN.localPos /= 25;
o.Normal = UnpackNormal (tex2D (_BumpMap, TRANSFORM_TEX (IN.localPos.xy, _BumpMap)));
// Albedo comes from a texture tinted by color
fixed4 c = tex2D (_MainTex, TRANSFORM_TEX (IN.localPos.xy, _MainTex)) * _Color;
o.Albedo = c.rgb;
// Metallic and smoothness come from slider variables
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = tex2D (_FontTex, IN.uv_FontTex).a * _Color.a;
if (o.Alpha < _Cutoff)
discard;
}
ENDCG
}
FallBack "Diffuse"
}
You can use this shader instead of the replacement one. Just note that this uses pixel discarding rather than alpha blending, so the text can receive shadows, anti aliasing, depth, etc. but will have hard edges.