cocos2d-objc icon indicating copy to clipboard operation
cocos2d-objc copied to clipboard

Improved Rendering (Simplified particles)

Open Birkemose opened this issue 12 years ago • 5 comments

As it is now, particles uses quite a bit of CPU time on transformations etc, which doesnt even work properly. See #484. I suggest a simplified approach, where particles are more like layers, you can add to your game. Each layer can then handle an infinite number of emitters and particles, which all are based on global positioning, and of course batched. Emitters can be attached to a node, to allow for tracking an object (rocket exhaust).

Birkemose avatar Jan 24 '14 17:01 Birkemose

Is this a situation where offloading the positioning maths for particles and their quads to GLKMaths and Matrix calculations would relieve the CPU of this overhead?

dissidently avatar Jan 24 '14 17:01 dissidently

No, not really.

The idea is to simplify particle calculation by assuming a lot of things. Ex anchor point always being 0.5, 0.5. If so, you max. need to calculate two vertices, to be able to get the last two by simple adding and subtracting. If you furthermore assume the particle is rectangular, you only need calculate one vertex. Finally, you could assume there was no rotation of the particles, which would pretty much remove all vertice calculation, but a few adding and subtracting.

In my opinion, the keyword to obtaining good CPU performance on "a lot" of particles, ie 10K+ particles on modern devices, is brute force programming, where you dont even test and branch, in the critical parts of the code. So my idea is to plug in different kinds of methods, if you ex define that your particle system doesn't need to rotate its particles.

Birkemose avatar Jan 24 '14 21:01 Birkemose

As an (extremely) annoying designer, I can assure you that rotation, scale AND position are essential to making anything truly interesting with particles.

Then there's all sorts of wonders with skew to fake perspective effects on them as well...

See. Told you I'm annoying.

dissidently avatar Jan 24 '14 21:01 dissidently

Exactly, so I would leave it to the designer to choose what kinds of options were needed for the particle system he wanted. It should be a setup like any other in the plist.

However, If you ex were designing rain, snow, etc etc, you might be able to live with no rotation and scaling, which again then would enable you to add 10-20-50% more particles. Especially with low fillrate particle systems (as opposed to ex fire systems, which depends a lot on the additive render effect), this could make quite a difference.

Birkemose avatar Jan 24 '14 22:01 Birkemose

Pinging this issue for #1163

slembcke avatar Jan 14 '15 01:01 slembcke