- Home /
Question by
TechGuard · Jul 06, 2014 at 11:53 PM ·
shader writingblackcutoutvertexcolorcolor32
Cutout Shader with Vertex Color (always black)
Hi, I created an extension of the cutout diffuse shader. I wanted to add custom vertex color, but it always turns out black. (It did work without a cutout shader but just a diffuse shader)
My shader:
Shader "Transparent/Cutout/Diffuse Color" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
_vertStrength("Color Strength", Range(0.0, 2.0)) = 1.0
}
SubShader {
Tags { "Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout" }
CGPROGRAM
#pragma surface surf Lambert alphatest:_Cutoff
sampler2D _MainTex;
float _vertStrength;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
float3 vertColors;
};
void vert (inout appdata_full v, out Input o) {
o.vertColors = v.color.rgb;
o.uv_MainTex = v.texcoord;
}
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
c.rgb = lerp(c.rgb, c.rgb * IN.vertColors.rgb, _vertStrength);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Transparent/Cutout/Diffuse"
}
Also, in my mesh I add Color32 to the colors32 list.
I made sure it are all valid values, and not just 0
Comment