HI all! Could you help me with my question about shaders? I trying write vertex fragment shader. If use i.color in fragment shader, my shader looks just white, but if i use _Color. Shader works correctly.
Shader "custom/green"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Color Texture", 2D) = "white" {}
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Cull Off
Lighting Off
ZWrite Off
Blend One OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
float4 color : COLOR0;
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
float4 color : COLOR0;
};
float4 _Color;
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o.color = v.color;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col_tex = tex2D(_MainTex, i.uv);
// fixed4 col = i.color; // not work
fixed4 col = _Color; // work!
return col;
}
ENDCG
}
}
}