Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (108)
games submitted by our members
Games in WIP (536)
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  
  Practising with fireworks  (Read 2729 times)
0 Members and 1 Guest are viewing this topic.
Offline Varkas
« Posted 2013-01-29 16:49:57 »

I wanted to play a bit with particle systems, also the new (for me) java.util.concurrent classes. So I made a little multithreaded fireworks demo.



On my notebook drawing semi-transparent images is really slow. I suspect that with other graphics hardware it will be better. The other thing that bugs me is that despite threading, I could not get to 100% CPU, so my threads sleep/wait too often.

The demo will try to move as many particles as possible while retaining 30 FPS. On my notebook the screen looks a bit empty, but maybe you can get more out of it Cheesy (33kb executable jar file).

http://www.java-gaming.org/user-generated-content/members/132627/fireworks-r3.jar

if (error) throw new Brick(); // Blog (german): http://gedankenweber.wordpress.com
Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #1 - Posted 2013-01-29 17:00:10 »

This looks good. Smiley I got 13k particles on spikes, and about 50% CPU usage. I have a quad-core processor.

Offline Varkas
« Reply #2 - Posted 2013-01-29 17:13:24 »

Thanks for the feedback Smiley

13k particles should give a good firework impression. Some day I want to make more colorful and more detailed particles. But I'm afraid Java2D isn't the right tool for that.

if (error) throw new Brick(); // Blog (german): http://gedankenweber.wordpress.com
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #3 - Posted 2013-01-29 17:32:44 »

Cool Smiley

Got 6k particels at max, but 25% cpu Tongue.
Nice stuff for java2d.
Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #4 - Posted 2013-01-29 17:35:05 »

I'm afraid Java2D isn't the right tool to make more colorful and more detailed particles.

Well... persecutioncomplex I don't think so either! Most of us have GPU's though. Pointing

Offline theagentd
« Reply #5 - Posted 2013-01-29 18:09:26 »

23-24k particles here, around 37.5% CPU usage (100% on 3 cores I guess). If you're interested, I've made a few particle engines using different techniques (all using LWJGL though). If you search around the forum you can check them out if you want. One of my first ones used all available cores in your computer to update particles and can render 2 million particles at 60 FPS with 95-100% load on my hyperthreaded quad core (8 threads). It's actually RAM bandwidth limited, so that number would probably bump up a bit if I got some faster RAM for $40 or so.

Myomyomyo.
Offline nsigma
« Reply #6 - Posted 2013-01-29 18:32:34 »

The demo will try to move as many particles as possible while retaining 30 FPS.

That logic doesn't seem to work for me - ever increasing particle count and ever decreasing framerate - 30k particles at 1 FPS!  Grin

Are you using drawImage() for this?  From multiple threads?  There's quite a lot in AWT that is single-threaded so could be causing contention.

Would you be willing to share code for this?  I'd be interested in converting to run on the software pipeline in Praxis to see what performance is like there for comparison.

This old thread has various blendmodes for working directly with pixel arrays (as used in Praxis).  Additive is quite good for particles. http://www.java-gaming.org/topics/some-new-blendmodes-add-multiply-overlay-etc/24529/view.html

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline Varkas
« Reply #7 - Posted 2013-01-30 12:14:58 »

If you're interested, I've made a few particle engines using different techniques (all using LWJGL though). If you search around the forum you can check them out if you want. One of my first ones used all available cores in your computer to update particles and can render 2 million particles at 60 FPS with 95-100% load on my hyperthreaded quad core (8 threads). It's actually RAM bandwidth limited.

Memory accesses are quite expensive indeed. I assume my own demo makes very bad use of cache and memory, many scattered reads and writes.

There are truly amazing particle engines, but in this case it's less the particle management but the drawing which is the bottleneck. I could use BufferedImages and write directly into the buffer like my raytracing demo does, but I wanted to use Java2D functions this time.

At the moment I'm trying to get a feeling what is slow and what is fast, and what are good ways to display graphics with Java if one doesn't want to bundle extra libs.

I have a demo which might look a bit better and might have better frame rate control, but it's hard to guesstimate if this code will adapt well to other machines:

http://www.java-gaming.org/user-generated-content/members/132627/fireworks-r3.jar


