1
votes

I basically got the same question as the guy who asked here: Dynamically sized arrays in OpenGL ES vertex shader; used for blend shapes/morph targets . Especially his last unanswered question bothers me too.

So I also want to use an arbitrary number of blendshapes for each mesh I'm processing. At the moment I'm using a fixed number and treat the shapes as vertex attribute. The advantage here is that I always have the relevant data for the current vertex availiable. Now, if I want to use an arbitrary number of shapes, I figured I'd use SSBOs since their clue is exactly what I want: Dynamically sized data. However SSBOs are, as far as I understand it, static and for each processed vertex in the shader I have the blendshape data for the whole mesh availiable. That means I would have to introduce some kind of counter and try to pick the correct data piece out of my SSBO for each vertex.

Is this understanding correct? I'm really not sure whether this is the optimal solution, maybe you can give me some hints.

1

1 Answers

1
votes

Yes your understanding is correct.

You can use gl_VertexID or just pass some 'vertex number' as attribute to know what data to load in your SSBO for the particular vertex you're processing.