Last active
April 18, 2018 04:32
-
-
Save alexshikov/aad6fe6a790d4ed6cecdca8888c95a59 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)
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 "Unlit/Tiling Texture" | |
{ | |
Properties | |
{ | |
_MainTex ("Texture", 2D) = "white" {} | |
_Tiling ("Tiling", Vector) = (1, 1, 0, 0) | |
} | |
SubShader | |
{ | |
Tags | |
{ | |
"Queue"="Geometry" | |
"IgnoreProjector"="True" | |
"RenderType"="Geometry" | |
"PreviewType"="Plane" | |
"CanUseSpriteAtlas"="True" | |
} | |
Cull Off | |
Lighting Off | |
//ZWrite Off | |
Fog { Mode Off } | |
Blend One 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