<p>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</p>

CC BY-SA 4.0
2020-12-11T13:27:26.627Z
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.
wychmaster
CC BY-SA 4.0
2020-12-11T12:46:28.477Z
2020-12-11T12:46:28.477Z
Gedalia
<p>The counter you want is built in the shader as <code>gl_VertexID</code>. </p>

<p>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.</p>

<p>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.</p>

CC BY-SA 3.0
2016-06-13T09:52:01.777Z
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!
try_some_ubik
CC BY-SA 3.0
2016-06-13T09:44:32.683Z
2017-10-22T05:06:57.687Z
2017-10-22T05:06:57.687Z
ratchet freak
<p>At first: I already posted this on the stackoverflow community. I'm new and didn't know about this community here. I apologize.</p>

<p>I basically got the same question as the guy who asked here: <a href="https://stackoverflow.com/questions/36457138/dynamically-sized-arrays-in-opengl-es-vertex-shader-used-for-blend-shapes-morph">https://stackoverflow.com/questions/36457138/dynamically-sized-arrays-in-opengl-es-vertex-shader-used-for-blend-shapes-morph</a>.
Especially his last unanswered question bothers me too.</p>

<p>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.</p>

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

<p>Thank you for your answers!</p>

<opengl><shader><c++>
Open GL Shader Storage Buffer Objects to replace Vertex Attributes
try_some_ubik
# Open GL Shader Storage Buffer Objects to replace Vertex Attributes

(Asked by: username_0 on 2016-06-13)

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!

**Tags:** opengl, shader, c++


---

## 2 answers

### Answer by username_3 on 2016-06-13. Score: 6 | Accepted answer

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.

> **Comments:**
> **username_0**: 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!  

---

### Answer by username_1 on 2020-12-11. Score: 0

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

> **Comments:**
> **username_2**: 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.  

---

