0
votes

Since GLES2.0 don't have geometry shaders, i want to simulate one using just vertex shaders. My idea goes like this: I have: x, y, z, size variables and send one each vertex, then save them somewhere. After the 6th vertex, i use the last 6 values (x, y, z, size and two more if i need) to build the next 6 vertices out of them. For instance:

  • On the first call of the vertex shader, i save the x variable somewhere, and return gl_Position = (0,0,0), gl_Color = (0,0,0,0), etc...
  • On the second call, i save the y variable somewhere, and then trash the vertex in the same way as above. I then repeat this until the 6th vertex.
  • On the 6th vertex, i pull the x, y, z and size variables from somewhere and then build the upper left vertex of a square using them. (gl_Position = (x-size/2, y-size/2, 0)... etc..

The problem is, i don't know what is this 'somewhere'. I have no idea how to save a variable in a vertex shader call, to the use it in the next call.

TLDL: I want to make 10400 triangles out of 5200 * (x, y, z, square_size) on GLES2.0 in a single draw call, have an idea on how to do, but don't know how to implement it

1

1 Answers

0
votes

The problem is, i don't know what is this 'somewhere'. I have no idea how to save a variable in a vertex shader call, to the use it in the next call.

This is something you can't do (it takes something beyond the vertex shader stage to do this). Simply consider that all vertices are processed by the GPU through the vertex shader at the same time. This is the model you should have in your mind when working with the vertex stage. I think it's pretty obvious why it is, that what you want can't be done that way.