6
$\begingroup$

At first: I already posted this on the stackoverflow community. I'm new and didn't know about this community here. I apologize.

I basically got the same question as the guy who asked here: https://stackoverflow.com/questions/36457138/dynamically-sized-arrays-in-opengl-es-vertex-shader-used-for-blend-shapes-morph. 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.

Thank you for your answers!

$\endgroup$

2 Answers 2

6
$\begingroup$

The counter you want is built in the shader as gl_VertexID.

However you have 16 attributes of 4 components each to work with. Take 2 components for the texture coordinates and you have 62 float values to play with. If you need 6 components per blend shape (3 pos + 3 normal) you get 10 blend shapes to work with per object per frame. If you leave off the normal as static then you get up to 19 shapes.

Times when you want to blend between more than 10 shapes should be very rare. And even then you can probably get away with making another shape to get the resulting shape you want.

$\endgroup$
1
  • $\begingroup$ Alright, thank you for the hint to gl_vertextID. That's what I looked for. Regarding the number of blendshapes: I am writing a renderer for facial animation research and in this context the possibility to use more than 10 shapes should at least exist. Another possibility I just stumbled upon is the use of transform feedback to process blocks of shapes iteratively. Do you have a take on that? Again, thank you! $\endgroup$ Jun 13, 2016 at 9:52
0
$\begingroup$

gl_VertexID Is the way to go, you quickly run out of attribs if you need a normal mapped skeletal character, there’s only room for 2-3 blend shapes to fit in 16 attribs

$\endgroup$
1
  • $\begingroup$ I don't really see a point in this answer to an old question since it doesn't provide any relevant new information that wasn't already given by the existing answer. $\endgroup$
    – wychmaster
    Dec 11, 2020 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.