Skip to content

Instantly share code, notes, and snippets.

@superokp
Created December 4, 2020 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save superokp/2f89a4eeffde398c6fd1b6a9e913e5ba to your computer and use it in GitHub Desktop.
Save superokp/2f89a4eeffde398c6fd1b6a9e913e5ba to your computer and use it in GitHub Desktop.
a counting clock shader for unity created by shaderforge
Shader "Shader Forge/Counter" {
Properties {
_Source ("Source", 2D) = "white" {}
}
SubShader {
Tags {
"RenderType"="Opaque"
}
Pass {
Name "FORWARD"
Tags {
"LightMode"="ForwardBase"
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_FORWARDBASE
#include "UnityCG.cginc"
#pragma multi_compile_fwdbase_fullshadows
#pragma only_renderers d3d9 d3d11 glcore gles
#pragma target 3.0
uniform sampler2D _Source; uniform float4 _Source_ST;
struct VertexInput {
float4 vertex : POSITION;
float2 texcoord0 : TEXCOORD0;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
};
VertexOutput vert (VertexInput v) {
VertexOutput o = (VertexOutput)0;
o.uv0 = v.texcoord0;
o.pos = UnityObjectToClipPos( v.vertex );
return o;
}
float4 frag(VertexOutput i) : COLOR {
////// Lighting:
////// Emissive:
float node_4504 = 4.0;
float4 node_794 = _Time;
float node_9382 = (node_794.g*60.0);
float node_5525 = 10.0;
float node_3485 = floor((frac((node_9382/node_5525))*node_5525));
float2 node_973_tc_rcp = float2(1.0,1.0)/float2( node_4504, node_4504 );
float node_973_ty = floor(node_3485 * node_973_tc_rcp.x);
float node_973_tx = node_3485 - node_4504 * node_973_ty;
float2 node_973 = (((i.uv0*5.0)+float2(0,-2)) + float2(node_973_tx, node_973_ty)) * node_973_tc_rcp;
float4 node_9110 = tex2D(_Source,TRANSFORM_TEX(node_973, _Source));
float3 digit1 = node_9110.rgb;
float Mask5 = ((1.0 - (step(i.uv0.g,0.4)+step(0.6,i.uv0.g)))*(1.0 - (step(1.0,i.uv0.r)+step(i.uv0.r,0.8))));
float node_3281 = 4.0;
float node_6807 = 60.0;
float node_7996 = floor((floor((frac((node_9382/node_6807))*node_6807))/10.0));
float2 node_361_tc_rcp = float2(1.0,1.0)/float2( node_3281, node_3281 );
float node_361_ty = floor(node_7996 * node_361_tc_rcp.x);
float node_361_tx = node_7996 - node_3281 * node_361_ty;
float2 node_361 = (((i.uv0*5.0)+float2(1,-2)) + float2(node_361_tx, node_361_ty)) * node_361_tc_rcp;
float4 node_5909 = tex2D(_Source,TRANSFORM_TEX(node_361, _Source));
float3 digit2 = node_5909.rgb;
float Mask4 = ((1.0 - (step(i.uv0.g,0.4)+step(0.6,i.uv0.g)))*(1.0 - (step(0.8,i.uv0.r)+step(i.uv0.r,0.6))));
float node_1028 = 4.0;
float node_5146 = 1440.0;
float node_9866 = 10.0;
float node_4255 = (frac((floor((floor((frac((node_9382/node_5146))*node_5146))/60.0))/node_9866))*node_9866);
float2 node_5733_tc_rcp = float2(1.0,1.0)/float2( node_1028, node_1028 );
float node_5733_ty = floor(node_4255 * node_5733_tc_rcp.x);
float node_5733_tx = node_4255 - node_1028 * node_5733_ty;
float2 node_5733 = (((i.uv0*5.0)+float2(3,-2)) + float2(node_5733_tx, node_5733_ty)) * node_5733_tc_rcp;
float4 node_5007 = tex2D(_Source,TRANSFORM_TEX(node_5733, _Source));
float3 digit3 = node_5007.rgb;
float Mask2 = ((1.0 - (step(i.uv0.g,0.4)+step(0.6,i.uv0.g)))*(1.0 - (step(0.4,i.uv0.r)+step(i.uv0.r,0.2))));
float node_3017 = 4.0;
float node_115 = 1440.0;
float node_764 = floor((floor((floor((frac((node_9382/node_115))*node_115))/60.0))/10.0));
float2 node_8195_tc_rcp = float2(1.0,1.0)/float2( node_3017, node_3017 );
float node_8195_ty = floor(node_764 * node_8195_tc_rcp.x);
float node_8195_tx = node_764 - node_3017 * node_8195_ty;
float2 node_8195 = (((i.uv0*5.0)+float2(4,-2)) + float2(node_8195_tx, node_8195_ty)) * node_8195_tc_rcp;
float4 node_5231 = tex2D(_Source,TRANSFORM_TEX(node_8195, _Source));
float3 digit4 = node_5231.rgb;
float Mask1 = ((1.0 - (step(i.uv0.g,0.4)+step(0.6,i.uv0.g)))*(1.0 - (step(0.2,i.uv0.r)+step(i.uv0.r,0.0))));
float node_2618 = 2.0;
float node_7822_if_leA = step((frac((node_9382/node_2618))*node_2618),1.0);
float node_7822_if_leB = step(1.0,(frac((node_9382/node_2618))*node_2618));
float node_8538 = 4.0;
float node_7968 = 10.0;
float2 node_2416_tc_rcp = float2(1.0,1.0)/float2( node_8538, node_8538 );
float node_2416_ty = floor(node_7968 * node_2416_tc_rcp.x);
float node_2416_tx = node_7968 - node_8538 * node_2416_ty;
float2 node_2416 = (((i.uv0*5.0)+float2(2,-2)) + float2(node_2416_tx, node_2416_ty)) * node_2416_tc_rcp;
float2 node_7822 = lerp((node_7822_if_leA*node_2416)+(node_7822_if_leB*0.0),node_2416,node_7822_if_leA*node_7822_if_leB);
float4 node_1692 = tex2D(_Source,TRANSFORM_TEX(node_7822, _Source));
float3 Comma = node_1692.rgb;
float Mask3 = ((1.0 - (step(i.uv0.g,0.4)+step(0.6,i.uv0.g)))*(1.0 - (step(0.6,i.uv0.r)+step(i.uv0.r,0.4))));
float3 emissive = ((digit1*Mask5)+(digit2*Mask4)+(digit3*Mask2)+(digit4*Mask1)+(Comma*Mask3));
float3 finalColor = emissive;
return fixed4(finalColor,1);
}
ENDCG
}
}
FallBack "Diffuse"
CustomEditor "ShaderForgeMaterialInspector"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment