13
IN DEGREE PROJECT COMPUTER SCIENCE AND ENGINEERING, SECOND CYCLE, 30 CREDITS , STOCKHOLM SWEDEN 2019 Procedural Generation of Volumetric Data for Terrain HENRIQUE FURTADO MACHADO KTH ROYAL INSTITUTE OF TECHNOLOGY SCHOOL OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE

Procedural Generation of Volumetric Data for Terrainkth.diva-portal.org/smash/get/diva2:1355216/FULLTEXT01.pdf · of computer graphics and procedural content generation, and can broadly

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Procedural Generation of Volumetric Data for Terrainkth.diva-portal.org/smash/get/diva2:1355216/FULLTEXT01.pdf · of computer graphics and procedural content generation, and can broadly

IN DEGREE PROJECT COMPUTER SCIENCE AND ENGINEERING,SECOND CYCLE, 30 CREDITS

, STOCKHOLM SWEDEN 2019

Procedural Generation of Volumetric Data for Terrain

HENRIQUE FURTADO MACHADO

KTH ROYAL INSTITUTE OF TECHNOLOGYSCHOOL OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE

Page 2: Procedural Generation of Volumetric Data for Terrainkth.diva-portal.org/smash/get/diva2:1355216/FULLTEXT01.pdf · of computer graphics and procedural content generation, and can broadly

SammanfattningEn proceduell metod har framställts för att generera volymdata för terräng-er med hjälp av en höjdkarta samt information om terrängens material. Tillskillnad från tidigare metoder har följande nyttjat den omfattande forskningenkring genererad terräng. Det här genom att anpassa materialens lager till ter-rängens topologi. Metoden tillåter användaren att specifiera materialen somstratifierade eller eroderade, vilket genereras olika: stratifierat material stap-las och generar på så vis materialen i lager, medan eroderat material samlaspå jämn terräng. Vi jämför en termisk erosionsmetod med originellt tillväga-gångssätt som nyttjar användarinformation om terrängens lutning som en gen-väg till att generera eroderade lager samt presterar signifikant bättre. Fördelarsamt nackdelar med båda teknikerna utforskas och diskuteras.

Page 3: Procedural Generation of Volumetric Data for Terrainkth.diva-portal.org/smash/get/diva2:1355216/FULLTEXT01.pdf · of computer graphics and procedural content generation, and can broadly

Procedural Generation of Volumetric Data for TerrainHenrique Furtado Machado

School of Electrical Engineering and Computer ScienceKTH Royal Institute of Technology

[email protected]

Figure 1: Procedually generated volumetric material layers .

ABSTRACTA procedural method is proposed to generate volumetric data forterrain using a surface height map and information about materialsas input. In contrast to previous explored methods this approachtakes advantage of the extensive research on surface terrain gener-ation by adapting the material layers to the topology of the inputterrain. The method allows the user to specify materials as stratifiedor eroded, which are generated differently: stratified materials arestacked to generate material layers while eroded materials accumu-late on even terrain. We compare a thermal erosion method andan original approach that uses information about the slope of theterrain as a shortcut to generate eroded layers and performs signifi-cantly better. The advantages and drawbacks of each technique areexplored and discussed.

KEYWORDSprocedural terrain generation, volumetric terrain, thermal erosion,procedural modelling

1 INTRODUCTIONTerrain is often an integral part of virtual applications such asgames, feature film special effects and simulations. Creating land-scapes with a high level of detail can be a time consuming taskfor artists and developers, thus several techniques have been pro-posed to procedurally generate them. Using these techniques it ispossible to randomly create expansive environments in a matterof seconds. These methods have been explored both in the fieldof computer graphics and procedural content generation, and canbroadly be categorized as procedural-based, simulation-based orexample-based methods [Galin et al. 2019].

The use of procedural generation is even more relevant for ap-plications that require volumetric terrain - terrain in which thereis also information about subsurface materials - since the amountof data that has to be created is exponentially larger. The successof Minecraft 1, a game in which players explore a procedurallygenerated virtual world that they can dig through to find cavesand secrets underground shows the demand for techniques thatgenerate volumetric terrain.

1https://www.minecraft.net/

1

Page 4: Procedural Generation of Volumetric Data for Terrainkth.diva-portal.org/smash/get/diva2:1355216/FULLTEXT01.pdf · of computer graphics and procedural content generation, and can broadly

Input height map User generated material information Output terrain

Stratified layersgeneration

Erosion Simulation

Figure 2: Step by step of the proposed method.

In the literature, volumetric models for storing data are oftenused to improve surface terrain using erosion techniques [Mus-grave et al. 1989] or by adding interesting features such as archesand overhangs [Gamito and Musgrave 2001; Peytavie et al. 2009].However, very little has been explored regarding techniques thatgenerate volumetric material data for terrain, and the only methodpresent in the literature produces uninteresting surface terrain[Santamaría-Ibirika et al. 2014].

In this paper a method is introduced to generate appropriatevolumetric data that adapts to the topology of the surface terrainprovided as input. In order to achieve these results, two differentmethods are proposed to generate what are referred to as erodedmaterials. While the stratified materials form the layers that arestacked on top of each other to create the static part of the volu-metric terrain, the eroded materials accumulate on areas with eventerrain. To generate them, one of the proposed methods is a tra-ditional approach based on thermal erosion techniques, while theother is a novel technique that takes advantage of the derivativesof the terrain height to produce similar looking results with muchhigher efficiency.

