• No results found

NOAHTELLANTONTHUN AnapproachofusingDelaunayrefinementtomeshcontinuousheightfields

N/A
N/A
Protected

Academic year: 2021

Share "NOAHTELLANTONTHUN AnapproachofusingDelaunayrefinementtomeshcontinuousheightfields"

Copied!
34
0
0

Loading.... (view fulltext now)

Full text

(1)

IN

DEGREE PROJECT TECHNOLOGY, FIRST CYCLE, 15 CREDITS

,

STOCKHOLM SWEDEN 2017

An approach of using Delaunay

refinement to mesh continuous

height fields

(2)

An approach of using Delaunay

refinement to mesh continuous

height fields

NOAH TELL ANTON THUN

Degree Programme in Computer Science Date: June 5, 2017

Supervisor: Alexander Kozlov Examiner: Örjan Ekeberg

Swedish title: En metod att använda Delaunay-raffinemang för att skapa polygonytor av kontinuerliga höjdfält

(3)

Abstract

Delaunay refinement is a mesh triangulation method with the goal of generating well-shaped triangles to obtain a valid Delaunay triangulation. In this thesis, an approach of using this method for meshing continuous height field terrains is presented using Perlin noise as the height field. The Delaunay approach is compared to grid-based meshing to verify that the theoretical time complexity O(n log n) holds and how accurately and deterministically the Delaunay approach can represent the height field. However, even though grid-based mesh generation is faster due to an O(n) time complexity, the focus of the report is to find out if De-launay refinement can be used to generate meshes quick enough for real-time applications. As the available memory for rendering the meshes is limited, a solution for providing a co-hesive mesh surface is presented using a hole filling algorithm since the Delaunay approach ends up leaving gaps in the mesh when a chunk division is used to limit the total mesh count present in the application. The methods were implemented in the programming language C++ using the open source library libnoise to generate the Perlin noise and the off-the-shelf solution CGALmesh provided a Delaunay refinement implementation. The video game en-gine Unity was used to render the output meshes created by the Delaunay and grid approach by interfacing with C++ via a Windows DLL.

(4)

Sammanfattning

Delaunay-raffinemang är en trianguleringsmetod med målet att generera reguljära trianglar för att uppnå en giltig Delaunay-triangulering. I denna avhandling presenteras en metod användandes Delaunay-raffinemang för att skapa polygonytor av kontinuerliga höjdfälts-terränger, där Perlin noise används som höjdfält. Delaunay-metoden jämförs med en rut-nätsbaserad metod för att verifiera att tidskomplexiteten O(n log n) gäller och hur exakt och deterministiskt som Delaunay-metoden förhåller sig till att representera höjdfältet. Även fast rutnätsmetoden är snabbare på grund av en O(n) tidskomplexitet är rapportens fokus att ta reda på om Delaunay-raffinemang är snabb nog för att användas i realtidsapplikationer för att generera polygonytor.

Eftersom det tillgängliga minnet för att rendera polygonytorna är begränsat presenteras en lösning för att få sammanhängande ytor genom en hålutfyllningsalgoritm då Delaunay-metoden lämnar hål i ytan när chunk-uppdelning används för att begränsa det totala an-talet polygonytor i applikationen. Metoderna implementerades i programmeringsspråket C++ användades biblioteket libnoise för att generera Perlin noise och den färdiga lösning-en CGALmesh användes som implemlösning-entation av Delaunay-raffinemang. Datorspelsmotorn Unity användes för att rendera polygonytorna som skapades av Delaunay- och rutnätsme-toden genom ett C++-gränssnitt via en Windows DLL.

(5)
(6)

Contents

1 Introduction 1

1.1 Purpose . . . 1

1.2 Problem statement . . . 2

1.3 Scope and constraints . . . 2

1.4 Disposition . . . 2

1.5 Terminology . . . 3

2 Background 4 2.1 Height field generation . . . 4

2.1.1 Gradient noise . . . 4

2.1.2 Perlin noise . . . 4

2.2 Delaunay-based mesh generation . . . 5

2.2.1 Delaunay triangulation . . . 5

2.2.2 Restricted Delaunay refinement . . . 6

2.2.3 Numerical precision issues . . . 7

2.3 Related work . . . 7

3 Methodology 8 3.1 Delaunay meshing . . . 8

3.1.1 The oracle . . . 8

3.1.2 Surface hole filling . . . 8

3.2 Grid meshing . . . 10

3.3 Test setup . . . 10

3.3.1 Performance test . . . 11

3.3.2 Accuracy and determinism test . . . 12

3.3.3 Test parameters . . . 12 3.4 Development setup . . . 13 3.4.1 Hardware . . . 13 3.4.2 Tests . . . 14 4 Results 15 4.1 Grid meshing . . . 15 4.2 Delaunay meshing . . . 15 4.3 Relative observations . . . 19

4.3.1 High complexity noise . . . 19

4.3.2 Low complexity noise . . . 20

5 Discussion 21 5.1 Applicability . . . 21

5.2 Performance overhead . . . 21

5.3 Errors sources . . . 21

5.3.1 Determinism . . . 21

(7)

CONTENTS

5.3.3 Choice of parameters . . . 22

5.4 Future work . . . 22

5.4.1 Volumetric terrain . . . 22

5.4.2 Delaunay edge refinement . . . 22

6 Conclusion 23

(8)

1 Introduction

In computer graphics, height fields serve an important role for visualizing terrain in real-time applications, simulations and geographic information systems. Traditionally, height fields are finite regular 2D grids containing height values for each grid point, as such it is common to create a triangular mesh from sampling those values directly as vertices. Though as shown by the work of Santamaría-Ibirika et al. [1] and video games such as Minecraft and No Man’s Sky, height fields may also be algorithmically generated, from which grids of any resolution can be extrapolated and triangulated.

However, due to the latter use, it is also possible to utilize other meshing techniques such as restricted Delaunay refinement which is of focus for this report. It is expected to have comparable height field representation to that of grid meshing, although it is incapable of surpassing grids in performance due to a theoretical time complexity of O(n log n) in contrast to O(n), where n is the number of triangles in the created mesh [2].

Though since the available graphics card memory and computational power is limited, it is often desired to limit the number of triangles rendered at once, which due to the nature of grids is straightforward to do through rendering a limited amount of larger grids containing the meshes, commonly referred to as chunks [1]. This presents a challenge for Delaunay re-finement which while capable of meshing versatile domains as shown by decades of research [3] has no immediate mesh pattern allowing for the chunks to create a cohesive mesh surface when each chunk is triangulated independently.

In addition, applications using algorithmic height fields may rely on the deterministic mesh-ing that grids provide which ensures that the created mesh within a chunk can be regener-ated exactly at another point in time [4]. This is something that Delaunay refinement must be able to provide if it is going to be applicable in the same extent as the grid-based approach.

(a) Fixed-grid (b) Delaunay refinement Figure 1.1: An example of the triangle pattern achieved by each method

1.1

Purpose

(9)

1 INTRODUCTION

Delaunay surface meshing and that of the grid will be of use for meshing volumetric ter-rains, where the 3D grid equivalent requires the use of cubes to generate a mesh, that unlike Delaunay refinement relies on additional algorithms such as marching cubes [5] to create smooth volume meshes [6].

1.2

Problem statement

Since the grid meshing method is widely used for creating height field meshes, it serves as a control to ensure that the designed Delaunay method in this study has comparable robust-ness to representing the height field. The robustrobust-ness will be measured by the accuracy of the generated mesh to the height field together with the determinism and chunking require-ment specified above. Additionally, to verify that the time complexity holds, the generation time of each method has to be measured. Thus, the following properties are of interest for answering the research question and verifying that this is achieved:

• The accuracy of the generated mesh in relation to the height field. • The determinism of the generation.

• The computational cost during generation.

Research question

Is it practical to use Delaunay refinement to mesh chunk divided height fields for real-time applications?

1.3

Scope and constraints

Although there are many variants of grid-based mesh generation, this report will use a 2D fixed sized grid interspersed equally along the entire height field to create the mesh.

Moreover, parallelization will not be investigated in this report, as grids are embarrassingly parallel and Delaunay-based methods are proven to be parallelizable in theory as described in section 2.2.

In addition, the height fields in this report are created by the Perlin noise algorithm which is detailed in section 2.1.2. However, the Delaunay refinement approach should be applicable to any continuous height field as that is the only requirement of the meshing algorithm, and this is demonstrated by comparing height field settings of both high and low complexity as described in section 3.3.

1.4

Disposition

(10)

1 INTRODUCTION

1.5

Terminology

These are the key terms used in the thesis that are not self-explanatory from the sentence contexts or the introduction.

Chunk division

As mentioned in the introduction, due to limited memory it is necessary to limit the number of triangles rendered at once. With chunk division, this is done by restricting meshing to a square or cube region that allows control over how many regions that should be loaded at any point in time, for instance through only loading chunks in the user’s field of view.

Mesh

A mesh is a triangular graph representing a 3D polygon surface, commonly stored as a set of triangles.

Mesh hull

A mesh’s hull in 2D is the set of outermost edges that together completely envelop all vertices of the mesh.

Polygonal chain

A sequence of points called its vertices. Consecutive vertices form line segments.

Subdivision

(11)

2 Background

The following sections build up the necessary background for the methodology. First, section 2.1 describe the algorithmic height field generator used in this report. Second, section 2.2 detail how Delaunay refinement creates triangular surface meshes. Lastly, section 2.3 gives an overview of the related work to this report.

2.1

Height field generation

The two most common height field generation algorithms shown to be used in practice to lay the foundation for terrain are fractal and gradient noise algorithms. Fractal algorithms are commonplace from their tendency to appear in reality, and likewise gradient noise tend to emulate natural height shifts in terrain. Moreover, these methods are not mutually exclusive as fractal features can be incorporated into other algorithms, such as the commonly used Perlin noise. [7] However, pure fractal terrain algorithms rely heavily on random values [8] which would violate the desired deterministic generation and as such fractal patterns with assistance from other algorithms are preferred.

2.1.1 Gradient noise

By using the rate of change of a function as the basis for noise generation, i.e. the function’s gradient, as opposed to interpolating random noise, the generated noise creates continuous slopes of random steepness in the generated height-coordinate for a 2D noise function, re-sulting in a smooth function with no sudden changes in height. This is done by interpolating nearby gradients placed in a grid where each point has zero height, which allows interme-diary points to be extracted. The heights are set to zero due to the inability to infer that from the gradients alone, however, this does not create any grid artifacts visible in the resulting surface as the gradients ensure that there is no discernible pattern at those points. As the grid spacing controls the interpolation distance of the gradients, it is known as the frequency of the noise. [7]

2.1.2 Perlin noise

(12)

2 BACKGROUND

2.2

Delaunay-based mesh generation

With any variant of algorithmic height fields, such as the one described above, the resulting output can be interpreted as a set of 3D Cartesian coordinates describing the boundary of a surface. With this, it is desirable to generate a triangular mesh accurately representing the boundary. As mentioned earlier, this is obtained directly in grid-based methods by querying the height of grid positions and then creating triangles between adjacent points.

A similar approach can be taken using random points and triangulating them directly, al-though that would give no guarantee of the mesh quality. In general, there are two main meshing approaches capable of creating triangular meshes of a surface boundary without any reliance on underlying grids, these are known as advancing front and restricted Delau-nay refinement. Common advancing front algorithms are surpassed in reliability and perfor-mance by Delaunay-based methods due to convergence issues in 3D and their dependence on the use of heuristics. [10] Delaunay-based methods assert certain properties of triangles, allowing more information to be used when creating the structure to avoid unsolvable situ-ations [2] and enables parallel processing capabilities which is otherwise not possible with regular advancing front algorithms [10].

2.2.1 Delaunay triangulation

The Delaunay-based methods stem from the basis of Delaunay triangulation, which is the concept of a triangulated set of points that maximize the narrowest angle of every triangle. It is a widespread and deeply researched subject of triangulation, starting from the work of Delaunay and his empty-sphere criterion. The empty-sphere criterion defines a Delaunay triangulation as a triangulation such that each triangle’s circumscribing sphere (an open ball) contains no other point in the whole triangulation. A valid Delaunay triangulation in 2D is shown in figure 2.1, and the same principle applies in 3D for tetrahedral volumes and triangular surfaces. [2]

Figure 2.1: 2D triangulation fulfilling Delaunay’s empty-sphere criterion

(13)

2 BACKGROUND

Figure 2.2: The Voronoi diagram of a 2D Delaunay triangulation

2.2.2 Restricted Delaunay refinement

As described above, Delaunay refinement is one of the methods that build upon the quali-ties of Delaunay triangulation and are governed by an oracle that can describe the surface being meshed. The oracle provides a few initial points guaranteed to be on the surface and returns the point of intersection by any line segment intersecting the surface. The initial points are required to include sharp features, such as the corners of a cube, if they exist as it is normally impossible for the algorithm to find these points from surface intersections. There exists variants where the dual Voronoi-triangle to a refinement edge is used to mesh sharp features, commonly known as edge-refinement, but that is known to jeopardize the convergence guarantee of the algorithm. [6]

After initialization, triangles are created from the initial points and for each triangle, as shown in figure 2.3, intersection points of the surface known as Steiner points are calculated from the intersection of the triangle’s dual Voronoi line and the abstract continuous surface done by the oracle. Additionally, a Delaunay ball centered at the Steiner point circumscrib-ing the triangle forces it to conform to three criteria in the meshcircumscrib-ing process which are listed below. In this step, if a triangle’s dual does not intersect the surface it is removed from the triangulation, otherwise it is added to a refinement queue if it does not fulfill the criteria. [6] • A lower bound of the minimum angle the queued triangle is allowed to have, if it is

≤ 30° then the algorithm is proven to always converge to a solution.

• An upper bound of the maximum distance between the Steiner point and the triangle’s circumcenter.

• An upper bound of the maximum radius of the Delaunay ball circumscribing the tri-angle.

(14)

2 BACKGROUND

Finally, the refinement process is finished when the refinement queue is empty, leaving the current triangulation as the resulting mesh. [6]

Steiner point Circumcenter Continuous surface Voronoi dual

Figure 2.3: The Delaunay ball centered at the point of intersection on the continuous surface from a queued triangle’s dual

2.2.3 Numerical precision issues

As implied by the strictness of the Delaunay criterion, non-exact arithmetic such as floating point numbers cause considerable issues in Delaunay meshing algorithms. Since if preci-sion errors are enough to alter the validity of meshing criteria it will cause mesh construc-tions to be non-predictable from a theoretical standpoint. Research related to introducing a threshold value in the calculations to overcome exactness issues has been shown to be non-generalizable for different use cases. At this time, use of infinite precision arithmetic is shown to be the most promising approach of overcoming the problem while maintaining a valid Delaunay triangulation.

2.3

Related work

(15)

3 Methodology

As stated in the introduction, the difference in performance as well as the relative accuracy of each method is of interest for the comparison. The use of Perlin noise was also motivated as the continuous height field of choice due to its representation of varying use cases as well as maintaining determinism as described in section 2.1.2. Recall also that a focus of this report is to develop a procedure to handle chunk division of Delaunay meshing, which requires special consideration as section 3.1.2 details below.

3.1

Delaunay meshing

For the Delaunay refinement, the off-the-shelf solution CGALmesh [6] was used to imple-ment the oracle traits of the height field. CGALmesh additionally allows the use of exact arithmetic when verifying Delaunay criteria, as well as for performing oracle operations. This allows non-exact number types such as floating point to be used for performing the in-tersections of the height field while the Delaunay refinement process uses infinite precision. This reduces the supposed accuracy to the continuous height field, but is likely negligible in contrast to performance overhead of exact precision. As such, that is used in this report to minimize overhead in the performance comparison.

3.1.1 The oracle

We designed the oracle to provide the initial points at the sharp features formed as a con-sequence of the chunk division, with remaining points placed deterministically in a cross-formation according to the chunk size.

In addition, the intersection tests were first restricted to the chunk boundary and the height range of the Perlin noise in order to limit the necessary line segment to intersect the surface with. Then the restricted line segment is traced along the height field, evaluating whether the height field is below or above the line. It was designed as a binary search as line segments are very close to the intersection point and the height field is unlikely to fluctuate much on the segment. Since the endpoints of the segment are either below or above the surface it leads to a straightforward convergence. If the endpoints are both below or above, then it is very unlikely that the segment will hit anything and as such an intersection point can be considered to not exist. When the intersection trace is complete, the intersection point will serve as the Steiner point of a triangle as described in section 2.2.2.

3.1.2 Surface hole filling

As the above oracle forces the intersection to be constrained within the chunk and the Per-lin noise’s height range, the Delaunay refinement algorithm will only find Steiner points contained within to intersect the surface, thus the triangles will never overstep its chunk boundary. However, as seen in figure 3.1, this creates undesirable gaps between the chunks that must be merged.

(16)

3 METHODOLOGY

Figure 3.1: Undesirable gaps in the mesh as a consequence of chunk division

present in the refinement mesh due to a lack of control of whether a Steiner point is used to create new triangles or verify a valid triangulation. However, this is not an issue as the sides of the b)-regions can be considered to always have an edge to the chunk boundary corner vertices by adding an edge from the closest hull point if the corner is missing and traversing the polygonal chain of the mesh hulls as described below.

A polygonal chain is obtained from the 2D hull of area a) whose edges are provided by CGALmesh in no particular order. A hash map is used to give each hull vertex a reference to its two adjacent vertices it forms edges to, which grants a bidirectional graph like structure in which it is possible to traverse the hull vertices. The graph can then be used to obtain an ordered polygonal chain by starting at an arbitrary vertex and ending at the same point. This structure leads to an optimal time complexity of O(n) where n is the number of hull vertices, which should have no considerable performance impact on the whole meshing process.

a)

a)

a)

a)

a)

b)

b)

b)

b)

b)

(17)

3 METHODOLOGY

vertices corresponding to the region traversing to the other hull corner of the same chunk and then if not on the chunk boundary corner, going there and then continuing to the second chunk’s corresponding hull corner vertex, traversing through the second chunk hull to the corresponding first corner and if not on the chunk boundary corner, going there and finally back to the first vertex of the first chunk hull, forming a closed polygonal chain.

With the b)-regions in figure 3.2 guaranteed and clearly defined by the polygonal chain, the region can be triangulated, either directly using the chain or by using the same Delaunay refinement procedure again to fill the hole with the chain’s vertices as initial points or as Xiang and Jia [13] described in section 2.3. In this report, the first alternative is used as the second is prone to missing triangles due to the same reason the corner points are missing, and the third is prone to altering triangles of the a)-regions and thus risk altering the hull of other neighboring regions which can alter how they are merged, and thus the algorithm is no longer deterministic. Figure 3.3 shows the final result without any gaps.

Figure 3.3: A mesh of several chunks generated by Delaunay meshing

3.2

Grid meshing

For the fixed-grid method, a method of dividing the chunk size by the number of elements desired in each chunk is used to obtain the grid size that will conform exactly to the chunk boundaries. Points on the grid are then used to generate height values from the height field and are connected by creating two triangles between every four points. To ensure the best linear interpolation through the triangles, their shared diagonal edge may be swapped to minimize the diagonal edge length, as demonstrated by figure 3.4. The resulting mesh is then continuously defined without any holes and no special chunk division handling is required as the boundary points on the grid will be shared between each adjacent chunk. Figure 3.5 shows how the resulting mesh is structured.

3.3

Test setup

(18)

3 METHODOLOGY

Figure 3.4: An example of the diagonal swapping of the triangles created by the grid meshing

Figure 3.5: A mesh generated by grid meshing

3.3.1 Performance test

The performance of each method is tested by timing how long it takes to generate several chunks from start to finish, and the number of triangles in each resulting mesh is noted, in-cluding the merged borders. These metrics are then used to verify the time complexity of Delaunay refinement. This is done by using the time complexity of the Delaunay refinement and grid meshing as defined by equation 3.1, where t is the generation time, n is the number of triangles in the created mesh and c1, c2 are expected constants. The relative difference in time complexity as defined by equation 3.2 can then be obtained. This is done by cancel-ing out the factors responsible for the time complexities for the Delaunay and grid method. C is thereby the quotient of the constants in both time complexities and should be a rela-tively constant value. For the results, a mean and sample variance was then computed from aggregating the C-value of every combination of the grid and Delaunay parameter settings.

tDelaunay = c1· nDelaunay· log2(nDelaunay) tGrid= c2· nGrid

(3.1)

C =

tDelaunay

nDelaunay·log2(nDelaunay)

tGrid

nGrid

= c1

(19)

3 METHODOLOGY

3.3.2 Accuracy and determinism test

For the accuracy, it was verified from visual inspection of the generated graphics that both mesh generation methods create continuous meshes with no discernible gaps or any over-lapping when rendering an adjacent mesh from behind. As that is the case, it is possible to verify the accuracy of each mesh to the actual height field by tracing the intersection point of the respective meshes at particular points, comparing the height value of the mesh to what height is generated by the Perlin noise to obtain the approximation error of each method. A randomly selected 4 by 4 region was used for the generation and the center 2 by 2 region was used for the intersection traces which guarantees that the entire sampled region is covered by the generated mesh.

Lastly, as mentioned in the introduction, it is desired to verify the deterministic property of the Delaunay meshing. This is done by randomly selecting a 2 by 2 chunk region, testing each possible permutation of generating the chunks and verifying that the generated meshes have the same triangles as the first permutation.

3.3.3 Test parameters

For all tests, 6 grid sizes and 16 pairs of Delaunay meshing criteria parameters were used which are noted in tables below. One Perlin noise height field of high complexity and one of low complexity was used during the tests to compare robustness for different type of height fields as mentioned in the introduction, figure 3.6a and 3.6b display how they differ and table 3.1 detail which Perlin settings were used to generate them, where the amplitude scales the height values to exaggerate the noise effect. In addition, linear interpolation was used to interpolate the Perlin noise gradients. Further, a chunk size of 32 was used for all tests, as it is an adequate size due to the high complexity function’s high height fluctuation and should have no significant effect on the mesh generation process.

High complexity Low complexity

Seed 1203 100 Frequency 0.001 0.010 Lacunarity 2.420 2.000 Persistence 0.386 0.200 Octave count 12 5 Amplitude 228 25

Table 3.1: Perlin noise parameters used in all tests

(20)

3 METHODOLOGY

For the grid meshing, as seen in table 3.2, grid sizes in power of two were used to represent the quick access to each grid element that is possible to achieve through storing grids in a quadtree structure, which is of use for certain applications. Grid size 0.25 was chosen as the minimum size since the smallest Delaunay parameters used do not create similar triangle amounts, and the remaining grid sizes create meshes with triangles of similar size to the used Delaunay parameters.

Grid size 8 4 2 1 0.5 0.25

Table 3.2: Tested parameters for grid-based meshing

For the Delaunay meshing, only the criteria with an upper bound described in section 2.2.2 were used as it is desired that the generated triangles are well-shaped and it is shown that Delaunay refinement is known to converge with a lower angular bound less than 30°. Table 3.3 show which parameter pairs were tested, where α is the maximum allowed distance be-tween the Steiner point and a triangle’s circumcenter and β is the maximum allow Delaunay ball radius, henceforth in the following sections they will be referred to as distance and ra-dius. While the parameters are highly correlated, they attempt to minimize different aspects to the mesh generation which is why it is of interest to compare the listed combinations.

Distance α 3 2 1 0.5 3 2 1 0.5 3 2 1 0.5 3 2 1 0.5 Radius β 3 3 3 3 2 2 2 2 1 1 1 1 0.5 0.5 0.5 0.5

Table 3.3: Delaunay meshing criteria parameter pairs tested

3.4

Development setup

The main part of the project used the programming language C++, due to being the only supported programming language used by CGALmesh. For comparison reasons, C++ was used to implement the grid-based meshing as well. As previously mentioned, Perlin noise is widely used, as such there exists many off-the-shelf solutions implementing it. In this report the open-source library libnoise [15] was used to generate the continuous height field. To render the meshes, the video game engine Unity [16] was used to interface with the main project by a Windows library. The reason for using Unity was mainly due to its simplicity to setup for both user input and render output in comparison to setting up render engines such as OpenGL [17]. While the main project should be generalized enough to support other operating systems, the rendering pipeline displaying the resulting mesh is only supported by Windows.

3.4.1 Hardware

(21)

3 METHODOLOGY

3.4.2 Tests

Performance and determinism

The performance tests described in section 3.3 were implemented using the high resolution clock available in the C++ STL library chrono, where the clock was timed before each chunk generation with microsecond precision. As each method stores the resulting triangles in a list, the list size was polled to extract the memory use of the methods. The results of each generation were temporarily stored in a list that was written to disk after all generations were completed.

As the performance and determinism tests examine different aspects to the generation they were evaluated simultaneously using the permutation testing described in section 3.3. The permutation order was generated using the next_permutation function in the C++ STL library. After the first test, a copy of each mesh’s vertices was made. For the remaining tests, each mesh’s vertices were compared to the first copy, making a note of how many permutation discrepancies that were encountered in the results list.

Accuracy

The accuracy tests were conducted as described in section 3.3 using an intersection trace on the resulting mesh of each method. Unity’s built-in intersection tracer was used to trace down on the generated mesh to extract its height at specified height field points. The points are interspersed on a fine grid, purposely sized to be at least 20 times as small as the smallest grid-size used for the mesh generation. The points to check are generated in the C++-project by evaluating the height of the Perlin noise according to the grid.

(22)

4 Results

The results of the tests described in the methodology are presented here with some gen-eral observations. Section 4.1 and 4.2 describe ovgen-erall observations of each method together with the determinism test results and section 4.3 details the exact results obtained from the performance and accuracy tests.

4.1

Grid meshing

The results show the expected quadratic increase in computational cost and triangle count for the grid size of the grid-based method as seen in figure 4.1 and 4.2. This can also be observed in figure 4.3, which is expected. The determinism test was verified to hold with no permutation deviating from the other generations.

4.2

Delaunay meshing

In general, it can be observed that the distance parameter has no significant effect on the generation time and triangle count as shown by figure 4.4 and 4.5.

However, as seen in figure 4.6a it appears as if the accuracy is slightly improved if the dis-tance criterion is smaller than or equal to the radius criterion. Although this cannot be ob-served in figure 4.6b where there appears to be no clear correlation between the distance and radius criteria.

(23)

4 RESULTS

Distance Radius µf ailed permutations σf ailed permutations Sample failure rate

3 3 1.78 0.18 19% 2 3 2.59 0.26 27% 1 3 1.02 0.10 15% 0.5 3 1.24 0.12 11% 3 2 2.30 0.23 19% 2 2 2.40 0.24 29% 1 2 1.66 0.17 16% 0.5 2 1.93 0.19 16% 3 1 5.88 0.59 47% 2 1 5.64 0.57 45% 1 1 6.56 1.65 50% 0.5 1 5.12 0.51 36% 3 0.5 2.73 0.27 19% 2 0.5 1.22 0.12 11% 1 0.5 1.20 0.12 9% 0.5 0.5 1.59 0.16 10%

Table 4.1: Determinism test results of Delaunay meshing with high complexity Perlin noise

Distance Radius µf ailed permutations σf ailed permutations Sample failure rate

3 3 1.01 0.40 10% 2 3 1.29 0.13 13% 1 3 0.63 0.06 6% 0.5 3 0.50 0.05 9% 3 2 0.75 0.08 10% 2 2 1.61 1.95 15% 1 2 2.13 0.21 16% 0.5 2 1.82 0.18 14% 3 1 3.53 0.35 36% 2 1 2.61 0.26 30% 1 1 2.68 1.54 27% 0.5 1 3.81 1.73 33% 3 0.5 8.71 0.88 55% 2 0.5 8.99 1.11 55% 1 0.5 5.77 1.03 48% 0.5 0.5 4.20 0.42 34%

(24)

4 RESULTS 8 4 2 1 0.5 0.25 0 2,000 4,000 6,000 Grid size Generation time (µs )

