Vertex color doesn't show!

Hello, this is my first post. I’m a newbie at Unity and so far I’m very impressed with what I see (I use the Unity 4 Beta).

I have been able to import my animated character from Maya 2012 without problem (using the fbx exporter version 2011), but I met a strange issue: the vertex color information on my meshes is not displayed (I use the Bumped Specular shader, but I tried pretty much all the available shaders and the problem is still there).

Now I know that Unity sees the vertex color data, since in the preview window it says “uv, color, skin”. And the diffuse and normal maps are showing just fine. But again the vertex color are nowhere to be seen.

Now I know this is an ultra basic newbie thing, but could anyone please help me…?

[B__]Update:__[/B] This time I’ve tried with a simple cube, added a color set (tried with RGB and RGBA), painted a different color on each corner, exported and still no vertex color. Please don’t tell me Unity doesn’t support vertex color…

The standard built-in shaders don’t support vertex colors, aside from the particle shaders. You can make your own or modify the existing ones.

–Eric

Unity supports vertex colors, but standart materials in unity do not respect vertex colors, you need special shader for this.

Try this one

Shader "BumpedSpecularVtxCol" {
Properties {
	_Color ("Main Color", Color) = (1,1,1,1)
	_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
	_Shininess ("Shininess", Range (0.03, 1)) = 0.078125
	_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
	_BumpMap ("Normalmap", 2D) = "bump" {}
}
SubShader { 
	Tags { "RenderType"="Opaque" }
	LOD 400
	
CGPROGRAM
#pragma surface surf BlinnPhong


sampler2D _MainTex;
sampler2D _BumpMap;
fixed4 _Color;
half _Shininess;

struct Input {
	float2 uv_MainTex;
	float2 uv_BumpMap;
	half4 color : COLOR0;
};

void surf (Input IN, inout SurfaceOutput o) {
	fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
	o.Albedo = tex.rgb * _Color.rgb * IN.color.rgb;
	o.Gloss = tex.a;
	o.Alpha = tex.a * _Color.a;
	o.Specular = _Shininess;
	o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
}
ENDCG
}

FallBack "Specular"
}
1 Like

Oh my. How strange. But thank you very much guys, that works now!

However this is an extremely basic feature anyone is expecting out of the box and I’m frankly very surprised it isn’t included in the standard shaders. I can’t quite imagine why…

Every feature that is “supported” by a shader has a fixed cost, whether you use it or not. Most people use textures rather than vertex colours, so there would be a lot of wasted GPU time around the world if every shader was using undefined vertex colours to no effect.

Yes, you are totally right. But why devs cant just include both versions : with vertex colors and no vertex colors? If you look at shader that i post you ll see that it is just standart blinn shader with 2 little edits. But it might be a problem for non-techy or newtounity people.

There are all sorts of modifications you could make to the standard shaders with a couple edits. At some point UT have to assess what most people will use, and then just do their best to make sure that what everyone else wants is possible.

Thanks for you reply, Daniel. I understand what you’re saying, but as Yursiv pointed out the best thing to do would be to at least include those shaders. Again it might be obvious for a Unity veteran, but to a beginner (with a lot of experience with other engines) it’s a little bit like you’ve got a new car with four doors but the doors in the back won’t open. Because some people don’t need them to open (?!). Honestly it feels almost like a mistake that at least one shader with vertex coloring isn’t included in the standard release.

And it’s all the more puzzling because to my beginner’s eyes all of Unity seems amazingly straightforward and well thought-out. I love it!

Actually, particle colours are done with vertex attributes, so all the particle shaders support vertex colours.

1 Like

thaks for this! I wish teh docs provided this info!

someone know how keep vertex color from zbrush obj please ? thank’s

Aaaaah thank you for this info! you just ended my endless search!

Thanks a lot dude!

I just wanted to say thank you ive spent hours trying fix this until i found this thank you

Hey man i don’t know how i can use the shader if it doesn’t let me

Hello! I am from future XD
i just wanted to ask that, where am i gonna use this code?
i realy dont know…