Shader "Kawashirov/FPS" { Properties { _DigitsTex ("Digits", 2D) = "white" {} } SubShader { Tags { "RenderType" = "Opaque" } Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct v2f { float2 uv : TEXCOORD0; float4 vertex : SV_POSITION; }; sampler2D _DigitsTex; v2f vert (float4 vertex : POSITION, float2 uv : TEXCOORD0) { v2f o; o.vertex = UnityObjectToClipPos(vertex); o.uv = uv; return o; } fixed4 frag (v2f i) : SV_Target { uint fps = round(unity_DeltaTime.w); half4 tex = tex2D(_DigitsTex, half2(frac(i.uv.x * 2) / 10 + half((i.uv.x > 0.5 ? fps : (fps / 10)) % 10) / 10, i.uv.y)); half4 grad = lerp(half4(1,0,0,1), half4(0,1,0,1), unity_DeltaTime.w / 91.0h); return tex * grad; } ENDCG } } }