JMonkey Performance Test

Originally when I stumbled upon JMonkey, I thought “wow this game library is awesome”.  I spent some time playing around with it and decided that it was perfectly adequate for what I wanted to do, while allowing me to write all my little projects in Java for quick turn around time (number one goal for a short attention span).

After trying a couple projects (including the previously posted Map Generator) I started to see performance issues.  I wanted to make sure they weren’t related to JMonkey/OpenGL throughput issues, so I decided to do a little performance testing.

First thing I noticed was, most of my “Cube based” experiments were limited by the number of cubes placed in the scene graph.  As this number approached 100k, performance started to drop significantly.  With 12 triangles being rendered per cube, this was showing me that the triangle throughput seemed to be around 1.2million.  Still, 1.2million triangles per frame at around 20 frames per second was better than I thought I was going to achieve with Java but I thought some of my ideas might need more than that.

Many things could be causing this slowness in my first experiments:  material changes, number of objects in the scene graph (slow traversal), number of draw calls.  To improve upon these I started looking into JMonkey batch nodes and GeometryBatch Factory.  These had a small effect on performance, but I still wasn’t sure I’d capped out on the potential here.

Yesterday I set out and wrote a “simple voxel renderer” to test getting as many triangles in a single object as I could (to eliminate the material and scene graph traversal bottlenecks).  The quotes are used here because I’m doing lots of things incorrectly (I’m still rendering hidden faces between cubes) so it’s actually a direct replacement for drawing thousands of separate cube objects on screen.  I implemented a simple texture atlas (not obvious from the screen shot below) and tried pushing my implementation to the limits.

As is usual with the things I’ve created so far, I first started with some random map building algorithms.  I tried starting with a solid block and creating tunnels (this looked pretty terrible), I created a bunch of platforms with stairs between them (looked a little better, but didn’t let me test the onscreen cube limit without just looking like a simple solid cube).

I finally decided on creating a sphere.  Why?  It looks cooler than a giant cube… that’s about it.  On to the performance!

With all my triangles batched into a single object, I capped out (using the 20 frames per second result seen previously) at 11 million triangles in a scene.  I chose a more interesting camera angle in the screen shot, but frustum culling is off so performance was the same with the sphere completely within the viewport.

This solution was getting roughly 10 times the max performance I was getting out of the previous solution.  I’m confident that I can continue using JMonkey (as I was looking for higher frame rates with 1 million triangles or less).  Now, feast upon the screenshot!

This sphere is made up entirely of cubes built from a Voxel grid (hence the pretty crazy Moire patterns here).

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>