performance - Fastest way to draw sprites in opengles 2.0 on android -
so im trying figure out how draw single textured quad many times. issue since these create , deleted , every 1 of them has unique position , rotation. im not sure vbo best solution i've heard modifying buffers extremely slow on android , seems need create new 1 each frame since different quads might disappear randomly (collide enemy). if draw call each 1 20fps around 100, unusable. advice?
edit: i'm trying create bullethell, figuring out how draw 500+ things hurting head.
i think you're after particle system. similar question here: drawing many textured particles in opengl es 1.1.
using point sprites quite cheap, have work in fragment shader , i'm not sure if gles2 supports gl_pointsize
if need different sized particles. gl_pointsize corresponding world space size
my go-to particle system storing positions in double buffered texture, draw using single draw call , static array of quads. this related i'll describe bit more here...
- create texture (floating point if can, may limit supported devices). each pixel holds particle position , maybe rotation information.
- [edited] if need animate particles want change values in texture each frame. make fast, gpu in shader. using fbo, draw fullscreen polygon , update values in fragment shader. problem can't read , write same texture (or shouldn't). common approach double buffer texture creating second 1 render while read first, ping-pong between them.
- create vbo drawing triangles. positions same, filling -1 1 quad. make texture coordinates each quad address correct pixel in above texture.
draw vbo, binding positions texture. in vertex shader, read position given vertex texture coordinate. scale -1 1 vertex positions right size, apply position , rotation. use original -1 1 position texture coordinate pass fragment shader add regular colour textures.
if ever have glsl version
gl_vertex
, quite generating these coordinates in vertex shader, saving storing unnecessarily trivial data draw simple objects. this example.- to spawn particles, use
gltexsubimage2d
, write block of particles position texture. may need few textures if start storing more particle attributes.
Comments
Post a Comment