Two or more colors per vertex

Problems building or running the engine, queries about how to use features etc.
Post Reply
Tobse
Gnoblar
Posts: 24
Joined: Tue Apr 10, 2007 12:21 am

Two or more colors per vertex

Post by Tobse » Tue Jul 30, 2019 5:16 pm

Hello

Is it possible that a vertex has more than one (diffuse) color? The enum VertexElementSemantic for example contains VES_DIFFUSE and VES_SPECULAR, so 2 colors per vertex should be possible. So my question is how to access them from shader code (glsl and glsles) and can I use more than two colors per vertex?

Thanks
0 x

Tobse
Gnoblar
Posts: 24
Joined: Tue Apr 10, 2007 12:21 am

Re: Two or more colors per vertex

Post by Tobse » Thu Aug 01, 2019 12:10 am

As expected two colors per vertex is easy:

Code: Select all

          
decl->addElement(1, offset, VET_COLOUR, VES_DIFFUSE);
offset += VertexElement::getTypeSize(VET_COLOUR);
            
decl->addElement(1, offset, VET_COLOUR, VES_SPECULAR);
offset += VertexElement::getTypeSize(VET_COLOUR);
Access by GLSL code:

Code: Select all

attribute vec4 secondary_colour;
attribute vec4 colour;
The order of the attributes does not matter because they are bound by name.

If one want to assign more colors to a vertex one of the other semantics must be (miss) used due to name binding. I did not find a possibility to define custom vertex attributes with ogre. The predefined can be found here https://www.ogre3d.org/docs/manual/manu ... tml#SEC112
0 x

Post Reply