I’ve assigned vertex colors to a plane with Maya (Image1) and exported it to Unity with using my VertexColorShader which shows vertex colors.
I expected the result would be like Image3 but what happened was that it came out like Image2.
Please take a look at those images.
My shader is fairly simple. It just makes vertex colors visible.
The vert function takes each vertex color and stores it in the output variable.
The surf function retrieves the color from the variable and sets it as a fragment’s color.
Since vert function gets called per vertex as far as I believe, I thought the result would be like Image3 (I made up this image with Photoshop) but actually come out as Image2.
How come ??
Each fragment between vertices doesn’t know its color since vert function doesn’t get called between vertices so I thought the plain’s color is almost white except vertex’s position.
Would anyone please explain me why this happens ??
Here is my shader.
Shader "MyShader/VertexColorShader" {
Properties {
}
SubShader {
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma surface surf Lambert vertex:vert
struct Input {
float4 vertColor;
};
void vert(inout appdata_full v, out Input o) {
UNITY_INITIALIZE_OUTPUT(Input, o);
o.vertColor = v.color;
}
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = IN.vertColor.rgb;
}
ENDCG
}
}
Cheers