(a) High complexity Perlin noise

8 4 2 1 0.5 0.25 0 1,000 2,000 3,000 Grid size (b) Low complexity Perlin noise Figure 4.1: Effect on grid generation time in microseconds per parameter

8 4 2 1 0.5 0.25 0 10,000 20,000 30,000 Grid size Number of triangles

(a) High complexity Perlin noise

8 4 2 1 0.5 0.25 0 10,000 20,000 30,000 Grid size (b) Low complexity Perlin noise Figure 4.2: Effect on grid triangle count per parameter

8 4 2 1 0.5 0.25 0 0.1 0.2 0.3 0.4 Grid size Appr oximation err or

(a) High complexity Perlin noise

8 4 2 1 0.5 0.25 0 0.03 0.05 0.08 0.1 Grid size

(25)

4 RESULTS 0.5 1 2 3 0.5 1 2 3 0 150,000 300,000 450,000 Radius Distance Generation time (µs )

(a) High complexity Perlin noise

0.5 1 2 3 0.5 1 2 3 0 75,000 150,000 225,000 Radius Distance

(b) Low complexity Perlin noise Figure 4.4: Effect on generation time in microseconds per parameter pair

0.5 1 2 3 0.5 1 2 3 0 2,000 4,000 6,000 Radius Distance Number of triangles

(a) High complexity Perlin noise

0.5 1 2 3 0.5 1 2 3 0 2,000 4,000 6,000 Radius Distance

(b) Low complexity Perlin noise Figure 4.5: Effect on triangle count per parameter pair

0.5 1 2 3 0.5 1 2 3 0 0.05 0.1 0.15 Radius Distance Appr oximation err or

(a) High complexity Perlin noise

0.5 1 2 3 0.5 1 2 3 0 0.01 0.02 0.03 Radius Distance

(26)

4 RESULTS

4.3

Relative observations

As seen by the tables below, it is clear that the grid method significantly outperforms the De-launay method in terms of generation time in general. Though it can be noted that DeDe-launay refinement’s time complexity is verified to hold as the constant C is relatively constant as shown in the following sections.

4.3.1 High complexity noise

Table 4.3 and 4.4 describe in detail what the figures 4.1-4.6a has shown. It can be seen that the approximation error mean µerror of both methods are comparable to their triangle count mean µtriangles. The mean of C was found to be µc = 30.9695 with a standard deviation σc= 4.89293.

It appears that the accuracy is strongly correlated to the triangle count, as the µerroris lower than the other method when µtrianglesis respectively higher. This is shown by the Delaunay ball radius set to 3 compared to grid size 4 where a lower µerror is observed for the Delau-nay method, likewise grid size 0.5, 1 and 2 have a lower µerror in comparison to respective Delaunay radius parameters 0.5, 1 and 2.

Distance Radius µtime(ms) σtime(ms) µtriangles σtriangles µerror σerror 2 3 9.69 0.41 180.56 8.54 0.163647 0.015885 3 3 9.71 0.47 182.26 11.58 0.168179 0.018031 1 3 9.77 0.52 183.20 12.62 0.163395 0.015002 0.5 3 10.57 0.43 195.54 9.21 0.154873 0.014655 1 2 21.88 1.70 376.27 35.39 0.110763 0.007141 2 2 22.23 1.71 385.01 36.99 0.110569 0.011492 0.5 2 22.31 1.64 384.44 34.13 0.108377 0.008158 3 2 22.31 1.74 385.13 36.73 0.108226 0.008724 2 1 101.54 6.95 1,584.27 128.24 0.050702 0.002802 3 1 102.15 7.41 1,596.26 136.79 0.050346 0.002591 1 1 102.47 6.70 1,600.72 124.64 0.051196 0.002704 0.5 1 103.22 9.35 1,617.60 171.57 0.051114 0.002721 0.5 0.5 451.77 27.85 6,600.81 439.70 0.023418 0.001150 1 0.5 454.55 34.01 6,653.48 533.97 0.023374 0.000937 2 0.5 455.52 36.76 6,681.93 581.48 0.023649 0.000960 3 0.5 457.47 34.96 6,711.44 554.88 0.023489 0.001034 Table 4.3: Test results of Delaunay meshing with high complexity Perlin noise sorted by µtime

Grid size µtime(µs) σtime(µs) µtriangles σtriangles µerror σerror 8 8.39 0.10 32.00 0.00 0.398443 0.057939 4 28.07 0.26 128.00 0.00 0.187500 0.013990 2 101.01 1.00 512.00 0.00 0.094662 0.004693 1 393.69 1.42 2,048.00 0.00 0.042950 0.001013 0.5 1,532.34 8.61 8,192.00 0.00 0.020740 0.000223 0.25 6,022.35 14.09 32,768.00 0.00 0.009871 0.000067

(27)

4 RESULTS

4.3.2 Low complexity noise

Table 4.5 and 4.6 describe in detail what the figures 4.1-4.6b has shown. Similarly to the high complexity noise, the approximation error mean µerror of both methods are comparable to their triangle count mean µtriangles. The mean of C was found to be µc = 40.5461 with a standard deviation σc= 6.29127.

It can be observed that the grid method achieves a lower approximation error in general, even when µtriangles of the Delaunay method is larger than that of the grid method. As mentioned in 4.2, the distance criterion can also be observed to have an effect on the mesh’s approximation error. Although as previously observed there appears to be no clear correla-tion.

