Page 1 of 1

Two or more colors per vertex

Posted: Tue Jul 30, 2019 5:16 pm
by Tobse

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?


Re: Two or more colors per vertex

Posted: Thu Aug 01, 2019 12:10 am
by Tobse
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 ... tml#SEC112