Vertex color doesn't work as I expected

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

Ok, I got the answer.

Everything stored in the out variable of vertex function is interpolated and passed to the fragment or surface function.

Thanks.

As a further point, when Maya is displaying vertex colors it isn’t doing anything differently from your Unity shader, it too is using vertex / fragment shaders to render to the viewports. The only differences between Maya and Unity here are due to quad triangulation not matching (Maya might be using quads / patches internally, but they’re still triangulated to render in the viewports), and gamma / color space differences in displaying to the screen.