-
-
Save dimmduh/a3f76802888c35f255220266b4fe0389 to your computer and use it in GitHub Desktop.
Tiling shader for Unity3D 5.3.x (material tiling is broken in 5.3.4f1 for some reason) + transparent
This file contains 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 "Unlit/Tiling Transparent Texture" | |
{ | |
Properties | |
{ | |
_MainTex ("Texture", 2D) = "white" {} | |
_Tiling ("Tiling", Vector) = (1, 1, 0, 0) | |
} | |
SubShader | |
{ | |
Tags | |
{ | |
"Queue"="Transparent" | |
"IgnoreProjector"="True" | |
"RenderType"="Transparent" | |
"PreviewType"="Plane" | |
"CanUseSpriteAtlas"="True" | |
} | |
Cull Off | |
Lighting Off | |
//ZWrite Off | |
Fog { Mode Off } | |
Blend SrcAlpha OneMinusSrcAlpha | |
Pass | |
{ | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#include "UnityCG.cginc" | |
struct v2f | |
{ | |
float2 uv : TEXCOORD0; | |
float4 vertex : SV_POSITION; | |
}; | |
v2f vert (appdata_base i) | |
{ | |
v2f o; | |
o.vertex = mul(UNITY_MATRIX_MVP, i.vertex); | |
o.uv = i.texcoord.xy; | |
return o; | |
} | |
sampler2D _MainTex; | |
float4 _Tiling; | |
fixed4 frag (v2f i) : SV_Target | |
{ | |
float2 uv = i.uv + float2(_Tiling.z, _Tiling.w); | |
uv = frac(uv * _Tiling); | |
fixed4 col = tex2D(_MainTex, uv); | |
return col; | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment