opengl es - How to store and access per fragment attributes in WebGL -


i doing particle system in webgl using three.js, , want computation of particles in shaders. achieve that, positions (for example) of particles stored in texture sampled vertex shader of each particle (point primitive).

the position texture in fact 2 render targets swapped each frame after being updated off screen. each pixel of texture represent particle. update position, read 1 of render targets (texture2d), computation, , write on other render target (fragment output).

to perform "do computation" step, need per particle attributes, velocity (and lot of others). since step done in fragment shader, can't use vertex attributes buffers, have store these properties in separate textures , sample each of them in fragment shader.

it works, sampling textures slow far know, , wonder if there better ways this, having 1 vertex per particle, each rendering single fragment of position texture. know opengl 4 alternative ways deal this, ubo or ssbo, i'm not sure webgl.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -