Brand new Lod Generator

I’ve been playing around with Level of Detail lately.

As you may know (or not), JME 3 meshes supports lods as long as they are generated. There is also a LodControl that allows you switch the lod according to the distance to the camera.
In JME lods are implemented as several index buffers that provides different ways of connecting vertices in a mesh.
The only way until now to generate lods on an arbitrary model was to import it in the engine through the Ogre pipeline and use the advanced conversion to j3o to generate the lods.
This process uses Ogre’s command line tool in the background.

I wanted to allow users to generate lods from the SDK whatever pipeline they chose. So I went and look at ogre’s code.
I stumbled on this interesting thread where Peter Szücs a GSOC 2012 student describe how he enhanced Ogre LOD generation toward quality and performance…and provides an MIT licenced C++ code :D.

So I went and “translated” this to Java. I’m pretty happy with the result.
Here is Jaime with around 60% decimation. the left one is generated with JME and the “new” algorithm the right one is generated with ogre command line tool
Ok…they both have a tooth problem, but the left one doesn’t have bat wings and the texture is not distorted along the seams.
Note that the original model has 5108 triangles.
I don’t even know if this algorithm has been merged to Orge 1.9 version.

So enjoy, you now have a LodGenerator class to generate lods for any model. For now it’s only a utility class in the engine, a SDK tool will come later.
usage is

            LodGenerator lodGenerator = new LodGenerator(geometry);
            lodGenerator.bakeLods(LodGenerator.TriangleReductionMethod.PROPORTIONAL, reductionvalue1,reductionvalue2);

TriangleReductionMethod is the way to consider triangle decimation. Proportional is a percentage, Constant is an arbitrary number of triangle, Collapse_Cost is base on the aesthetic cost of collapsing a triangle. I encourage you to read the references pointed in the javadoc to understand all of this.

the above example will generate 3 lod levels : the first is the original index buffer, and the 2 others will have respectiively a reduction of reductionvalue2 and reduction value 2.

for example :
LodGenerator lodGenerator = new LodGenerator(geometry);
lodGenerator.bakeLods(LodGenerator.TriangleReductionMethod.PROPORTIONAL, 0.1f,0.5f);
the first one will be a version of the mesh with 10% less polygons, the second a version with 50% less polygons.


very nice :)! definitely heaps of improvement

The new one looks so much better, and since LOD is for far away the silhouette shape is what really matters - and the new one preserves it much better.

  • it’s not dependant on the ogre pipeline.

Really nice :slight_smile:

The class is actually easy enough to use, we should add a SDK action before release…

and where i can find this class now?

@normen said: The class is actually easy enough to use, we should add a SDK action before release..
ok I'll add it
@eraslt said: and where i can find this class now?

I’ve added the LodGenerator tool to the SDK.
Here are some screens to describe the process.
Hopefully that’s clear enough.

Model is courtesy of @mifth

EDIT…yeah i made some typo in the reduction explanation, I’m gonna fix it


Really nice work :slight_smile:

Does this have a wiki page yet?


Ok Novice question here. How can I get this to download in my SDK?

I have the RC2 SDK and I have selected the SDK nightly plug-in to be downloaded. However I cannot find this option in my right click menu also I don’t see it in the library either?

Could someone help me with what could be the issue?

I have installed a new copy of the SDK and I have the option available but when I attempt to apply the lods it does not generate the lods.

Not sure you can get it from nightly. You can pull the repo (preferably the 3.0 branch) and build the engine from it.

However still it’s a standalone class so you can just grab it from the source and use it.


I have install the current JME SDK installer and installed it. If I right click on my mesh I get the option to create the lods. I enter the proportions I want and when I click finish nothing happens. I still only have my main mesh in the lods list.

Well some mesh can’t be simplified with this algorithm…For example the elephant we have in the test models can’t be. Usually already triangulated mesh with very few polygons.
could you post a screen shot of your mesh (in wireframe mode)

Here is the model wireframe.

Here is the mesh after being imported to JME.

could you upload it somewhere, so i look into it?
an obj format, or mesh.xml


I just Pmed you a link.