Rendering models with vertex color

I’ve create a cube in Blender with vertex colors only and verified that there are only MASK_POSITION | MASK_NORMAL | MASK_COLOR masks and data, and it renders a solid white cube with no color.
The material used is:

    <technique name="Techniques/NoTextureVCol.xml" />

What am I missing for the vertex colors to show?

edit: added pic

That is what I would do. My next test would be on the model load to see if the color values were present in the mdl file.

Color data looks valid:

vertex element mask=0x7

At least, they’re not all white value.

What render API are you using? Are you sure you’re applying the material with that technique? Does e.g. the particles fading in NinjaSnowWar work correctly for you? (this uses vertex colors)

try this material for lit.

    <technique name="Techniques/NoTextureVCol.xml" />

and this for unlit

    <technique name="Techniques/NoTextureUnlitVCol.xml" />

also, how did you get that text read out of the values? is that some tool, to see whats in the mdl?

Edit: I just saw that you were using one of these materials…

Anyway, I was just doing this yesterday. And had some trouble, but in the end it was because I did not have correct vertex color values in the MDL. and I didnt have a way to see what values were on there. So it’s hard to say what you are missing… I have a mdl with vertex colors that maybe you can test with.

Here’s a download link

Thanks for providing me with your vertex.mdl. Trouble shooting your model allowed me to find what was wrong - it was just not having the correct path to my material file.

Test code to dump color info:

        // test
			unsigned char *pVertexData = (unsigned char*)m_pVertexBuffer->Lock(0, m_pVertexBuffer->GetVertexCount());

            if ( pVertexData )
                unsigned numVertices = m_pVertexBuffer->GetVertexCount();
                unsigned vertexSize = m_pVertexBuffer->GetVertexSize();
               unsigned uElementMask = m_pVertexBuffer->GetElementMask();

                SDL_Log( "vertex element mask=0x%X\n", uElementMask );
                SDL_Log( "======================\n" );
                SDL_Log( "Colors:\n" );

                // copy position and normal
				for (unsigned i = 0; i <numVertices; ++i)
                    unsigned char *pDataAlign = (pVertexData + i * vertexSize);

                    // position
                    if ( uElementMask & MASK_POSITION )
                        Vector3 &src = *reinterpret_cast<Vector3*>( pDataAlign );
                        //src = print dbg;
                        pDataAlign += sizeof( Vector3 );

                    // normal
                    if ( uElementMask & MASK_NORMAL )
                        Vector3 &normal = *reinterpret_cast<Vector3*>( pDataAlign );
                        //normal = print dbg;
                        pDataAlign += sizeof( Vector3 );

                    // color
                    if ( uElementMask & MASK_COLOR )
                        unsigned &uColor = *reinterpret_cast<unsigned*>( pDataAlign );
                        uColor = uColor;
                        SDL_Log( "0x%08x,", uColor );
                        pDataAlign += sizeof( unsigned );

                SDL_Log( "\n" );


The intent of using vertex color to render an object was to take the vertex buffer information of an object created by btSoftBodyHelpers and convert that data into Urho3D format.

A softbody object created by Bullet looks like this:

Sorry for reviving this old post.
I’m having a similar problem.
The link to the colored model looks broken though.

Do anyone have a vertex colored .mdl file?
I am not sure if the problem is in my model, the exporter or the material. Having something to troubleshoot with, would really help. Thanks in advance!

prefab models, i.e. box, sphere, cylinder, etc., in Data/Models/ folder have vcol since last year.

1 Like

Oh, I overlooked them. Thank you very much!