I really can't think of any huge performance boosts other then switching to opengl. You have to create a bufferedimage, get its pixels, edit the pixels, and then set them back onto the bufferedimage. It is just slow. The only way to get an reasonable performance is by drawing the image at a lower resolution, filtering it, and then redraw at the original resolution.

You can not get the pixels from a graphics object. That is why it is slow. If you could, you could do all sorts of cool effects. I have to create a buffered Image and to draw to and to perform the filter on. But this is sped up a bunch by using a VolatileImage and drawing with its graphics object then using the getSnapShot() method to draw onto a scaled down bufferedImage which is then filtered. I get reasonable performance with this.

Check this code out.I made a little Applet with a similar particle effect(just some bouncing particles)Increase the number of particles to see how the speed behaves.I limited the framespeed, to keep it steady with different amounts of particles.

Keeps my cpu usage at 25% cant go higher without multithreading. Interesting way of doing things. My effect would be greatly diminished if I did not scale down the size. By scaling down the size, it makes the effect more exaggerated and much faster but you lose quality.

The JHLabs filters don't offer very good performance for animation. They go through various hoops to keep the BufferedImage from being unmanaged - which is a pointless exercise when you're updating them every frame. You should create 2 BufferedImages too, otherwise the filter will create a temporary image and do an unnecessary copy every frame. You should also probably not use the createCompatibleImage() method for this either, as the filter is converting the data to ARGB.

Your best bet is to create 2 ARGB BufferedImages, grab the data arrays like @Damocles suggests, and fork the filter code so that you can pass in the input and output arrays rather than BufferedImages. That should speed things up a bit.

Maybe he referrs to my example code.I know that single dimensional arrays are quicker. (around 30% for the pure lookup logic)But I find that is an optimization that can be done in the end. During coding I see multi-dim arrays as much nicer to read and edit.

Things like making a multi to a single array is just mechanical optimization when cleaning up the program.

the main point of the example was to show how much faster direct pixel manipulation is

When I said 25% cpu I meant that is what your app was running at. I try to keep my stuff running around 5-8% cpu or lower. Currently, this bloom filter runs at 7-15 depending on how many particles there are. I changed the filter so it takes int[] of the pixels and outputs int[], this has sped things up a little I am very impressed. I am still really new to a lot of more complex things when it comes to coding. Here is what I have decided to make after having some fun with this thing.

Its all done without any images and is very small. Kinda break it styled. Very hard to play because there is so much going on. Lots and lots of glowing particles to distract you from the glowing ball.

So everyone who's ever done a tutorial or answered a question about making tilemaps is insane?

Do you mean I should do it with a 1D array and treat it as a matrix

I certainly believe not all tutorials uses multi-dimensional arrays, but I get the sentiment.

There's a ton of tilemap-implementations, and you can do it however you want. Using a single array is just more of a pain to implement versus the time spent. It's not worth it, unless you're looking for a tiny optimization. Mostly, you aren't. The only "real" difference is the lookup time (it's about double in the multidimensional), but it doesn't really make a difference unless you're quering a lot!

Thanks for clearing that up. I was afraid I was in for a terribly confusing rewrite of my level-system

But since you're querying all tiles in the tilemap (within the screen and all that) every update, wouldn't it be a big optimization considering it takes half the time to do each look-up with a 1D array?

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