Distance Radius µtime(ms) σtime(ms) µtriangles σtriangles µerror σerror 3 3 5.87 0.22 170.82 4.96 0.029558 0.012568 1 3 5.89 0.23 171.12 4.67 0.028128 0.009266 2 3 5.90 0.24 171.44 5.00 0.029014 0.012368 0.5 3 5.92 0.27 172.30 5.84 0.029195 0.011622 3 2 12.30 0.54 336.72 11.02 0.015888 0.007528 2 2 12.31 0.52 336.50 11.11 0.014296 0.004930 1 2 12.31 0.56 335.83 11.96 0.016290 0.007612 0.5 2 12.36 0.54 338.05 12.46 0.015213 0.005787 2 1 55.08 2.24 1,385.20 47.40 0.004848 0.001887 1 1 55.30 2.25 1,389.22 52.48 0.004735 0.001619 3 1 55.54 2.41 1,396.07 47.35 0.004466 0.001421 0.5 1 55.56 2.78 1,395.15 53.29 0.004791 0.001906 0.5 0.5 252.02 10.12 5,766.56 223.66 0.001184 0.000372 1 0.5 253.46 11.00 5,779.58 204.84 0.001166 0.000369 3 0.5 255.31 13.75 5,808.10 240.66 0.001227 0.000495 2 0.5 256.26 12.60 5,774.45 219.38 0.001219 0.000439 Table 4.5: Test results of Delaunay meshing with low complexity Perlin noise sorted by µtime

Grid size µtime(µs) σtime(µs) µtriangles σtriangles µerror σerror 8 4.17 0.04 32.00 0.00 0.093240 0.041892 4 13.40 0.12 128.00 0.00 0.023223 0.006804 2 47.89 0.23 512.00 0.00 0.005728 0.001576 1 196.17 0.74 2,048.00 0.00 0.001464 0.000377 0.5 789.58 2.55 8,192.00 0.00 0.000368 0.000113 0.25 3,008.38 9.39 32,768.00 0.00 0.000110 0.000044

(28)

5 Discussion

The results show that the Delaunay meshing method had limited success in achieving the set goals of this report.

5.1

Applicability

As the results show, the Delaunay meshing is comparable in robustness to the fixed-grid method. The relative time complexity cannot be overcome, but Delaunay refinement is still capable of creating meshes in real-time as shown by the generation time of one chunk taking less than 1 second. Additionally, using smaller chunk sizes for similarly smaller Delaunay meshing criteria can further improve the performance as shown by Xiang and Jia [13]. How-ever, without guaranteed determinism it is not suitable for applications depending on the triangle coordinates. If this can be overcome, then Delaunay refinement is indeed practical for meshing continuous height fields with chunk division as the results have shown.

5.2

Performance overhead

Regarding the expected time complexity, it was shown in the results with the C-value that the Delaunay method had an average constant overhead 30 and 40 times larger than the grid method for the high and low complexity noise respectively. This can be explained by the bi-nary search used in the intersection trace to find the Steiner points on the surface. From infor-mal observations the search required in average 15 and respectively 20 iterations to converge to the point for the high and low complexity noise, though it is uncertain why the number of iterations differed. Since each iteration required a Perlin noise value to be generated this scales directly to the grid-method where it was only required once. This seems to indicate that the Steiner point verification is responsible for the doubled constant overhead, which can be claimed with confidence as the Perlin noise is computationally expensive enough to represent a greater part of the generation time.

5.3

Errors sources

There are some potential sources of error that can impact the credibility of the results. As discussed above, this mainly stems from failing to achieve a fully deterministic generation, though it may also be because of the test setup.

5.3.1 Determinism

As it was found that the determinism test failed due to the Delaunay refinement algorithm, it is worth examining other implementations than CGALmesh. While it is known that De-launay refinement may not process the mesh in any specific order [2] [6], it should still have the same behavior for the same input.

5.3.2 Surface hole filling

(29)

5 DISCUSSION

though the impact on accuracy and total triangle count should be negligible. There is po-tential for investigating both Delaunay refinement as the hole filling algorithm and using it to further refine the several independent triangulations as done by Xiang and Jia [13]. Fur-thermore, Delaunay refinement with edge-refinement capabilities may be perfectly suited for the problem presented in this report and would likely not be affected by the missing triangles issue described in section 3.1.2.

5.3.3 Choice of parameters

As shown by the result, the accuracy was improved with a smaller distance criterion in re-lation to the radius. However, due to time constraints it was not possible to investigate the effect of decreasing the parameter further for each of the radius properties tested. Since the approximation error of the tested parameters was less than 0.5 it is likely to have a signifi-cant effect on the generation time and triangle count besides a likely smaller approximation error. The result of the low complexity result seems to indicate that poor parameter settings significantly worsen the accuracy of Delaunay, although this could also be because of lin-ear interpolation being used in the Perlin noise which produces several sharp features that Delaunay may have difficulty of accommodating.

In addition, it would be prudent to use grid size parameters that would generate meshes of near-equal size to that of the Delaunay method to see clearer if Delaunay refinement is capable of achieving better accuracy, or if it is indeed the larger triangle count having most effect.

5.4

Future work

As described above, there are certain areas of this study that may have contributed to the poor results of Delaunay refinement. Further investigation into the parameter settings may lead to improved accuracy or verification that the triangle count is the main contributing fac-tor, and other Delaunay refinement implementations may be more guaranteed of achieving deterministic results.

5.4.1 Volumetric terrain

While Delaunay refinement does not hold any particular advantage over grids for height field generation, it may perform better for 3D terrain generation created by density functions or multi-layered height fields such as the work of Santamaría-Ibirika et al. [1]. A suggested comparison would be to that of voxels (cubes) which are commonly employed in real-time volumetric terrain applications [1], which requires the use of an isosurface extraction algo-rithm such as marching cubes [5] that may potentially have more overhead or increased complexity in its design compared to a Delaunay-based method. Additionally, it may be necessary for chunk division to divide the height as well, which requires more considera-tion of how the merging is handled. Though this has been shown to be possible through 3D divide and conquer Delaunay refinement algorithms [18].

