4

I am attempting to create a very simplistic particle system for an Android application using OpenGL ES 2.0. Basically it is just for linear moving clouds in the background. My first thought before starting this was to work with point sprites, and that is what I have been trying to do. It's been pretty difficult for me to get this working, but those problems aside, are point sprites really the way to go for this?

I have read quite a few conflicting things about them in my searches to solve my bugs, and I don't want to invest a great deal of my time into making it all work right if it is not the solution I should be going for in the first place. People post all kinds of troubles with them such as clipping, and even performance dips in comparison to just using triangles. I would like an experienced users insight into where point sprites fit in and when they should be used, including in situations like mine where they will not be more than a few dozen "particles" on the screen at very most.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Shamrock
  • 436
  • 1
  • 8
  • 17

2 Answers2

5

Keep in mind that there are hard size limits for point sprites, and the bigger size, the slower performance. If your goal is to have only 12 "particles", I think you should render them as quads. On the other hand, if your goal is to have 12 clouds consisting of many, many "cloud particles" each to give them an animated effect, then yes you should go with point sprites.

The bottleneck will be the fill rate, especially since you will probably use blending.

If you have 100+ clouds, the question whether to use point sprites or not becomes more relevant. To animate them, you either have to send a new buffer to opengl each frame (method 1), or render each cloud in a separate call with a different transformation matrix (method 2). The latter will most likely be the slowest, but the former requires you to send 4 new vertices per cloud (assuming indexed rendering) compared to just 1 new vertex per cloud if you used point sprites (method 3).

At this point it's very easy to roughly calculate what will be the fastest. Method 2 means 16*4*num_clouds bytes of data transferred to the gpu each frame, method 1 is d*4*num_clouds, while method 3 d*num_clouds, where d is 2 or 3 depending on whether you need z.

Worth noting is also that method 1 and 3 send the data in one batch, while method 2 sends 16*4 bytes at a time.

Since you are using GL ES 2 you could skip the matrix in method 2 and just send the translation as a vector, but you will still suffer from non-batched data transfer and the cost of setting a uniform per instance.

EDIT: Actually, what you would do in the case of many particles would be to set a uniform time, and have a velocity for the clouds as static attributes, and then animate them in the shader by multiplying the velocity with the time, and making sure they wrap around the edge if necessary. So you would only need to transfer 4 bytes per frame for a fully animated cloud scene.

Emil Romanus
  • 794
  • 1
  • 4
  • 8
  • It seems like Point Sprites are still the way to go for me, so I suppose I will soldier on and try to get them working. Thanks a lot for that useful information. I have one other concern with them however. I've read that certain devices don't display them at all, and I was wondering if this was a problem with older Android phones (While using OpenGL ES 1.1) rather than more modern phones like the ones my app will be ran on? – Shamrock Sep 08 '11 at 15:46
0

I recommend you to read the particle article of "iPhone 3D Programming".

The title of this book includes 'iPhone', but this book explains OpenGL ES 1.1/2.0 generally. Thus you can use the knowledge from this book for Android or Android NDK.

Kazuki Sakamoto
  • 13,929
  • 2
  • 34
  • 96
  • Thanks for the link Kazuki, as I am learning OpenGL ES 2.0 at the moment that looks like it will be a good read for me. :) – Shamrock Sep 08 '11 at 15:46