I was asked to port here another topic about an infinite procedural terrain generator. I guess I have to explain it in a few words.
I’m just learning to use jME3, just found it a few weeks ago. I have a game idea in my mind and was happy that I don’t have to write everything from the bottom up, instead I can build on a stable engine, and take care of the main concepts. The first thing that was important for me, is to be able to generate terrain content on the fly, sometimes for different regions of the game, sometimes I need different terrain for different users, etc. I’m not as good in designing as in programming, also I do not have a designer yet, and my plans are that I will need so many terrains, that it’s not possible to be designed or even stored.
So I found out about procedural terrain generation, which uses noise functions and fractals, that can be defined by a few parameters, and then asked for a value at a given point. There are some rules for these functions that make it reliable, such that it will always generate the same output for the same input. I already had some of these basis functions implemented - mainly ported from C examples - when I found jME. After looking around the tutorials and getting familiar with how to use it, I found the TerrainQuads which seemed to be the perfect spot to wire my functions in. But after playing a few days with it I had to face it, that the existing terrain implementation was optimized for pregenerated terrain data, which makes it possible to optimize the quality and speed when reading the data. This optimization I found too slow for realtime usage, so I created a small implementation based on the basic Geometry object. I designed to be as easy to be configured as possible, but it’s just the basics as far as I can see.
I have uploaded the code to my sourceforge svn and is available at: https://proceduralterra.svn.sourceforge.net/svnroot/proceduralterra
Increasing the terrain detail can introduce some lags when calculating the next terrain tile, this might be solved by applying some LOD features, as faraway parts of the terrain can never be reached. (It uses a 3x3 grid and the user is always in the actual tile’s center cell)
The current version is using the jME builtin terrain material, and is not responing well when generating the next tile. This means that the texture is reset, so the user can see it change where he’s standing, though the terrain model remains the same. It will be solved soon.
Generating terrain from functions can result in boring worlds, so I’m planning some improvements:
- the current heightmap will be interpolated with some other “heightmap” which will contain information about the average height in that region, so it will be possible to create plains, hills, mountains instead of the current hills are everywhere approach
- replace the current material with a new, that applies texture based on height + temperature + humidity maps. The temperature and humidity maps can be also generated using preparameterized functions, which can take into count the time factor, so an ever changing world can be created.
Thanks for your time, any critics and improvements are welcome