if (error) throw new Brick(); // Blog (german): http://gedankenweber.wordpress.com
Offline ClickerMonkey

JGO Coder


Medals: 20


Game Engineer


« Reply #8 - Posted 2013-01-30 12:29:05 »

Not too bad! You should consider more complex effects... like a particle effect that shoots up and has a particle trail and when it reaches the end it explodes. You could also have the particles that shoot out of that explode as well (much like actual fireworks).

The fountains are fun particle effects, but they're way too slow for compared to actual fireworks.

Source: I'm a firework

Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #9 - Posted 2013-01-30 12:39:10 »

Source: I'm a firework

Awesome. Never met a.. firework, before.  persecutioncomplex

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline theagentd
« Reply #10 - Posted 2013-01-30 14:18:22 »

Quote from: Varkas link=topic=28596.msg260624#msg260624
I have a demo which might look a bit better and might have better frame rate control, but it's hard to guesstimate if this code will adapt well to other machines:

http://www.java-gaming.org/user-generated-content/members/132627/fireworks-r3.jar
The new one won't go over 13k particles, so there's no way to say if it's better or worse than the old one.

Myomyomyo.
Offline Varkas
« Reply #11 - Posted 2013-01-30 16:44:14 »

I've been trying to have it going smooth rather than fast. But it's alright, it's been an experiment and I'll let it rest now. I've learned a bit again, and want to work on a different project next, which was on hold for more than a year ... oh well. I just have too many ideas. I really must convince myself not to try to make an action RPG in low-graphics style in addition to all the other projects.

And I must look into music, what tools are nowadays used. I want to make a new raycasting demo with music and movements choreographed together - but the last time I tried to compose something was in the early 1990's when MOD files were popular and trackers were the tool of the trade ( http://en.wikipedia.org/wiki/Soundtracker#1990s_and_the_PC )


if (error) throw new Brick(); // Blog (german): http://gedankenweber.wordpress.com
Offline Varkas
« Reply #12 - Posted 2013-02-04 12:23:38 »

I've been trying to replace painting semi-transparent images for the glow effects with direct data buffer accesses and my own blending methods. I'd have expected that the standard Java implementation (which can use low level C libraries) is at least as efficient as my pure Java solution, but for some strange reason it isn't.

Latest version with above mentioned changes, and an upped particle limit (should max out at 26k particles, and still be more CPU efficient than before):

http://www.java-gaming.org/user-generated-content/members/132627/fireworks-r4.jar

Edit: seems I have a race condition in the threading code which shows up more frequently now that the painting got more efficient. If the demo doesn't start or locks up, just kill it and start it again ...

Edit: Now also with less Math.sqrt ... (don't ask, I just had a brain fail when I coded that)

http://www.java-gaming.org/user-generated-content/members/132627/fireworks-r5.jar

Edit: If I have to do my own shading for the glow anyways, I can let the shading change with particle age ...

http://www.java-gaming.org/user-generated-content/members/132627/fireworks-r6.jar

if (error) throw new Brick(); // Blog (german): http://gedankenweber.wordpress.com
Offline Regenuluz
« Reply #13 - Posted 2013-02-05 07:50:52 »

I get ~21k particles and a steady 30fps. Smiley (With the r6 version)
Offline Varkas
« Reply #14 - Posted 2013-02-05 10:50:34 »

Good to know Smiley

I've been finetuning my blending routines, and tried to balance the threading better. It should consume less CPU time now while showing a bit more particles than before. No big change in particle numbers though.

http://www.java-gaming.org/user-generated-content/members/132627/fireworks-r7.jar

if (error) throw new Brick(); // Blog (german): http://gedankenweber.wordpress.com
Offline Regenuluz
« Reply #15 - Posted 2013-02-05 11:29:14 »

I'm getting 22k particles with r7, and ~103% cpu usage, the r6 gave me ~145% cpu usage. (Dual core with hyper threading, so I guess 1 core and 1.5 cores?)

It's looking good though. Smiley
Offline theagentd
« Reply #16 - Posted 2013-02-05 14:51:37 »

Averages at around 10% CPU load now.

Myomyomyo.
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.

CogWheelz (16 views)
2014-07-30 21:08:39

Riven (22 views)
2014-07-29 18:09:19

Riven (14 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

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

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

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

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

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
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!