i am testing a shader,
i know it can be done with
- this.renderer.material.mainTexture.wrapMode = TextureWrapMode.Repeat;
but i wanted to try this an expand on it
this i my shader
{
Properties
{
_Color("_Color", Color) = (1,1,1,1)
_MainTex("_MainTex", 2D) = "white" {}
_Vertical("_Vertical", float) = 0
_Horizontal("_Horizontal", float) = 0
}
SubShader
{
ZWrite Off
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="False"
"RenderType"="Transparent"
}
Pass
{
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
float4 _Color;
sampler2D _MainTex;
float _Vertical;
float _Horizontal;
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
};
v2f vert(appdata_full v)
{
v2f output;
output.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
output.uv = v.texcoord;
output.uv = float4( v.texcoord.xy, 0, 0 );
output.uv.y -= _Vertical;
output.uv.x -= _Horizontal;
output.uv = frac(output.uv);
return output;
}
float4 frag(v2f i) : COLOR
{
float4 lColor = tex2D(_MainTex, i.uv)*_Color;
lColor.a *= _Color.a;
return lColor;
}
ENDCG
}
}
}
but with this i am getting some kind of reverse cramped image as well , and i dont know why,
any ideas ???
the idea is that i can wrap/ repeat when i move the image on the plane , not using TextureWrapMode.Repeat;