Last active
October 19, 2020 20:51
-
-
Save tolotratlt/7007797 to your computer and use it in GitHub Desktop.
Unity 3d unlit transparent shader that scroll horizontally, especially for 2d games.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Custom/UnlitTransparentScroll" { | |
Properties { | |
_MainTex ("Base (RGB)", 2D) = "white" {} | |
_ScrollXSpeed ("X Scroll Speed", Range (0,10)) = 2 | |
} | |
SubShader { | |
Lighting Off | |
AlphaTest Greater 0.5 | |
Tags { "RenderType"="Opaque" } | |
LOD 200 | |
CGPROGRAM | |
#pragma surface surf Unlit | |
fixed4 LightingUnlit(SurfaceOutput s, fixed3 lightDir, fixed atten) | |
{ | |
fixed4 c; | |
c.rgb = s.Albedo; | |
c.a = s.Alpha; | |
return c; | |
} | |
sampler2D _MainTex; | |
fixed _ScrollXSpeed; | |
struct Input { | |
float2 uv_MainTex; | |
}; | |
void surf (Input IN, inout SurfaceOutput o) { | |
fixed2 scrolledUV = IN.uv_MainTex; | |
fixed xscrollValue = _ScrollXSpeed * _Time; | |
scrolledUV += fixed2( xscrollValue, 0); | |
half4 c = tex2D (_MainTex, scrolledUV); | |
o.Albedo = c.rgb; | |
o.Alpha = c.a; | |
} | |
ENDCG | |
} | |
FallBack "Diffuse" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment