Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (636)
Games in Android Showcase (178)
games submitted by our members
Games in WIP (687)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  2d particle system efficiency  (Read 1973 times)
0 Members and 1 Guest are viewing this topic.
Offline nerb
« Posted 2013-07-07 11:51:40 »


Just for a bit of fun, I'm thinking about making a very simple 2d particle system. It will essentially spit out different coloured pixels. However I have a few questions about the design for those of you who are more well-versed in computer science than me.

A lot, if not all of the examples I have found on the net treat each particle as an instance of a Particle class, which holds its own variables and has an update method. That's all well and good, and makes sense, but wouldn't having a method call for each particle in each run of the update loop introduce extra performance overhead?

I'm more inclined to hold all particle information within arrays, perhaps in a ParticleEmitter class. Then instead of calling update() on separate instances of Particle, it would just be a case of doing some basic operations on a few arrays.

So my question is, are my assumptions about the overhead of a method call correct, and would the difference in performance between the two designs be considerable or negligible??? (Keeping in mind there may be quite a few particles involved).

Offline relminator
« Reply #1 - Posted 2013-07-07 14:36:54 »

Even on android, the overhead of calling methods is negligible.

My bullet-hell game could pump 2k bullets easily on an 80mhz single core at 60fps.

Your main concern for embedded systems is usually how you design your container and limiting GC.

Offline joen

Senior Newbie

Projects: 1

« Reply #2 - Posted 2013-07-07 14:55:38 »

You'll probably get a better return on your development time by limiting GL calls than optimizing the java side.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline nerb
« Reply #3 - Posted 2013-07-08 06:11:53 »

Even on android, the overhead of calling methods is negligible.

My bullet-hell game could pump 2k bullets easily on an 80mhz single core at 60fps.

Your main concern for embedded systems is usually how you design your container and limiting GC.

Great bit of advice, thanks relminator. Might go with the Particle class based system just for simplicity.

Offline relminator
« Reply #4 - Posted 2013-07-08 06:54:57 »

Oops  I meant 800mhz. 
Offline sproingie

JGO Kernel

Medals: 202

« Reply #5 - Posted 2013-07-08 17:11:54 »

There goes running your shmup on my 486 Wink
Offline relminator
« Reply #6 - Posted 2013-07-09 00:38:27 »

Funny you should mention a 486 because I developed this shmup on a 486 dx 66mh compaq. Smiley

You'll need dos with ems to run this though:
Offline Redocdam

Senior Devvie

Medals: 17

« Reply #7 - Posted 2013-07-09 17:26:21 »

After playing around with different ways implementing particles, I'm compelled to offer up the idea of a GPU system.
When I first read about this, I began trying to guess how many animal sacrifices I would need to get this magic to work.
Turns out it wasn't that bad at all. In many ways I found it easier.

The whole idea centers around ping-ponging between two Transform Feedback Buffers (I'll call them TBO for short). TBOs are buffers you can draw into and from.
When you draw from one TBO to the other, you use a Shader to update particle information like position, velocity, age and so on. You also tell OpenGL to skip the rasterize step when you do this. Then all you really need to do is stuff this bad boy into a particle emitter class and tell it to draw when you want.

This ends up being extremely fast. When I compared it with my other particle systems, it was like a race between an Olympic Sprinter Vs. A Walmart Scooter Jockey (sans scooter).

You can use Geometry Shaders for updating, spawning and destroying particles, as well as using them for creating the billboards.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Dwinin (70 views)
2015-11-07 13:29:08

Rems19 (80 views)
2015-10-31 01:36:56

Rems19 (72 views)
2015-10-31 01:32:37

williamwoles (106 views)
2015-10-23 10:42:59

williamwoles (92 views)
2015-10-23 10:42:45

Jervac_ (106 views)
2015-10-18 23:29:12

DarkCart (134 views)
2015-10-16 00:58:11

KaiHH (116 views)
2015-10-11 14:10:14

KaiHH (155 views)
2015-10-11 13:26:18

BurntPizza (169 views)
2015-10-08 03:11:46
Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30

Rendering resources
by Roquen
2015-10-15 07:40:48

Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!