- Home /
Question by
Ledrec · Nov 18, 2016 at 04:48 AM ·
errorshaderoffsetalpha-channel
offset shader not moving alpha
Hi im trying to offset my texture, but every time i move it using TRANSFORM_TEX and offseting it it get clipped just where the alpha of my image is, so im guessing it doent translate alpha, is there a way to translate it? Its as if the color are getting clipped by my image alpha, this is my shader code:
Shader "Sprites/TilesetNoMask" { Properties { _MainTex ("Sprite Texture", 2D) = "white" {} _Color ("Tint", Color) = (1,1,1,1) [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0 }
SubShader
{
Tags
{
"Queue"="Transparent+2"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Cull Off
Lighting Off
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#pragma multi_compile _ PIXELSNAP_ON
#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
#include "UnityCG.cginc"
uniform float4 _MainTex_ST;
sampler2D _MainTex;
struct appdata_t
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
fixed4 _Color;
v2f vert(appdata_t IN)
{
v2f OUT;
OUT.vertex = UnityObjectToClipPos(IN.vertex);
OUT.color = IN.color * _Color;
OUT.texcoord = TRANSFORM_TEX(IN.texcoord, _MainTex);
#ifdef PIXELSNAP_ON
OUT.vertex = UnityPixelSnap (OUT.vertex);
#endif
return OUT;
}
fixed4 frag(v2f IN) : SV_Target
{
fixed4 c = tex2D (_MainTex, IN.texcoord);
return c;
}
ENDCG
}
}
}
Comment