I really need to ask a few stupid questions. I played around with the terrain tutorials and they work nicely, also with my own heightmap class instead of the defaults. I checked the documentation for both jME2 and jME3, but I just cannot figure out, how LOD ist supposed to work.
When I use just one TerrainQuad like in the Hello Terrain it shows, but I cannot tell that any LOD operations are going on. In wireframe mode, the level of detail of the mesh always looks the same, regardless of the distance to the camera, until the triangles are clipped in the distance.
What I would like to do is set up a huge landscape with many TerrainQuads and some LOD handling so that the landscape is generated dynamically or the level of detail is increased as the camera gets closer. I understood that you can set up a huge landscape with a hierarchy of TerrainQuads, but I could not figure out how to do any of that dynamically or how to control LOD operations or even make them work.
Also it appears that the size of the Terrain is directly dependent on the size of the height map, so it would change size if the level of detail increases?
How are the TerrainQuads in a QuadTree positioned?
I have the impression that I am somehow missing major pieces of the concept. I have quite some experience in game programming with openGL 1.1, but none with an engine. This beats me at the moment. Could you explain the larger picture please?
In jME3 you just need to add a TerrainLodControl to the terrain to enable lod:
TerrainLodControl control = new TerrainLodControl(terrain, cameras);
Check the tests in jme3test.terrain for more examples.
You only want to use one terrain quad, it will split itself into small terrain quads until they hit the size limit that you specify (patchSize) then it creates terrain patches. The terrain patches hold the actual geometry. This way when the LOD level changes the edges of the terrain patches can seam themselves together.
The size of the terrain is directly related to your heightmap. If you supply a smaller heightmap it will only fill in part of the terrain and the rest of the points of the terrain will be at height zero.
You will have to create a large enough terrain to see the LOD changes happen.
The size of my TerrainQuad/HeightMap is 2049x2049, Shouldn’t that be large enough to trigger LOD handling? Still, I see no LOD reaction, in wireframe mode the plain just merges into a solid green horizon when seen from a low camera angle or a solid green plain when seen from high above. It still has all triangles when they are clipped individually. The LOD ist instantiatet exactly as you describe, basically it is a modified HelloTerrainAdvanced example.Is there a way to influence the LOD calculation? How can I go about debugging this?
As for the concept: So I have to provide the full heightmap with all details from the beginning? That basically rules out the idea of creating an “endless” terrain and instantiating and detailing the parts as you get closer. Would it be feasible to cheat and put two terrains with different level of detail on top of each other to get a horizon that does not only look less detailed ( as I guess it would if LOD did work) but actually has less data behind it?
the current GSoC is in its decision session. One idea is to implement endless terrain and I even think that Sploreg is already working on it. Not quite sure though.
And another thing: Are using alpha-3? It is encouraged to update to the latest svn. There were some changes and bugfixes in LOD-calculation after alpha-3 which were very important.
I was not using Alpha3 but a nightly build from about 2 weeks ago. Anyway, i updated to the latest SVN - no change.
When you start jme3test.terrain.TerrainTest of the latest nightly you don’t have LOD going on??
Ok, found it. The HelloTerrain and TerrainTest examples work, but I started from TerrainTestAdvanced and for some reason, the line terrain.addControl(control); was commented out there.
So now that it works is there any way to control what LOD does?
What do you mean by control what the LOD does?
The default LOD algorithm is the Distance Lod Calculator that just bases the LOD level based on the terrain patch’s distance from the camera.
A more advanced and better looking method is to use the Perspective Lod Calculator; it uses the terrain’s entropy to calculate LOD.
I mean: I somehow expected there would be parameters e.g. to tweak at what distance the LOD changes.
I looked a the Perspective Lod Calculator, but I can’t figure out how to use it with the TerrainControl.
The perspective lod calculator manages the lod for you based on pixel error. Just change pixel error and it will affect when the LOD changes.
For the distance lod calculator, just give it a new SimpleLodThreshold and set the distance on that. SimpleLodThreshold calculates the lod level based on a distance factor and the terrain patch size. You can create your own LodThreshold and pass that into the DistanceLodCalculator to customize it some more.