2 RELATEDWORKThe research field of procedural content generation (PCG) investi-gates the algorithmic creation of content. It aims to allow content tobe generated automatically, and can therefore reduce the workloadof artists and designers [Hendrikx et al. 2013]. One of the mostimportant parts of any game is the terrain the user will traversethrough and sometimes interact with while playing. PCG of ter-rain, also known as procedural modelling of terrain, is a widelyresearched area [Smelik et al. 2014], and has been used in severalcommercially successful applications, such as games and movies.

2.1 Terrain GenerationSeveral methods have been proposed to generate andmodify terrain.These methods generally fall into three categories: procedural tech-niques, physical simulations and example-based methods [Galinet al. 2019].

2.1.1 Procedural techniques rely on algorithms which are nottrying to emulate geological processes. Commonly, these methodsrely on fractal models, attempting to mimic the fractal properties

that can be observed in large-scale terrain. This is often achievedthrough the use of fractional Brownian motion (fBm), where thesame base function is sampled with increasing frequencies anddecreasing amplitudes generating the so called octaves which arethen added together [Fournier et al. 1982].

The midpoint displacement and diamond-square algorithms arepopular examples of base functions that are used to generate octavesfor the fBm. These subdivision algorithms iteratively divide theterrain while adding random displacements on the grid that iscreated [Mandelbrot 1983].

Another popular option of base function for the fBm are noisefunctions [Lagae et al. 2010]. Since the introduction of Perlin noise[Perlin 1985], many different variations, improvements and ex-tensions have been proposed and used for terrain generation. Theoriginal Perlin noise andmost of its extensions are a type of gradientnoise, where the a grid of pseudo random gradients are generatedand the values between them are interpolated based on the dotproducts of the gradients on the nearest vertices.

Procedural techniques, although powerful and easily implemented,have several drawbacks. They fail to capture some characteristicsof real-world terrain, such as the structure of mountain ridges andother specific land forms. The generated terrain tends to be veryrepetitive and the lack of control means that the user must havetechnical understanding of the parameters to be able to modify thegeneration process in a meaningful way.

2.1.2 Physical simulations tend to focus more on modelling thesystems that generate and modify the terrain then on how it willultimately look like. The majority of simulation techniques focuseson erosion, that is, a processes that removes material from one areaof the terrain and moves it to another location. These are oftenused to simulate the effects of rainfall, wind, water streams andtime, and may be used in combination with procedural techniquesin order to improve the terrain generated by them.

Hydraulic erosion aims to simulate the effects of water, usuallyrain, on the landscape. The most common implementation worksby depositing droplets of water at random points of the terrain andallowing them to move through it while removing or depositingmaterial in the process [Olsen 2004]. The amount eroded by dropletof water during a time step depends on its volume and the amountof sediment it is already carrying. This type of erosion tends toform steeper slopes and larger valleys.

2

Page 5: Procedural Generation of Volumetric Data for Terrainkth.diva-portal.org/smash/get/diva2:1355216/FULLTEXT01.pdf · of computer graphics and procedural content generation, and can broadly

Thermal erosion is another commonly used erosion technique.The goal here is to simulate the weathering that naturally occurson real-world terrain where material is set loose and accumulatesat the bottom of steep slopes [Musgrave et al. 1989]. At each timestep loose material is moved from one point to another if the heightdifference between them is larger than a predetermined settlementangle.

Although the most prevalent topic in research, erosion tech-niques are not the only simulation methods that have been explored.Work has been done with the simulation of tectonic activity, bysimulating the mechanics of uplift to generate mountain ranges[Cordonnier et al. 2016; Cortial et al. 2019].

2.1.3 Example-based methods opt to use existing terrain infor-mation to guide the generation process and often rely on scannedheight maps called Digital Elevation Models (DEMs). Most com-monly, these methods select and deconstruct different terrain ex-emplars and blend the pieces together to form a coherent output[Zhou et al. 2007]. Most recently, machine learning approacheshave been explored through the use of adversarial networks: onethat generates terrain and another that guesses if an example is agenerated or a real DEM [Guérin et al. 2017].

2.2 Terrain RepresentationSeveral different models to represent and store terrain data havebeen used in the literature [Natali et al. 2013]. Historically therehas been a trade-off between the flexibility of the model and itsmemory cost.

2.2.1 Height maps are the most popular model used for terrains.They consist of a 2D discrete grid in which each cell contains thealtitude at a specific point. The memory cost is O(n2) where n isthe number of divisions on the square grid. While height maps arerelatively cheap and easy to use, they have drawbacks: height maprepresentations have no volumetric information and it is impossibleto represent caves and overhangs using them, which limits thepossibilities of the procedural generation.

Figure 3: A common visualization of height maps whereheight values are encoded into a gray scale and displayedas an image. Sourced from Olsen [2004].

2.2.2 Voxels (volume pixels) offer a solution to this problem.Instead of a 2D grid, the voxel model uses a 3D grid in which eachcell contains a material index. The memory cost, however, is much

larger, and a naive implementation will require O(n3) instead. Thiscan be improved by using Sparse Voxel Octrees [Laine and Karras2010] and other compression techniques [Kämpe et al. 2013], butstill performs worse than height maps memory-wise. The voxelmodel is widely used for physical simulation techniques such aserosion, providing much better results than height maps.

2.2.3 Layer representations arose from the observation that real-world terrain is structured in stratified layers. That is, usually, thereare few changes of material layers vertically. That means that it isnot necessary to store a big number of voxels if they all have thesame material index and come one right after the other. Instead, themodel can be organized in a 2D grid of stacks which are composedof layers of materials each with their own heights. This modellends itself particularly well for erosion simulation, combining thebenefits of the voxel model with the speeds that can be achievedusing height-maps [Benes and Forsbach 2001]. With a memory costof O(mn2) wherem is the maximum possible number of materiallayers in a stack, the space efficiency is very close to a height map,since most of the timem is orders of magnitude smaller than n.

As proposed by Peytavie et al. [2009] this model can representoverhangs and caves by treating air as another material, and havingair layers in between layers of regular materials.

RockSandStoneAir

Layer representation Voxel representation

Figure 4: Comparison between a cross section of the layerand a voxel representation of the same terrain. Air layersare used to represent empty space between material stacks.

Figure 4 shows a cross section of the same terrain in a layeredand a voxel representation. Due to discretization of space in alldimensions, some vertical material information can be lost whileusing the voxel representation, while the layer representation isonly horizontally discrete and can have layers of any size.

2.2.4 Subsurface geology representations are a collection of dif-ferent models for storing volumetric information about terrain thatare used by geological modelling tools. These are often focusedin accomodating different modelling approaches and giving theuser of the tool freedom to model. An overview of these modelingtechniques was compiled by Natali et al. [2013].

2.3 Volumetric Terrain GenerationAll of the generation methods mentioned on section 2.1 focus onthe creation of realistic looking surface terrains. The generation ofvolumetric data for terrain has notoriously not been explored inthe literature [Galin et al. 2019]. Most uses of volumetric data forterrain generation is with the goal of improving the surface terrainthrough erosion or with the presence of arches and caves.

3

Page 6: Procedural Generation of Volumetric Data for Terrainkth.diva-portal.org/smash/get/diva2:1355216/FULLTEXT01.pdf · of computer graphics and procedural content generation, and can broadly

Gamito and Musgrave [2001] introduce a method that applies awrapping function to height map modelled terrain to create over-hangs which are usually impossible with this representation. Pey-tavie et al. [2009] use the layer representation to create volumetricstructures and simulate the settlement of debris with an approachsimilar to thermal erosion.

In commercial applications it is common to see the use of higherdimensional noise functions to generate volumetric structures. Theproblem with this approach is that 3D noise functions have noknowledge of the physical restraints of the real world, and cangenerate unrealistic features such as floating islands and otherdisconnected structures. In most cases some post-processing - suchas connectivity tests - is required to ensure that the generatedlandscapes look realistic enough.

Another application of volumetric representation is for the gen-eration of procedural 3D cave systems. Most of the approachesinvolve carving a cave from a voxel representation of 3D space.Boggus and Crawfis [2009] present a method that mimics the struc-ture of real caves by modelling acidic water erosion. Mark et al.[2015] use a grammar-baser approach to generate cave structuresand a noise meatball technique to carve out navigable paths.

Santamaría-Ibirika et al. [2014] introduced the only techniquepresent in literature to procedurally generate volumetric terrain,focusing on the generation of individual material layers. Theirapproach uses designer input, where user must provide the systemwith information about the properties of the materials - the depththey appear on, how likely they are to blend with other materialsand so on. The system then combines these material randomlytaking into account the design specifications and creates layersmade of these blends. The materials, however, have no physicalproperties and all the layers are generated through simple noisefunctions.

Figure 5: Resulting terrain achieved using the volumetricgeneration introduced by Santamaría-Ibirika et al. [2014]

The cave and vein generation is done using a midpoint displace-ment technique, where the sides of a square are subdivided andrandomly displaced. This generated fractal shape is used as thehorizontal contour of the cave, and the height at each point is cal-culated based on the minimum distance to a border. This is by farthe most time consuming step in the process and it creates randombut similar looking caves which are inserted between layers in thegeneration process.

The resulting topology of the surface is sub-par when comparedwith the state-of-the-art generation techniques, and most of the in-teresting features on it appear because a cave or vein was generatedbeneath it. This can be seen in figure 5: the shape of undergroundcaves propagates to the top as layers are stacked. Because of thisthe mountains have roughly the same topology as the caves under-neath. Since layers are stacked on top of each other, it is impossiblefor any other material to appear on the surface apart from the onethat forms the top layer.

3 METHODOLOGYWith the goal of expanding the possibilities for procedural genera-tion of volumetric data for terrain a top-down approach to generatematerial layers using pre-generated surface terrain as input is pro-posed. In contrast to the work by Santamaría-Ibirika et al. [2014],the method’s goal is to allow the user to take advantage of theexpansive research that has been conducted on the procedural gen-eration of surface terrains by creating appropriate volumetric datafor the provided terrain.

The pre-generated surface terrain must be in the form of a heightmap. The second input that must be provided by the user is theproperties of the materials that will be used for the layers. Thematerials can be of two different kinds: stratified or eroded. Theoutput is volumetric data appropriate to the terrain in the form ofthe layer model shown in section 2.2.3.

Two different methods are proposed to create the eroded ma-terial layers. The first one, referred to as the erosion method inthis paper, uses a stabilization simulation technique introducedby Peytavie et al. [2009] that is very similar to thermal erosion ap-proaches explored in section 2.1.2. The second one, the slope method,is an original technique that tries to approximate the results of theerosion technique with a smaller computational overhead.

3.1 Base Surface GenerationFor the purposes of testing the method a surface terrain has to begenerated to serve as input. In order to simulate a typical settingwhere this method could be used, a Perlin noise generated heightmap was used. A commonly used modification to the noise wasperformed by elevating the noise values to the power of four tocreate flatter valleys and steeper mountains as shown in figure 6.

Figure 6: Examples of surface terrain generated using themodified Perlin noise.

4

Page 7: Procedural Generation of Volumetric Data for Terrainkth.diva-portal.org/smash/get/diva2:1355216/FULLTEXT01.pdf · of computer graphics and procedural content generation, and can broadly

3.2 MaterialsOne of the inputs the user must give to the algorithm is the infor-mation about the materials that are going to be part of the layeredterrain. These materials can either be stratified or eroded.

3.2.1 Stratified materials are trying to simulate the naturallyobserved phenomena of sedimentary rock or soil settling to createdistinct layers on the earth’s crust. For these materials the usermust input the following properties:

• Depth: The depth at which the material appears.• Thickness: The average size of the layer that this materialtends to form.

• Roughness: The amount of variation on the layer’s thick-ness.

3.2.2 Eroded materials on the other hand, are simulating loosematerials such as dirt, sand and gravel that will not accumulate onsteep hills, but will settle on flat areas and valleys. The generationof these material layers will adapt itself to the provided terrain andcreate realistic looking granular accumulation. For these materialsthe following properties are required:

• Weight: This is used to the determine the ordering of thematerial layers.

• Thickness: The amount of eroded material.• Angle of repose: The angle at which the material stabilizes.• Maximum slope: The maximum steepness of a slope inwhich the eroded material will appear. This value is onlyused on the slope method.

3.2.3 Resolution. is the final input the user must provide the al-gorithm. Since the method is designed to be resolution independentthe values for the material’s thickness and depth will be propor-tional to the resolution. In practice this means that a material stackof height 0.5 will be 150 units high if the resolution is 300x300,and 50 units high if the resolution is 200x200. This allows for thegeneration of the same terrain in any size desired, as shown infigure 7.

(1) (2)

Figure 7: The same terrain with different resolutions:400x400 (1) and 100x100 (2).

3.3 SlopeConsider the following definition of slope si, j that will be used inthis method:

si, j = max(|hi, j − hi−1, j−1 |, |hi, j − hi−1, j |,

|hi, j − hi−1, j+1 |, |hi, j − hi, j−1 |,

|hi, j − hi, j+1 |, |hi, j − hi+1, j−1 |,

|hi, j − hi+1, j |, |hi, j − hi+1, j+1 |)

(1)

That is, the greatest height difference between a material stackand its eight neighbours where hi, j is the height of the stack i, j.

3.4 Layer GenerationThe layer generation is based on the information provided by theuser for the stratified materials. First, the algorithm chooses thematerial for the new layer. If this is the first layer, this will be thematerial with the largest depth property. Otherwise, the chosenmaterial will be the one whose property is closest to the currentdepth on the generation process.

Starting Height Map First Layer

Second Layer Third Layer

Figure 8: Layer generation process where material layersare stacked on top of each other until the starting heightis reached

Next, the algorithm generates the layer physically. This is donethrough the use of fBm Perlin noise. The roughness property ofthe material influences the frequency of the noise. This process isrepeated for each material layer. As can be seen in figure 8, oncethe stack of material surpasses the height of the starting heightmap for that point, the final layers’ surplus material is removed andthe generation algorithm will no longer add material to that stack.Once all stacks get to this point the process is done.

3.5 Erosion MethodThe first proposed method to generate eroded material layers isbased on a stabilization simulation model [Peytavie et al. 2009] thatis very similar to erosion simulations. The main difference betweenthe two is the presence of stable material layers. While in erosion

5

Page 8: Procedural Generation of Volumetric Data for Terrainkth.diva-portal.org/smash/get/diva2:1355216/FULLTEXT01.pdf · of computer graphics and procedural content generation, and can broadly

Figure 9: Effects of increasing the roughness of all materiallayers

methods there is usually no distinction between different kindsof materials, the stabilization simulation considers some materialsstable and only loose materials are allowed to move and settle. Inthe context of the proposed method, the stratified materials arestable and the eroded materials are loose.

The first step in the process is to erode material from the staticstratified layers. The amount of material that is set loose is pro-portional to the thickness parameter defined by the user for thematerial. This means that this method will alter the surface terrainby changing the highest parts of the material stacks into erodedmaterial and moving them if necessary.

After materials are set loose, they are ordered based on theirweight parameter. The heaviest materials are transferred to thebottom of the stack. This is done because the simulation of multiplegranular materials blending and interacting is extremely challeng-ing, so ordering and separating them simplifies the algorithm byallowing the use of a single angle of repose for each material whilestill producing satisfactory results. If there are multiple layers ofthe same material, these are merged together.

Before ordering Ordered stacks

Figure 10: Material layers being merged and ordered on theerosion method.

The next step in the algorithm is to simulate the movement ofmaterial. For each stack, part of a material layer will be movedto neighbouring stacks in case the angle between them is largerthan the angle of repose. The layers are moved from the bottomto the top, starting off with the heaviest materials. This process isrepeated until there is no unstable stacks with material that shouldbe moved. Figure 11 shows the resulting terrain on a very smallexample-case. It is clear to see the effects of the difference in theangle of repose between the two different materials.

Considerhi the height of material stack i . Material will be movedfrom stack i if the height difference ∆h between it and any of itsneighbouring stacks is larger than tanα where α is the angle of

Unstable material Settled material

Figure 11: The starting and ending state of material beingstabilized on the erosion method.

repose of the material being moved. The amount of material movedwith each time step is set to a small constant c . This is done in orderto avoid oscillations on the algorithm, where material is movedendlessly back and forth between two neighbouring stacks. Materialis moved until the angle between a stack and all of its neighboursis smaller than the angle of repose.

ii − 1 i + 1

hi

∆hi−1tanα

α

ii − 1 i + 1

hitanα

α

Figure 12: Material stacks before and after stabilization onthe erosion method.

The moved material is divided between all neighbouring stackswhere each stack receives an amountm proportional to a weightedaverage of their height difference, that is, more material will bemoved to stacks that have a larger ∆h. For stack i:

mi = c∆hi∑8

k=1 ∆hk(2)

3.6 Slope MethodThe slope at a certain point on the terrain can be calculated byobtaining the derivatives of the height values on a height map.These values are commonly used in rendering to apply appropriatetextures to the mesh of a generated terrain. Points with a highderivative value will be mapped to a stone texture while flat areasare mapped to grass, with blending in the transition regions.

Observing the results of the erosion method it is clear that sedi-mentary material tends to accumulate on valleys and flatter areas.Because of this, the slope of the terrain can serve as a shortcut togenerate material layers. In contrast with the texturing however,derivative values aren’t enough on their own. The very top of amountain can have the same slope as a flat area in the middle of avalley, but the sediment accumulation on both of these would notbe the same.

6

Page 9: Procedural Generation of Volumetric Data for Terrainkth.diva-portal.org/smash/get/diva2:1355216/FULLTEXT01.pdf · of computer graphics and procedural content generation, and can broadly

The first step of the algorithm is to go through the height mapand create an analogous slope map using the computation shownin equation 1. Then, the starting heights hi for the material stacksare calculated:

hi =

