Not so long ago, we made a moon creation system. Our goal was to create moons similar in size and composition to those existing in our solar system. The main difficulty was to obtain the vast surfaces of such moons and their insides, so that while they remained interesting. In addition, we needed the moons to be rendered with clear details, regardless of the distance to them.
The system assumes that the moons have a spherical base. The creation of a geodesic mesh is applied to the base sphere, which guarantees the same area of all parts of the surface. The system applies this structure only as a computational grid for procedural generation; the real surface of the moon will be much smoother than the generation grid.
Geodesic sphere
To get small, jagged moons, basic geometric shapes are distorted by low-frequency 3D noise.
Noise-distorted Surveying Sphere
Starting with this foundation, the system uses a series of concentric shells. Each cell determines the volumetric characteristics of the subsequent concentric shell. The outermost shell defines the surface properties of the moon.
Concentric shell
Each cladding may be distorted by the low-frequency 3D noise unique to that cladding. If you choose this generation option, then the inner shell may even be larger than the outer one.
Shell distortion
In the above diagrams, the distance between the shells and the amount of distortion are exaggerated in order to more clearly show the construction process. In practice, the shells will be much closer to each other, and the magnitude of their distortion will be proportionally smaller.
Below we will talk about how to create the outermost shell. The same principles apply when creating inner shells, so we will not consider them in detail.
A procedural moon system requires a real-time component and an offline component. The real-time component runs on the player’s computer. The offline component runs on the game developers computers. The offline generation component creates information that can be quickly supplemented with a real-time component.
Each vertex in a spherical shell is classified as belonging to one separate biome. A biome is a set of surface properties, including: height, distribution of materials, placement of specimens, and coloring of materials.
Biome Example
Biome information contains entropy-rich properties, such as craters, dry seas, surface cracks caused by gravitational tides.
Large crater recorded in biome information
The definition of the biome also contains rules for the placement of objects that determine the location, frequency and randomization of small parts - stones, cobblestones, ledges, etc.
Rock Instances
Each biome is created from elements placed by tiles (tiles) so that the real-time component can apply the same information to different parts of the moon, as well as to other moons. Biome information should be generated in such a way that rapid distortion and rearrangement is possible, thereby reducing the number of repeating and predictable environmental patterns.
The system uses two types of biome tiles: transitional and isolated.
Transitional information of biomes occurs in areas where the biome goes into the neighboring biome. Isolated biome information occurs in areas where the system guarantees the absence of neighboring biomes.
These two separate modes are necessary because some elements of biomes, for example, craters, can only be located in areas where the biome does not transfer to another biome, because transitions between biomes can affect the height profile and appearance of relief elements.
Below is a simplified example of the moon, which uses three different biomes: polar, tropical and equatorial, colored respectively in red, blue and green.
Moon with three biomes
Areas with an isolated biome have a uniform color; in areas with transitional biomes, colors mix.
The system uses a set of pre-calculated noise to introduce variability into the transition zones between biomes, creating interesting, unique transitions from one biome to another.
Procedural noise applied to transitions between biomes
In the images above, the size of each portion of the biome is exaggerated relative to the size of the moon, to more clearly show the technique for creating biomes. A separate biome site will cover an area of approximately 10 by 10 km. A moon with a radius of 1,500 km will have a surface area of 30,000,000 km
2 . To cover this surface would require nearly 300,000 such areas.
Resolution of the biome grid for the moon with a radius of 1,500 km
Resolution of the biome network can lead to a very large number of biome sites. The system will not track each of them individually, because the location of each site can be analytically calculated. A biome for most sites can be assigned from a high-level biome map.
High-level biome maps determine the key characteristics of moons when viewed from a great distance. The system uses these maps to generate additional details in closer forms, preserving the uniformity of the moon's definition when viewing from different distances.
High-level biome maps are 2D images that can be placed on the surface of the moon using 2D parameterization. Each point of the map contains a numerical identifier of the biome prevailing in the corresponding location of the surface or inner shell.
2D biome map
The image above shows a map with four different types of biomes (blue, red, yellow, and white). The image is superimposed onto the sphere using 2D parameterization. One possible parameterization is shown below:
2D parameterization for biome ID map
In addition to the biome identifier map, the system allows the use of other maps, for example, containing heights and surface colors.
Long distance moon shade and rendering
One pixel in each image can cover 4 km
2 , making their creation cost-effective. Such height and color maps can be generated procedurally or drawn by artists. In a project that uses only a dozen moons and where each moon must have rich and unique natural properties, it is best to use the work of artists at this stage.
The image below shows the process of generating a shell surface height and other properties:
Three scales used to build the moon
The moon will consist of at least one spherical shell. If there are several shells, then the system extrudes the inner shells based on their maximum radius and the function of the shell height, which is obtained by performing the process with different scales described above.
For each shell, the moon designer creates a high-level map of the distribution of biomes, the definition of biomes for the biomes found on this map, and the definition of the materials found in this biome.
The system considers air to be an acceptable material, so it can be used to create cavities in any shell.
Cross section of the relief of the moon, on which various shells are visible
A separate shell can also be a volumetric object, the depth of which is set by a stack of materials. Stack information is stored in a biome.
A stack of materials made up of six materials
Since underground materials rarely come to the surface, they can be described with much lower resolution than surface materials of biomes, and the use of local procedural noise will remain invisible to the player.
The functionality of the material stack may be enough for layout, because some materials in the stack can be quite rare. The biome designer can customize the prevalence and pattern of any material on the stack.
Procedural generation is performed by GPU shaders and voxel CPU algorithms.
The shader calculates the color of the fragment for each of the three scales and mixes these samples depending on the distance between the camera and the fragment.
All parts that are too small to register in the geometry. but still affecting the perceived complexity of the surfaces, they are recorded in normal maps generated in real time based on the procedural determination of materials, biomes, or high-level maps for determining the moon. Due to this, a low number of polygons is maintained in the scene.
You have to pay the price for that, as long as the moon is visible in the camera, the biome and high-level definition maps must be stored in the GPU. You can use selective loading of only those mip-textures that are necessary for rendering the current scale of the moon. The total amount of GPU memory required is reduced to a minimum due to streaming loading and unloading from the GPU when changing the observer's position.
When, due to the proximity to the camera, individual elements become large enough, they begin to appear in the output of the geometry using real-time voxel generation. The same applies to all parts of the moon terraformed or dug by players. If the changes are large enough and can be observed from orbit, the adaptive scene manager Voxel Farm increases the level of detail (LOD) of all areas, the change of which the application considers important.