Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
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  
  best method for a particle system?  (Read 2340 times)
0 Members and 1 Guest are viewing this topic.
Offline deepthought
« Posted 2011-07-08 23:23:13 »

i want t create a particle system for explosions and trails and other effects. question is,  how should i store my particles? it seems like a bad idea to use classes. maybe should i use a 2 dimensional array, one dimension is the particle, the second is which attribute?

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
Offline philfrei
« Reply #1 - Posted 2011-07-09 00:38:02 »

Quote
it seems like a bad idea to use classes.
Why? Huh

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline namrog84

JGO Ninja


Medals: 46
Projects: 4


Keep programming!


« Reply #2 - Posted 2011-07-09 00:45:30 »

I just had assumed youd make a Particle class
give it some functions/properities like location, direction,  fade out,  velocity, lifetime(till death),  grow/shrink

then somewhere particle generator just make a ton of them

then apply other effects like wind/gravity to them

There is no reason you cant generate an array or list of some sort with thousands of particles in it.

Because they typically dont collide or interact with many other things directly, they shouldn't have a huge performance hit? Or that's what I thought.  They are basically just basic simple moving sprites/images.  in a JGO sprite battle they could have something like 100k+ images colliding/bouncing around on the screen, with the best one and plenty with 10k-50k.

"Experience is what you get when you did not get what you wanted"
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline pitbuller
« Reply #3 - Posted 2011-07-09 07:53:59 »

Use pooling. Classes are fine if you dont create and destroy them whole the time.
Offline theagentd
« Reply #4 - Posted 2011-07-09 12:28:57 »

I recently experimented with particle systems. With 250.000 particles I get 62 FPS on a laptop with an i5-2410M and a Geforce GTX 460M.
 - Lifetime of 100 frames.
 - Gravity and fake air resistance.
 - Bounds checking to bounce particles on window edges.
 - They are drawn drawn as colored smoothed points.

Using a glPointSize up to 12 or 13, my test is CPU bottlenecked. The slowest part is actually filling the data buffer with particle positions+colors to submit using glBufferData, as it involves calls to native functions. Also, by load balancing between 4 threads (I have a dualcore with hyperthreading) I get a 2.2x performance boost (28 fps with one thread). I use pooling. NOT using pooling is actually faster by a pretty large margin, but produces HUGE hitches due to the GC.
Basically, if you only want a few thousand particles you shouldn't really worry much.

Myomyomyo.
Offline Rejechted

Senior Member


Medals: 1
Projects: 1


Just a guy making some indie games :D


« Reply #5 - Posted 2011-09-07 15:48:19 »

I recently experimented with particle systems. With 250.000 particles I get 62 FPS on a laptop with an i5-2410M and a Geforce GTX 460M.
 - Lifetime of 100 frames.
 - Gravity and fake air resistance.
 - Bounds checking to bounce particles on window edges.
 - They are drawn drawn as colored smoothed points.

Using a glPointSize up to 12 or 13, my test is CPU bottlenecked. The slowest part is actually filling the data buffer with particle positions+colors to submit using glBufferData, as it involves calls to native functions. Also, by load balancing between 4 threads (I have a dualcore with hyperthreading) I get a 2.2x performance boost (28 fps with one thread). I use pooling. NOT using pooling is actually faster by a pretty large margin, but produces HUGE hitches due to the GC.
Basically, if you only want a few thousand particles you shouldn't really worry much.

I assume this is a lot slower if you are drawing textured quads instead of points.  What do you mean by the GC?

Blog for our project (Codenamed Lead Crystal): http://silvergoblet.tumblr.com
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #6 - Posted 2011-09-07 16:20:49 »

Are you rendering large GL_POINTs? Those have never been fast in my experience, textured quads would almost certainly be faster.

IMHO big particle systems should be done with vertex shaders, so you can just feed static data to be drawn. Dead easy for simple ones, and you can even add some basic collision/interaction.

Complicated particle systems that require lots of interaction or elaborate physics are probably best done on the CPU still, but I generally find these kind of system require much less particles so they're less heavy. Combining the two will get great results, eg. an explosion could be a big smoke effect (done on GPU) along with a handful of smaller sparks/embers (done on CPU with world collision).

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (37 views)
2014-07-24 01:59:36

Riven (38 views)
2014-07-23 21:16:32

Riven (26 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21

Zero Volt (50 views)
2014-07-17 23:47:54

danieldean (42 views)
2014-07-17 23:41:23

MustardPeter (44 views)
2014-07-16 23:30:00

Cero (60 views)
2014-07-16 00:42:17

Riven (57 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org 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‑gaming.org
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!