Skip to content

Instantly share code, notes, and snippets.

@dimmduh
Forked from alexshikov/TilingTexture.shader
Last active April 18, 2018 04:33
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 dimmduh/a3f76802888c35f255220266b4fe0389 to your computer and use it in GitHub Desktop.
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
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