Hello I cannot seem to set the MASK_OBJECTINDEX attribute for a shader. I am creating every vertex with this and it works just fine:
vertexData.Push(x); vertexData.Push(y); vertexData.Push(z);
vertexData.Push(0.5f);
The fourth is some data that I want to be the OBJECTINDEX.
Here is how I am setting the size of type of my vertex buffer (where VERTEX_SIZE is just 4)
vb->SetSize(vertexData.Size()/VERTEX_SIZE, MASK_POSITION | MASK_OBJECTINDEX);
Here is a simplified version my shader:
#include "Uniforms.glsl"
#include "Samplers.glsl"
#include "Transform.glsl"
varying float vObjectIndex;
void VS()
{
vec3 worldPos = GetWorldPos(iModelMatrix);
gl_Position = GetClipPos(worldPos);
vObjectIndex = iObjectIndex / 10000000000.0;
}
void PS()
{
gl_FragColor = vec4(vObjectIndex, vObjectIndex, vObjectIndex, 1.0);
}
If I don’t have the 10000000000.0 in there the entire mesh I am rendering is completely white and including it makes the mesh a dark grey. Thus, even though every vertex should be a 0.5f it ends up being in the 10s of billions instead… there must be something strange I am doing here…
Is this even what iObjectIndex is meant to be used for? If not, how can I have a single float or 4 byte int (int is preferred) for every vertex?