{si > S : 0

si ≤ S : t S−siS(3)

Where S and t are the maximum slope and the thickness proper-ties set by the user and si is the corresponding value on the slopemap for stack i . In practice, this will only generate material at pointswhere the slope is smaller than S , and hi will increase in value asthe slope increases, getting to its maximum thickness when theslope is equal to zero.

The following step is a simplified and inverted version of thestabilization simulation explored in section 3.5. Instead of beingstacked on top of the stratified layers, the eroded material layersare inserted into the top of the material stack and a part of the staticlayers are removed to make place for them.

The stabilization simulation is used to calculate the heights of thematerial stacks, but no material is moved throughout the process.Instead material is just removed, until there are no neighbouringstacks with the height difference angle greater then the angle ofrepose.

Starting heights Stable stacks

Figure 13: On the slope method material is removed fromthe starting stacks to achieve the angle of repose shown bythe dark dotted lines.

The lack of material movement cuts down the algorithm’s com-putation time by avoiding cases where some material will have tobe moved all the way down from a mountain. It also means thatcases where oscillations might happen are impossible, and thus theneed for a constant amount of material to be moved is unnecessary.Instead, the algorithm removes the amount required for the stackto achieve the angle of repose with the smallest neighbour, even ifthe height difference between them is very large.

Points where si > S have no material. This means that its neigh-bouring stacks that do have material will always have an amountsmaller than tanα , ensuring a smooth transition between stacksthat contain the eroded material and ones that do not. The thicknesswill only grow if the current stack has a large enough slope anddoes not have any neighbours that lack eroded material.

ii − 1 i + 1

hi

∆hi−1tanαα

α

ii − 1 i + 1

hitanα α

Figure 14: Material stacks before and after the removal ofmaterial on the slope method.

3.7 Voxel representationFor these methods to be rendered it was necessary to transformthe stack representation of the terrain into a voxel representation.This is not necessary for all applications, but it is by far the mostcomputationally intensive part of the process, if required. In orderto generate visualizations in a reasonable time the process was par-allelized by dividing the terrain into smaller chunks and convertingeach chunk separately on the GPU.

4 RESULTSThe methods were implemented using C++ and tests were per-formed on an Intel Core i5-8400 CPU clocked at 2.80GHz andequiped with 24 GB of RAM. All of the results shown in the imageson this paper were rendered using the MagicaVoxel 2, a applicationused for modelling and visualizing voxel models.

4.1 VisualFigure 16 shows comparisons between the results obtained by themethod using both techniques used to generate erosion layers onthe same input terrain.

The stratified material layer generation produced the expectedvisual results. As shown by Santamaría-Ibirika et al. [2014] materiallayers are present in real-world terrain and the method proposedhere achieves very similar results to the ones obtained by them.This means that, while this method does not generate simulationsof real terrain and does not achieve the breadth of variety seen inthem, it does show some similarities such as stacked layers and thepropagation of folds over several layers (figure 9).

Both methods used to generate eroded layers produced realisticlooking results, although differing slightly. The goal of having loosematerial accumulate on flat areas and not appear on steep hills andmountain was achieved, producing reasonable looking materialaccumulation. On the erosion method the eroded layer tends tobe thinner in really flat areas while sediment accumulation on thebases of mountains is more prominent. The erosion method alsoshows less accumulation on the high flat areas such as mountainstops and hills, but this can be adjusted by tinkeringwith thematerialproperties.

2https://ephtracy.github.io/

7

Page 10: Procedural Generation of Volumetric Data for Terrainkth.diva-portal.org/smash/get/diva2:1355216/FULLTEXT01.pdf · of computer graphics and procedural content generation, and can broadly

4.2 PerformanceThe thermal erosion algorithm was not designed to be executedonline [Jákó and Tóth 2011; Musgrave et al. 1989], that is, fastenough that a user could execute it on their computer and obtainresults in a timely fashion. Fastest computation can be achieved byconsidering only half the neighbours when transferring material.This will half the number of checks done during execution. Boththe Von Neumann and the modified Von Neumann neighbourhoodcan be used (figure 15), with the latter having a slight performanceedge Olsen [2004].

Von Neumann

hi, jhi−1, j

hi, j+1

hi, j−1

hi+1, j

Modified Von Neumann

hi, j

hi−1, j+1 hi+1, j+1

hi−1, j−1 hi+1, j−1

Figure 15: Different neighbourhoods can be used to achievefaster results with minimal quality loss.

However, thanks to recent hardware developments, there hasbeen work done on techniques to execute fast erosion methods onthe GPU [Jákó and Tóth 2011; Mei et al. 2007]. In the case of thermalerosion, it is possible to execute each material stack independent ofthe others by using virtual pipes to avoid write dependency. Thesevirtual pipes store the material to be transferred to each stack and,once an iteration is done, the material is transferred all at once.While these modifications allow erosion techniques to be run inreal-time, they were out of the scope of this paper and were notimplemented. The time comparisons, however, are still valid, sinceboth techniques could benefit from them.

Table 1 shows the steep increase in computation time for bothmethods as the size of the generated terrain increases. For eachdifferent terrain size, twenty different tests were performed, usingrandom seeds. The slope method proposed in this paper performssignificantly better than the traditional erosion technique, especiallyfor larger terrain sizes.

5 DISCUSSIONThe performance results presented in the previous section showsthat the slope method outperforms the traditional erosion approach.This does not mean, however, that there are no reasons to use it.These reasons will be explored in this section, along with compar-isons with other methods in literature and an example of a relevantuse case for the generated terrains.

5.1 Physical simulationWhile the results achieved by the slope method closely resemblethe ones generated using the erosion technique, one fundamentaldifference between them is that the latter is trying to simulate a

Table 1: Average computation time by size of terrain gener-ated

Resolution Erosion Method Slope Method(s) (s)

50x50 1.003 ± 0.295 0.186 ± 0.01875x75 3.093 ± 0.966 0.499 ± 0.048100x100 7.922 ± 2.456 1.015 ± 0.111125x125 16.87 ± 7.865 1.784 ± 0.198150x150 25.52 ± 8.941 2.868 ± 0.346175x175 42.41 ± 16.81 4.349 ± 0.554200x200 53.61 ± 18.37 6.213 ± 0.944

physical phenomena. This is one of the main reasons why the ero-sion method does not have great performance. The slope techniquecreated good results through several conceits that do not aim tomodel any kind of real-world occurence so it should not be used ifthe goal is to approximate real-world thermal erosion as closely aspossible.

5.2 Input alterationThe erosionmethodmodifies the input terrain by removingmaterialfrom mountains and moving it down. This method has historicallybeen used to improve procedurally generated terrain, so there isvalue in using it to augment the generation process and producebetter looking terrain. If erosion is already being used, then there isno reason to compute the eroded materials using another method.On the other hand, if the goal is to not change terrain but to generatesuitable volumetric data, the slope method is the clear choice as itcan be combined with any other surface generation technique.

5.3 Endless terrainOne of the main problems with the thermal erosion methods is howthey behave at the edges of terrain. This is critical for applications,such as games, that might need to create endless landscapes. Usually,game developers generate individual chunks of terrain on demandas the player moves through it, since generating it entirely from thestart would be impossible. This is a problem for terrains generatedusing erosion techniques due to the uncertainty on how to behaveat the edges of the map where there is incomplete informationabout the neighbourhood, as shown in figure 17. While the slopemethod may also suffer from this problem, the effects of it are muchless stark. Since the surface geography is not altered, the terrainwill still fit together seamlessly. Some anomalies may still happenin the connections between the subsurface layers, but those will bemuch less daunting, since mismatches on the surface terrain mightgenerate impossible looking landscapes.

5.4 Comparison to other methodsThe only othermethod proposed in literature to generate volumetricmaterial data for terrain is the work done by Santamaría-Ibirikaet al. [2014]. In their method, surface terrain is generated as theresulting topology of the top-most layer. This is a major differencein comparison to the method proposed in this paper since it usessurface terrain as input.

8

Page 11: Procedural Generation of Volumetric Data for Terrainkth.diva-portal.org/smash/get/diva2:1355216/FULLTEXT01.pdf · of computer graphics and procedural content generation, and can broadly

(1)

(2)

Figure 16: Comparison between the results for the slope method (1) and the erosion method (2) for the same surface terrain.

Figure 17: Example of material accumulation at the edge ofa chunk. Material piles up because it can’t move outside ofthe boundaries. This might cause mismatches with adjacentchunks.

This method is also capable of generating terrain that can haveseveral different stratified layers protruding from mountains andcliffs, an effect that can be observed in real life and is impossible toachieve using simple layer stacking. The creation of eroded layersprovides the greatest improvement in regards to both the realismand look of the generated terrain.

It is difficult to compare both methods in terms of computationalcomplexity. In their method, the most time consuming feature is the

creation of caves and veins, and computation time increases rapidlyas the number and size of these features rise. The choice of numberof caves to be generated in test cases would greatly influence thiscomparison. Perhaps it would be fair to consider the case whereno caves or veins are created, since the method proposed in thispaper lacks these features, but as discussed in section 2.3, theseare extremely important for the topology of the resulting surfaceterrain on their method.

5.5 Use caseA major problem with the current graphics pipeline based on tri-angle meshes is that there is no volumetric data associated withobjects. Meshes only model the surfaces, which means that objectsare essentially hollow. This can be a great challenge for games thatwant to have destructible objects and surfaces, as they often haveto rely on having objects made up of different chunks that can bedisassembled. This means that a lot of work has to go into creatingeach of the destructible objects, and leads to situations where theplayer is able to destroy and interact with some objects in the gamebut not others, detracting from their immersion.

While the rendering of a lot of very small voxels was previouslyimpossible due to memory restrictions, recent advancements inhardware have sparked the development of voxel-based engines,which forgo triangle meshes entirely and focus on rendering objectsmade up of voxels which have inherent volumetric data making it

9

Page 12: Procedural Generation of Volumetric Data for Terrainkth.diva-portal.org/smash/get/diva2:1355216/FULLTEXT01.pdf · of computer graphics and procedural content generation, and can broadly

much easier to change and remove parts. This voxel approach alsolends itself very well to terrain generation. As mentioned beforein section 2.2, a lot of the terrain PCG techniques voxilize thespace. The use of voxel engines avoids having to transform thatinformation into meshes.

One of the goals of the work done in this paper is for future usein a game made in a voxel engine. Volumetric terrain lends itselfvery well to applications where the user can dig and destroy theenvironment.

6 FUTUREWORKAs mentioned in section 3.1 and shown in figure 6, the surfaceterrain used to test the algorithm is a modification of Perlin noise.While this is probably one of the most used techniques for terraingeneration, it would be important to explore how the algorithmsperform with input terrain created by other techniques. It wouldalso be interesting to see how the eroded material layers differwhen using other erosion methods instead of thermal erosion. Thismethod would also work in combination with hydraulic erosion.

In section 2.3 the work in the literature regarding the use ofvolumetric models to generate caves was explored. Since most ofthe methods involve carving a 3D voxel representation, they canbe combined with the presented method in order to create moreinteresting subsurface geology. Combining the creation of caveswith the layer generation process could also produce interestingresults and augment the method.

Finally, because of the nature of noise methods, the stratifiedlayer generation tends to produce repetitive results. One way toincrease their unpredictability is to add tectonic plate simulationto break them apart and move them. By detecting the presence ofmountains it might be possible to the simulate the tectonic activitythat could have led to the formation of the detected mountain range,such as tectonic plate collisions.

7 CONCLUSIONThe method proposed in this paper expands on the scarcely re-searched field of volumetric procedural terrain generation. An orig-inal approach to generate eroded material layers that closely re-semble the ones created by thermal erosion was presented. Thismethod was shown to be efficient when compared to a common im-plementation of settlement simulation inspired by thermal erosion.

The introduction of eroded material layers added to the real-ism and the look of the output terrain, and achieved the goal ofhaving material accumulation on areas of low incline. The resultsobtained by the method were discussed and compared with a previ-ous method present in the literature.

ACKNOWLEDGMENTSThis thesis was done in association with Resolution Games 3. Iwould like to thank my supervisor at the Royal Institute of Technol-ogy in Stockholm Björn Thuresson, my examiner Tino Weinkaufas well as my supervisor at Resolution Games Björn Englesson.

3https://www.resolutiongames.com

REFERENCESBedrich Benes and Rafael Forsbach. 2001. Layered data representation for visual

simulation of terrain erosion. In Proceedings Spring Conference on Computer Graphics.IEEE, 80–86.

Matt Boggus and Roger Crawfis. 2009. Procedural creation of 3d solution cave mod-els. In Proceedings of the 20th IASTED International Conference on Modelling andSimulation. 180–186.

Guillaume Cordonnier, Jean Braun,Marie-Paule Cani, Bedrich Benes, Eric Galin, AdrienPeytavie, and Eric Guérin. 2016. Large scale terrain generation from tectonic upliftand fluvial erosion. In Computer Graphics Forum, Vol. 35. Wiley Online Library,165–175.

Yann Cortial, Adrien Peytavie, Eric Galin, and Eric GuÃľrin. 2019. Procedural TectonicPlanets. Computer Graphics Forum (2019). https://doi.org/10.1111/cgf.13614

Alain Fournier, Don Fussell, and Loren Carpenter. 1982. Computer rendering ofstochastic models. Commun. ACM 25, 6 (1982), 371–384.

Eric Galin, Eric Guérin, Adrien Peytavie, Guillaume Cordonnier, Marie-Paule Cani,Bedrich Benes, and James Gain. 2019. A Review of Digital Terrain Modeling. (2019).

Manuel N Gamito and F KentonMusgrave. 2001. Procedural landscapes with overhangs.In 10th Portuguese Computer Graphics Meeting, Vol. 2.

Eric Guérin, Julie Digne, Eric Galin, Adrien Peytavie, Christian Wolf, Bedrich Benes,and Benoît Martinez. 2017. Interactive example-based terrain authoring withconditional generative adversarial networks. Acm Transactions on Graphics (TOG)36, 6 (2017), 228.

Mark Hendrikx, Sebastiaan Meijer, Joeri Van Der Velden, and Alexandru Iosup. 2013.Procedural content generation for games: A survey. ACM Transactions on Multime-dia Computing, Communications, and Applications (TOMM) 9, 1 (2013), 1.

Balázs Jákó and Balázs Tóth. 2011. Fast Hydraulic and Thermal Erosion on GPU.. InEurographics (Short Papers). 57–60.

Viktor Kämpe, Erik Sintorn, and Ulf Assarsson. 2013. High resolution sparse voxelDAGs. ACM Transactions on Graphics (TOG) 32, 4 (2013), 101.

Ares Lagae, Sylvain Lefebvre, Rob Cook, Tony DeRose, George Drettakis, David S Ebert,John P Lewis, Ken Perlin, and Matthias Zwicker. 2010. A survey of procedural noisefunctions. In Computer Graphics Forum, Vol. 29. Wiley Online Library, 2579–2600.

Samuli Laine and Tero Karras. 2010. Efficient sparse voxel octrees. IEEE Transactionson Visualization and Computer Graphics 17, 8 (2010), 1048–1059.

Benoit B Mandelbrot. 1983. The fractal geometry of nature. Vol. 173. WH freeman NewYork.

Benjamin Mark, Tudor Berechet, Tobias Mahlmann, and Julian Togelius. 2015. Proce-dural Generation of 3D Caves for Games on the GPU.. In FDG.

Xing Mei, Philippe Decaudin, and Bao-Gang Hu. 2007. Fast hydraulic erosion simu-lation and visualization on GPU. In 15th Pacific Conference on Computer Graphicsand Applications (PG’07). IEEE, 47–56.

F Kenton Musgrave, Craig E Kolb, and Robert S Mace. 1989. The synthesis andrendering of eroded fractal terrains. In ACM Siggraph Computer Graphics, Vol. 23.ACM, 41–50.

Mattia Natali, Endre M Lidal, Julius Parulek, Ivan Viola, and Daniel Patel. 2013. Model-ing Terrains and Subsurface Geology.. In Eurographics (STARs). 155–173.

Jacob Olsen. 2004. Realtime procedural terrain generation. (2004).Ken Perlin. 1985. An image synthesizer. ACM Siggraph Computer Graphics 19, 3 (1985),

287–296.Adrien Peytavie, Eric Galin, Jérôme Grosjean, and Stéphane Mérillou. 2009. Arches: a

framework for modeling complex terrains. In Computer Graphics Forum, Vol. 28.Wiley Online Library, 457–467.

Aitor Santamaría-Ibirika, Xabier Cantero, Mikel Salazar, Jaime Devesa, Igor Santos,Sergio Huerta, and Pablo G Bringas. 2014. Procedural approach to volumetricterrain generation. The Visual Computer 30, 9 (2014), 997–1007.

Ruben M Smelik, Tim Tutenel, Rafael Bidarra, and Bedrich Benes. 2014. A surveyon procedural modelling for virtual worlds. In Computer Graphics Forum, Vol. 33.Wiley Online Library, 31–50.

Howard Zhou, Jie Sun, Greg Turk, and James M Rehg. 2007. Terrain synthesis fromdigital elevation models. IEEE transactions on visualization and computer graphics13, 4 (2007), 834–848.

10

Page 13: Procedural Generation of Volumetric Data for Terrainkth.diva-portal.org/smash/get/diva2:1355216/FULLTEXT01.pdf · of computer graphics and procedural content generation, and can broadly

www.kth.se

TRITA -EECS-EX-2019:439