I am using opengles 2.0. I am trying to pass an integer value to vertex shader. My client code is like this :
glEnableVertexAttribArray(3); // Bones
glVertexAttribPointer(3, 4, GL_UNSIGNED_SHORT, GL_FALSE, object->m_mesh->GetVertexSize(), (const void*)offset);
And the vertex shader code is :
attribute vec4 vBones;
uniform Bone bones[64];
gl_Position = bones[int(vBones.x)].transform * bones[int(vBones.x)].bindPose * vec4(vPosition, 1.0) * vWeights.x;
If I compile code as it is. All "vBones.xyzw" becomes 0 and I get an unskinned mesh. Because 0 refers to an identity matrix.
if I change client code to this :
glVertexAttribPointer(3, 4, GL_INT, GL_FALSE, object->m_mesh->GetVertexSize(), (const void*)offset);
Code runs without anyerror in windows. However when I compiled it to webgl via emscripten, I get gl error 1282 (Invalid Operation)
So briefly, can you give me an example of passing int vertex attribute to glsl ?