Creating a crowd shader
To render a crowd, you will need to create a new shader. The crowd shader will have projection and view uniforms, but no model uniform. This is because all actors are drawn with the same projection and view matrices but require a unique model matrix. Instead of model matrices, the shader will have three uniform arrays: one for position, one for rotation, and one for scale.
The value that will be placed into these arrays will be an instance index – the index of the current mesh being rendered. Each vertex gets a copy of its mesh instance through a built-in glsl
variable, gl_InstanceID
. Each vertex will construct a model matrix using the position, rotation, and scale uniform arrays.
The inverse bind pose is like a matrix uniform array with regular skinning, but the animated pose is not. To find the animated pose, the shader will have to sample the animation texture. Since each vertex is skinned to four vertices, the animated pose has to be found...