5.4.2 Delaunay edge refinement

(30)

6 Conclusion

(31)

Bibliography

[1] Aitor Santamaría-Ibirika, Xabier Cantero, Mikel Salazar, Jaime Devesa, Igor Santos, Ser-gio Huerta, and Pablo G. Bringas. Procedural approach to volumetric terrain genera-tion. The Visual Computer, 30(9):997–1007, 2014. ISSN 1432-2315. doi: 10.1007/s00371-013-0909-y.

[2] Pascal Jean Frey and Paul-Louis George. Delaunay-based Mesh Generation Methods, pages 235–273. ISTE, 2010. ISBN 9780470611166. doi: 10.1002/9780470611166.ch7.

[3] Laurent Rineau and Mariette Yvinec. Meshing 3D Domains Bounded by Piecewise Smooth Surfaces, pages 443–460. Springer Berlin Heidelberg, Berlin, Heidelberg, 2008. ISBN 978-3-540-75103-8. doi: 10.1007/978-3-540-75103-8_25.

[4] Noor Shaker, Julian Togelius, and Mark J. Nelson. Procedural Content Generation in Games, chapter 1, pages 6–7. Springer International Publishing, 2016. ISBN 978-3-319-42716-4. doi: 10.1007/978-3-319-978-3-319-42716-4.

[5] William E. Lorensen and Harvey E. Cline. Marching cubes: A high resolution 3d surface construction algorithm. SIGGRAPH Comput. Graph., 21(4):163–169, August 1987. ISSN 0097-8930. doi: 10.1145/37402.37422.

[6] Clément Jamin, Pierre Alliez, Mariette Yvinec, and Jean-Daniel Boissonnat. Cgalmesh: A generic framework for delaunay mesh generation. ACM Trans. Math. Softw., 41(4): 23:1–23:24, October 2015. ISSN 0098-3500. doi: 10.1145/2699463.

[7] Noor Shaker, Julian Togelius, and Mark J. Nelson. Procedural Content Generation in Games, chapter 4, pages 61–62. Springer International Publishing, 2016. ISBN 978-3-319-42716-4. doi: 10.1007/978-3-978-3-319-42716-4.

[8] F. K. Musgrave, C. E. Kolb, and R. S. Mace. The synthesis and rendering of eroded fractal terrains. In Proceedings of the 16th Annual Conference on Computer Graphics and Interactive Techniques, SIGGRAPH ’89, pages 41–50, New York, NY, USA, 1989. ACM. ISBN 0-89791-312-4. doi: 10.1145/74333.74337.

[9] K. Perlin and E. M. Hoffert. Hypertexture. In Proceedings of the 16th Annual Conference on Computer Graphics and Interactive Techniques, SIGGRAPH ’89, pages 253–262, New York, NY, USA, 1989. ACM. ISBN 0-89791-312-4. doi: 10.1145/74333.74359.

[10] Pascal Jean Frey and Paul-Louis George. Advancing-front Technique for Mesh Generation, pages 201–233. ISTE, 2010. ISBN 9780470611166. doi: 10.1002/9780470611166.ch6. [11] A. Agrawal, M. Radhakrishna, and R. C. Joshi. Dynamic multiresolution level of detail

mesh simplification for real-time rendering of large digital terrain models. In Proceedings of the IEEE INDICON 2004. First India Annual Conference, 2004., pages 278–282, Dec 2004. doi: 10.1109/INDICO.2004.1497755.

(32)

BIBLIOGRAPHY

[13] Chuan-Jie Xiang and Yunde Jia. Practical algorithm of building delaunay triangle mesh for terrain modeling. volume 4875, pages 1004–1010, 2002. doi: 10.1117/12.477107. [14] Leo J. Guibas and Jorge Stolfi. Primitives for the manipulation of general subdivisions

and the computation of voronoi diagrams. In Proceedings of the Fifteenth Annual ACM Symposium on Theory of Computing, STOC ’83, pages 221–234, New York, NY, USA, 1983. ACM. ISBN 0-89791-099-0. doi: 10.1145/800061.808751.

[15] Jason Bevins. libnoise: a portable, open-source, coherent noise-generating library for C++, accessed 17th of May 2017. URL http://libnoise.sourceforge.net/. [16] Unity Technologies. Unity - game engine, accessed 17th of May 2017. URL

https://unity3d.com/.

[17] Khronos Group. OpenGL - the industry standard for high performance graphics, ac-cessed 17th of May 2017. URL https://www.opengl.org/.

(33)
(34)

References

Related documents

Methodology/approach – A literature study, with Lean implementation, measuring starting points for improvement work, soft values and the effects of the improvement work in focus

Svar: Det f¨ oljer fr˚ an en Prop som s¨ ager att om funktionen f (t + x)e −int ¨ ar 2π periodisk, vilket det ¨ ar, sedan blir varje integral mellan tv˚ a punkter som st˚ ar p˚

(a) (2p) Describe the pattern of nonzero entries in the basis matrix used to determine the coefficients for polynomial interpolation using each of the three bases.. (b) (2p) Rank

(b) All previous computations can still be used when new data points are added in the following type of polynomial representations:..

These points will be added to those obtained in your two home assignments, and the final grade is based on your total score.. Justify all your answers and write down all

the initial guess is not close enough to the exact solution Solution: the largest eigenvalue of the iteration matrix has absolute value equal to 1.. If this information is

(c) If 100 iteration steps were needed by the Gauss-Seidel method to compute the solution with the required accuracy, how do the num- ber of operations required by Gaussian

(c) If 100 iteration steps were needed by the Gauss-Seidel method to compute the solution with the required accuracy, how do the num- ber of operations required by Gaussian