Performance increase from soft particle code

I discovered a strange increase in fps performance after I copied and pasted the code from the soft particle example (lines 95-98) and later removed it but inadvertently left in

FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
TranslucentBucketFilter tbf = new TranslucentBucketFilter(true);
fpp.addFilter(tbf);
viewPort.addProcessor(fpp);

in simpleInitApp(). I am working on using a bunch of quads to give the illusion of volumetric clouds and since the performance difference is definitely not insignificant, Iā€™d like to understand why the above code affects performance even though Iā€™m not using any translucent objects nor any soft particles.

Without the code:

With the code:

Given that the code isnā€™t really doing anything if you arenā€™t using the translucent bucket, itā€™s easy to be skeptical that something else isnā€™t going onā€¦ especially when we canā€™t see anything else.

Also, how many times did you test one versus the other? How consistent are the frame rates? etc. Iā€™ve seen that much swing before just when my GPU is overheatingā€¦ makes timing things lots of fun. See something slow. Make a bunch of changes, recompile, fix syntax errors, recompile, run again (GPU has cooled down) get an extra 100+ FPS. Eureka! think Iā€™ve discovered something only to find I havenā€™t.

So, we probably need more information.

Edit: also given that the two views are clearly different. Something has changed from one to the other. Make sure you use consistent randomness so that the view is the same every time.

Iā€™ve cut down my code to its bare components and found that those four lines and the drawing of the quads are the only things that affect the performance. The performance difference is very consistent (except for when I force Java to use integrated graphics: then both get 29 fps); Iā€™ve tried running one right after the other, running them with the computer under various loads, and comparing them both the computerā€™s startup and after hours of computer use. I removed the randomness and got the same results (though performance diminished for both, the difference is still there):

Without the code:

With the code:

Well, thanks for testing it consistently. Itā€™s very strange.

ā€¦maybe we should all be adding the magic filter to our code. :smile:

What does ā€˜and the drawing of the quadsā€™ part mean? You mean when you changed from random to consistent or is there another difference than the four lines in the two images?

Is the term Iā€™m looking forā€¦ rendering? By ā€œdrawing of the quadsā€ I guess I mean the number of quads rendered (?).

edit: thatā€™s actually a great ideaā€”what happens if I add all of the magic filters? :smiley:

Iā€™m looking for all of the differences between the two pictures. If the number of quads rendered is the same then thatā€™s not a difference and doesnā€™t affect the performance difference between those two images.

ā€¦and the stats indicate that the triangle count is the same. I just wanted to make sure that there wasnā€™t any other difference.

Yes, youā€™re correct! The only thing Iā€™m changing between tests is whether or not I comment out those four lines. Everything else is untouched.

Update: other filters have a similar fps boost effect.

ColorOverlayFilter,
ComposeFilter,
FadeFilter,
PssmShadowFilter,
and TranslucentBucketFilter increase the performance the most (but only when used individually), while other filters like BloomFilter and CartoonEdgeFilter have a higher fps than without any filters at allā€¦ strange!

P.S. this is a great learning experience for me: I had never used WaterFilter before and it looks good

When you run, do you have AA turned on in the settings dialog?

I used setSamples(16) on the AppSettings. Is that the same thing?

Yes. Donā€™t do that and see if you get the same performance difference.

Guess: since you donā€™t set the number of samples on the filter post processor then you are effectively turning AA off whenever you have any filters.

1 Like

Your guess was right on, @pspeed! Thank you so much for your help. I guess there are sacrifices for better performance.

Have a great day, and I love your engine,

Lars

A blind shot out of pure theory.

Standard particle emitter doesnā€™t sort particles, and they are rendered with no depth test so there is a lot of overdraw.
With soft particles enabled, a sort of depth test is performed in the shader and irrelevant pixels are discarded, which dramatically reduce overdraw.

This only stands if depth write is enabled for the particles though, and I canā€™t remember if itā€™s the case by default. Also I guess the transparent nature of the particles kind of defeat that argumentā€¦ Reallyā€¦thatā€™s strangeā€¦

EDItā€¦ok didnā€™t read all the postsā€¦ So it was AAā€¦:stuck_out_tongue:

Except we already solved the problem.

For once someone was complaining that his game got faster all af a suddenā€¦ Thatā€™s a first :stuck_out_tongue:

5 Likes