I'm about to do an Opengl ES implementation of blend shapes/morph targets and I'm not quite sure about the best way for me to do this. The problems I am facing is that I want the interpolation of the vertex data to occur on the GPU but I also want the number of blend shapes to be arbitrary.
To clarify, I do not want my vertex shader to look like this: Glitchy Facial Morph Target Animation in OpenGL (C++). The problem with this implementation is that the number of meshes to blend between is static in the shader. I am going to process multiple meshes that have different numbers of blend shapes associated to them and I dont want to create separate shader for each if possible. Creating hard-coded shaders for meshes with around 20 blend shapes will also look quite ugly imo.
So I was thinking of using some kind of dynamic array to hold all the data. However, I'm uncertain if you can allocate dynamically sized arrays in the vertex shader? In Vertex shader with array inputs the op has the size set to a constant. The only way I could think about creating my array is the use a uniform variable to hold the size but I'm guessing that won't compile since the array cannot be allocated with an unknown variable.
So what I'm trying to find is a good way to store my data(number of blend shapes, weights, vertices, normals) and to access them during runtime in my vertex shader so I can effectively interpolate on the GPU.
Any ideas on how to accomplish this?
EDIT Forgot to mention its for OpenGL ES
dynamic array == std::vector
– NathanOliver