0
\$\begingroup\$

How one generates procedural terrain is pretty straight forward. But once you setup your terrain you don't really have a fine level of control where which details will go.

One solution I can think of is to store rules as functions, i.e. Square, circle, etc., which will override rules in the area. For example, in mountains terrain we could place a function which will make them flat or terraced.

What I have trouble figuring out is how to store those functions (assuming terrains can be in principle infinite or at least planetary scale). Should they be placed within existing coordinate system, or stored locally to terrain ?

I seen something like that done in Star Wars Galaxies, but it's really hard to find any details about implementation of system.

\$\endgroup\$
1
\$\begingroup\$

I would recommend you to use a functional and hierarchical model. Have terrain generator functions which either generate a requested chunk of terrain geometry themselves or delegate parts of it to other terrain generator functions.

A terrain generator function should take these parameters:

  • parent: terrain it is generated from
  • seed: the random number generator seed for the sub-terrain it should generate
  • quad: the three-dimensional chunk the terrain is supposed to fill.

The root generateTerrain function for the whole world would determine the type of terrain for each chunk, and then call the appropriate function to generate it, like generatePlainTerrain, generateMountainTerrain, generateOceanTerrain, etc.

Those functions would then either generate the requested quad of terrain geometry according to their own rules, or could also delegate parts of the terrain to further terrain generation functions. So the generatePlainTerrain function could choose to delegate a small part of it to generateVillage which then delegates to generateHouse which then delegates to generateBedroom.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.