- Home /
How to account for tiling in shader uv coords?
I have a fragment shader that looks like
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Main Tex (RGBA)", 2D) = "white" {}
_Progress ("Progress", Range(0.0,1.0)) = 0.0
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
//ZTest Always - testing this to remove always ontop
Blend SrcAlpha OneMinusSrcAlpha
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform float4 _Color;
uniform float _Progress;
uniform float4 _MainTex_ST;
struct v2f {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
};
v2f vert (appdata_base v)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
return o;
}
half4 frag( v2f i ) : COLOR
{
half4 color = tex2D( _MainTex, i.uv);
if(i.uv.x > (1.0 - _Progress))
{
if(color.a != 0)
{
color.a = 1;
}
}else
{
color.a = 0;
}
return tex2D(_MainTex, i.uv) * color * _Color;
}
ENDCG
}
}
Its point is to allow only showing the specified progress of whatever it's on.
If I tile the texture, when I access the uv's coords, it only returns the coords within 1 element of the tile. But I want them in terms of the entire width of the billboard I'm tiling the texture on. Is there a way to do this?
Comment
Your answer
Follow this Question
Related Questions
How to draw a tiled texture on a post process shader 0 Answers
Projector + custom fragment shader = endless texture draw 2 Answers
How to force the compilation of a shader in Unity? 5 Answers
Cg Language incompatibility Desktop VS GLSL Android 0 Answers
Can anyone help me with reflective shader with fall off property? 0 Answers