I've combined all of my vertex data for many particles into a single array. How would I batch draw all of those particles in a manner that preserves their unique translations?
Any code examples would be greatly appreciated.
|
I've combined all of my vertex data for many particles into a single array. How would I batch draw all of those particles in a manner that preserves their unique translations? Any code examples would be greatly appreciated. |
|||
|
How did you do this exactly? Details? You could "secretly contain" the transformation matrix for each particle's vertex in 4 texture coordinates. So, you'd have a vertex format like:
Little does the shader know that Da da da dah!! Effectively a |
||||
|
|
|
Perform the translation in your vertex shader. You must either have a parallel array which contains the translations for each vertex, or store the translations in a texture which you lookup in using some attribute of each particle. (Note: Answering as if for WebGL; I have no actual GL ES experience.) |
|||
|
|
|
Each particle needs it's own transformation matrix, so a parallel array or third element to the array of a unique tranform matrix is needed. Then before you draw a particle, multiply the current Modelview matrix by the particle's transform matrix. |
|||
|
|