I'm trying to write a custom shader for NGUI. It's a variation on the Unlit/Transparent Color shader, but it combines the texture and tint colors in a different way.The functionality I want is more complicated than can be done with a fixed function shader, so I'm writing a shader with vertex and fragment functions. The main problem I'm having with the shader is getting shader access to the color tint that can be specified in the UISprite's inspector. Below is a simple vertex/fragment shader I wrote that attempts to duplicate the functionality of Unlit/Transparent Color. The texture comes through fine (_MainTex), but the color (_Color) always seems to be white. Any suggestions on how I can access the tint color? Do I simply need to rename _Color, and if so what is the appropriate name?
Shader "Custom/NGUIVertFragTranspCol" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Color ("Main Color", Color) = (1,1,1,1)
}
SubShader
{
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
AlphaTest Greater .01
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f
{
float4 pos : POSITION;
half2 uv : TEXCOORD0;
};
sampler2D _MainTex;
fixed4 _Color;
v2f vert(appdata_img v)
{
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = v.texcoord;
return o;
}
half4 frag(v2f i) : COLOR
{
return _Color * tex2D(_MainTex, i.uv);
}
ENDCG
}
}
Fallback "VertexLit"
}
Thanks!
A. T.