I was trying to have a VBO with bone indices in my Android GLES2 3D game.
The issue is that most of the vertex buffer contains float while the indices only require unsigned bytes.
At first I was just using floats as indices for the bones but I wanted to do better. So I made a vertex buffer that have both floats and unsigned chars.
In order to tell GLES2.0 you want 4 indices of unsigned chars you need to call:
You will need to make sure you pass a ByteBuffer with the correct format to GLES2 with GLES20.glBufferData.
Lastly, and this is the tricky part and reason why I wrote this article. How to refer to unsigned bytes attributes inside the GLSL shader code?
Well it turns out GLES2.0 does not have ivec4 which is a vector of 4 ints. However, in GLES2.0 you can use “attribute vec4” for unsigned bytes even though the bytes are not 32 bit floats.
This will result in a float data type but you can convert it into int using int(YourVar).