Skip to content

Instantly share code, notes, and snippets.

@xiaobin83
Created November 22, 2017 15:23
Show Gist options
  • Save xiaobin83/ed0395f44d1d5288a589127421aec2c6 to your computer and use it in GitHub Desktop.
Save xiaobin83/ed0395f44d1d5288a589127421aec2c6 to your computer and use it in GitHub Desktop.
shadowed scan line mesh plane
// Shader created with Shader Forge v1.38
// Shader Forge (c) Neat Corporation / Joachim Holmer - http://www.acegikmo.com/shaderforge/
// Note: Manually altering this data may prevent you from opening it in Shader Forge
/*SF_DATA;ver:1.38;sub:START;pass:START;ps:flbk:,cmtg:SF,iptp:0,cusa:False,bamd:0,cgin:,lico:1,lgpr:1,limd:0,spmd:1,trmd:0,grmd:0,uamb:True,mssp:True,bkdf:False,hqlp:False,rprd:False,enco:False,rmgx:True,imps:True,rpth:0,vtps:0,hqsc:True,nrmq:1,nrsp:0,vomd:0,spxs:False,tesm:0,olmd:1,culm:0,bsrc:0,bdst:3,dpts:2,wrdp:False,dith:0,atcv:False,rfrpo:True,rfrpn:Refraction,coma:15,ufog:True,aust:False,igpj:False,qofs:1,qpre:1,rntp:2,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,stcl:False,atwp:False,stva:128,stmr:255,stmw:255,stcp:6,stps:0,stfa:0,stfz:0,ofsf:0,ofsu:0,f2p0:False,fnsp:False,fnfb:False,fsmp:False;n:type:ShaderForge.SFN_Final,id:928,x:33039,y:32703,varname:node_928,prsc:2|custl-3377-OUT,alpha-2180-OUT;n:type:ShaderForge.SFN_Tex2d,id:1601,x:31416,y:32735,ptovrint:False,ptlb:MeshTex,ptin:_MeshTex,varname:node_1601,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,tex:99f0679330d14884cbe3821e5b078df8,ntxv:0,isnm:False|UVIN-4524-OUT;n:type:ShaderForge.SFN_Color,id:5960,x:32365,y:32510,ptovrint:False,ptlb:Color,ptin:_Color,varname:node_5960,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,c1:1,c2:1,c3:1,c4:1;n:type:ShaderForge.SFN_Multiply,id:3377,x:32716,y:32653,varname:node_3377,prsc:2|A-5960-RGB,B-2978-OUT,C-7202-OUT;n:type:ShaderForge.SFN_Slider,id:2514,x:31734,y:33394,ptovrint:False,ptlb:ScanlineIntensity,ptin:_ScanlineIntensity,varname:node_2514,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:1,max:10;n:type:ShaderForge.SFN_Add,id:2978,x:32492,y:32793,varname:node_2978,prsc:2|A-1601-RGB,B-6512-OUT;n:type:ShaderForge.SFN_TexCoord,id:9831,x:29360,y:33095,varname:node_9831,prsc:2,uv:0,uaff:False;n:type:ShaderForge.SFN_Time,id:3954,x:29989,y:32975,varname:node_3954,prsc:2;n:type:ShaderForge.SFN_Fmod,id:1059,x:30337,y:33216,varname:node_1059,prsc:2|A-6617-OUT,B-6569-OUT;n:type:ShaderForge.SFN_Multiply,id:6617,x:30231,y:33066,varname:node_6617,prsc:2|A-3954-T,B-9916-OUT;n:type:ShaderForge.SFN_Vector1,id:6569,x:30111,y:33250,varname:node_6569,prsc:2,v1:1;n:type:ShaderForge.SFN_Slider,id:7202,x:32109,y:32687,ptovrint:False,ptlb:Intensity,ptin:_Intensity,varname:node_7202,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:1,max:1;n:type:ShaderForge.SFN_ValueProperty,id:5502,x:29428,y:32695,ptovrint:False,ptlb:MeshScaleU,ptin:_MeshScaleU,varname:node_5502,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,v1:1;n:type:ShaderForge.SFN_ValueProperty,id:1827,x:29428,y:32796,ptovrint:False,ptlb:MeshScaleV,ptin:_MeshScaleV,varname:node_1827,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,v1:1;n:type:ShaderForge.SFN_Multiply,id:6065,x:29845,y:32661,varname:node_6065,prsc:2|A-5502-OUT,B-9831-U;n:type:ShaderForge.SFN_Append,id:4524,x:30685,y:32601,varname:node_4524,prsc:2|A-6065-OUT,B-1812-OUT;n:type:ShaderForge.SFN_Multiply,id:1812,x:29817,y:32870,varname:node_1812,prsc:2|A-1827-OUT,B-9831-V;n:type:ShaderForge.SFN_ValueProperty,id:9916,x:29751,y:33172,ptovrint:False,ptlb:Speed,ptin:_Speed,varname:node_9916,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,v1:0.2;n:type:ShaderForge.SFN_Slider,id:1296,x:30712,y:33731,ptovrint:False,ptlb:ScanBarWidth,ptin:_ScanBarWidth,varname:node_1296,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.2520105,max:1;n:type:ShaderForge.SFN_Smoothstep,id:6022,x:31490,y:33605,varname:node_6022,prsc:2|A-7727-OUT,B-7215-OUT,V-771-OUT;n:type:ShaderForge.SFN_Add,id:7215,x:31196,y:33616,varname:node_7215,prsc:2|A-7727-OUT,B-1296-OUT;n:type:ShaderForge.SFN_Smoothstep,id:1888,x:31490,y:33832,varname:node_1888,prsc:2|A-7215-OUT,B-7727-OUT,V-771-OUT;n:type:ShaderForge.SFN_Relay,id:771,x:30820,y:33874,varname:node_771,prsc:2|IN-5938-OUT;n:type:ShaderForge.SFN_Multiply,id:7982,x:31789,y:33709,varname:node_7982,prsc:2|A-6022-OUT,B-1888-OUT;n:type:ShaderForge.SFN_RemapRangeAdvanced,id:7727,x:31177,y:33408,varname:node_7727,prsc:2|IN-4344-OUT,IMIN-1675-OUT,IMAX-5319-OUT,OMIN-6448-OUT,OMAX-5319-OUT;n:type:ShaderForge.SFN_Vector1,id:1675,x:30919,y:33383,varname:node_1675,prsc:2,v1:0;n:type:ShaderForge.SFN_Vector1,id:5319,x:30919,y:33437,varname:node_5319,prsc:2,v1:1;n:type:ShaderForge.SFN_Relay,id:4344,x:30771,y:33350,varname:node_4344,prsc:2|IN-1059-OUT;n:type:ShaderForge.SFN_Subtract,id:6448,x:30931,y:33510,varname:node_6448,prsc:2|A-1675-OUT,B-1296-OUT;n:type:ShaderForge.SFN_Multiply,id:6512,x:32087,y:33510,varname:node_6512,prsc:2|A-2514-OUT,B-7982-OUT;n:type:ShaderForge.SFN_OneMinus,id:5938,x:30102,y:33821,varname:node_5938,prsc:2|IN-9831-U;n:type:ShaderForge.SFN_LightAttenuation,id:3919,x:32347,y:32971,varname:node_3919,prsc:2;n:type:ShaderForge.SFN_Slider,id:4681,x:32289,y:33231,ptovrint:False,ptlb:ShadowInt,ptin:_ShadowInt,varname:node_4681,prsc:2,glob:False,taghide:False,taghdr:False,tagprd:False,tagnsco:False,tagnrm:False,min:0,cur:0.6794872,max:1;n:type:ShaderForge.SFN_Multiply,id:1029,x:32684,y:33034,varname:node_1029,prsc:2|A-6280-OUT,B-4681-OUT;n:type:ShaderForge.SFN_OneMinus,id:6280,x:32537,y:32935,varname:node_6280,prsc:2|IN-3919-OUT;n:type:ShaderForge.SFN_OneMinus,id:2180,x:32843,y:32992,varname:node_2180,prsc:2|IN-1029-OUT;proporder:1601-5960-2514-7202-5502-1827-9916-1296-4681;pass:END;sub:END;*/
Shader "Custom/Shd_CoordinatingPlane" {
Properties {
_MeshTex ("MeshTex", 2D) = "white" {}
_Color ("Color", Color) = (1,1,1,1)
_ScanlineIntensity ("ScanlineIntensity", Range(0, 10)) = 1
_Intensity ("Intensity", Range(0, 1)) = 1
_MeshScaleU ("MeshScaleU", Float ) = 1
_MeshScaleV ("MeshScaleV", Float ) = 1
_Speed ("Speed", Float ) = 0.2
_ScanBarWidth ("ScanBarWidth", Range(0, 1)) = 0.2520105
_ShadowInt ("ShadowInt", Range(0, 1)) = 0.6794872
[HideInInspector]_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader {
Tags {
"Queue"="Geometry+1"
"RenderType"="Transparent"
"CustomTag"="SF"
}
LOD 200
Pass {
Name "FORWARD"
Tags {
"LightMode"="ForwardBase"
}
Blend One SrcAlpha
ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_FORWARDBASE
#include "UnityCG.cginc"
#include "AutoLight.cginc"
#include "Lighting.cginc"
#pragma multi_compile_fwdbase_fullshadows
#pragma multi_compile_fog
#pragma only_renderers d3d9 d3d11 glcore gles metal
#pragma target 3.0
uniform sampler2D _MeshTex; uniform float4 _MeshTex_ST;
uniform float4 _Color;
uniform float _ScanlineIntensity;
uniform float _Intensity;
uniform float _MeshScaleU;
uniform float _MeshScaleV;
uniform float _Speed;
uniform float _ScanBarWidth;
uniform float _ShadowInt;
struct VertexInput {
float4 vertex : POSITION;
float2 texcoord0 : TEXCOORD0;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
LIGHTING_COORDS(1,2)
UNITY_FOG_COORDS(3)
};
VertexOutput vert (VertexInput v) {
VertexOutput o = (VertexOutput)0;
o.uv0 = v.texcoord0;
o.pos = UnityObjectToClipPos( v.vertex );
UNITY_TRANSFER_FOG(o,o.pos);
TRANSFER_VERTEX_TO_FRAGMENT(o)
return o;
}
float4 frag(VertexOutput i) : COLOR {
////// Lighting:
float attenuation = LIGHT_ATTENUATION(i);
float2 node_4524 = float2((_MeshScaleU*i.uv0.r),(_MeshScaleV*i.uv0.g));
float4 _MeshTex_var = tex2D(_MeshTex,TRANSFORM_TEX(node_4524, _MeshTex));
float4 node_3954 = _Time;
float node_1675 = 0.0;
float node_5319 = 1.0;
float node_6448 = (node_1675-_ScanBarWidth);
float node_7727 = (node_6448 + ( (fmod((node_3954.g*_Speed),1.0) - node_1675) * (node_5319 - node_6448) ) / (node_5319 - node_1675));
float node_7215 = (node_7727+_ScanBarWidth);
float node_771 = (1.0 - i.uv0.r);
float3 finalColor = (_Color.rgb*(_MeshTex_var.rgb+(_ScanlineIntensity*(smoothstep( node_7727, node_7215, node_771 )*smoothstep( node_7215, node_7727, node_771 ))))*_Intensity);
fixed4 finalRGBA = fixed4(finalColor,(1.0 - ((1.0 - attenuation)*_ShadowInt)));
UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
return finalRGBA;
}
ENDCG
}
Pass {
Name "FORWARD_DELTA"
Tags {
"LightMode"="ForwardAdd"
}
Blend One One
ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_FORWARDADD
#include "UnityCG.cginc"
#include "AutoLight.cginc"
#include "Lighting.cginc"
#pragma multi_compile_fwdadd_fullshadows
#pragma multi_compile_fog
#pragma only_renderers d3d9 d3d11 glcore gles metal
#pragma target 3.0
uniform sampler2D _MeshTex; uniform float4 _MeshTex_ST;
uniform float4 _Color;
uniform float _ScanlineIntensity;
uniform float _Intensity;
uniform float _MeshScaleU;
uniform float _MeshScaleV;
uniform float _Speed;
uniform float _ScanBarWidth;
uniform float _ShadowInt;
struct VertexInput {
float4 vertex : POSITION;
float2 texcoord0 : TEXCOORD0;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
LIGHTING_COORDS(1,2)
UNITY_FOG_COORDS(3)
};
VertexOutput vert (VertexInput v) {
VertexOutput o = (VertexOutput)0;
o.uv0 = v.texcoord0;
o.pos = UnityObjectToClipPos( v.vertex );
UNITY_TRANSFER_FOG(o,o.pos);
TRANSFER_VERTEX_TO_FRAGMENT(o)
return o;
}
float4 frag(VertexOutput i) : COLOR {
////// Lighting:
float attenuation = LIGHT_ATTENUATION(i);
float2 node_4524 = float2((_MeshScaleU*i.uv0.r),(_MeshScaleV*i.uv0.g));
float4 _MeshTex_var = tex2D(_MeshTex,TRANSFORM_TEX(node_4524, _MeshTex));
float4 node_3954 = _Time;
float node_1675 = 0.0;
float node_5319 = 1.0;
float node_6448 = (node_1675-_ScanBarWidth);
float node_7727 = (node_6448 + ( (fmod((node_3954.g*_Speed),1.0) - node_1675) * (node_5319 - node_6448) ) / (node_5319 - node_1675));
float node_7215 = (node_7727+_ScanBarWidth);
float node_771 = (1.0 - i.uv0.r);
float3 finalColor = (_Color.rgb*(_MeshTex_var.rgb+(_ScanlineIntensity*(smoothstep( node_7727, node_7215, node_771 )*smoothstep( node_7215, node_7727, node_771 ))))*_Intensity);
fixed4 finalRGBA = fixed4(finalColor * (1.0 - ((1.0 - attenuation)*_ShadowInt)),0);
UNITY_APPLY_FOG(i.fogCoord, finalRGBA);
return finalRGBA;
}
ENDCG
}
}
FallBack "Diffuse"
CustomEditor "ShaderForgeMaterialInspector"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment