Hi all. I try to write my first simple shader, that will be like built-in Alpha-Diffuse.shader, but will ignore some colors when it multiply texture color on _Color variable:
Shader "Transparent/Diffuse Selective" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 200
CGPROGRAM
#pragma surface surf Lambert alpha
sampler2D _MainTex;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
float4 c = tex2D(_MainTex, IN.uv_MainTex);
if (c.r < 1 c.g < 1 c.b < 1) { // multiply texture on color only if pixel isn't white
c *= _Color;
}
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback "Transparent/VertexLit" // if I comment this string - I have warning "Shader warning in 'Transparent/Diffuse Selective': No subshaders can run on this graphics card"
}
So when I make this shader and start to use it - nothing change, it works like default Transparent shader, then I comment string Fallback and get warning: “Shader warning in ‘Transparent/Diffuse Selective’: No subshaders can run on this graphics card”. So it looks like my shader doesn’t work, and instead of it Unity use shader from section Fallback “Transparent/VertexLit”.
I check this behavior on two different computers (one of them has NVIDIA GeForce 8600 GT)
Even if I comment
if (c.r < 1 c.g < 1 c.b < 1) { // multiply texture on color only if pixel isn't white
c *= _Color;
}
situation the same. It seems I do something wrong, because it looks like base Transparent shader and shout be work.
Thanks.