Modeling, Evaluation, Editing, and Illumination of Three Dimensional Mazes and

Caves for Computer Games

DISSERTATION

Presented in Partial Fulfillment of the Requirements for the Degree Doctor of Philosophy in the Graduate School of The Ohio State University

By

Matthew J. Boggus

Graduate Program in Computer Science and Engineering

The Ohio State University

2012

Dissertation Committee:

Roger Crawfis, Advisor

Han-Wei Shen

Richard Parent

Copyright by

Matthew J. Boggus

2012

Abstract

Caves are commonly used as environments in computer games. As the popularity of open world games rises, so does the demand for expansive virtual environments. To ease this cost, many tools have been developed to create and edit content for games including terrain, plants, roads, buildings, and cities. The same is not true for caves.

We present data structures and algorithms to create, evaluate, edit, and illuminate three dimensional models of caves for use in computer games. Game levels can be classified according to their spatial configuration: linear, maze, or open. Caves formed by the same geological process have similar features. These define parameters that can be used to partially or fully automate the creation of cave models of different spatial configurations. Additional information about the model such as its volume, number of branching paths, and number of connected components can be used by the designer in evaluating and editing the model to meet gameplay requirements. To assist in editing of cave models we propose a new data structure and framework and compare its use to existing modeling approaches. Physically based illumination of a cave typically results in low level lighting which is not suitable for games. We introduce a new illumination model based on radiant flux that can be used to ensure a sufficient amount of light is present throughout the cave. The new illumination model can also be adapted to assist in player navigation. Illuminating a scene according to distance to objects within it creates

ii highlights that captures the player’s visual attention. A user study was done to evaluate the new technique.

iii

To Meg and my parents for their love and support.

iv

Acknowledgments

This document could not have been completed without assistance from many individuals, and I am grateful for their help. First and foremost I would like to thank my advisor, Roger Crawfis, for his time and advice. I would also like to thank E. Scott Bair for providing domain knowledge in Geology. More generally, I am very grateful for the opportunity to work with the knowledgeable faculty, collaborative graduate students, and supportive staff in the Department of Computer Science and Engineering at The Ohio

State University. I would also like to thank the Department of Computer Science and

Engineering and The Computer Graphics Group at Ohio State for financial support in publishing this work.

v

Vita

2006...... B.A. Computer Science and Mathematics, Hiram College

2007...... University Fellow, The Ohio State University

2008-2011 ...... Graduate Teaching Associate, Department of Computer Science and Engineering, The Ohio State University

2012...... Visiting Instructor, Department of Computer Science, Oberlin College and Conservatory

Publications

Boggus, M. and Crawfis, R. 2010. Distance Field Illumination: a Rendering Method to Aid in Navigation of Virtual Environments, In Proceedings of the 6th International Symposium on Visual Communication, 501-510.

Boggus, M. and Crawfis, R. 2010. Prismfields: A Framework for Interactive Modeling of Three Dimensional Caves, In Proceedings of the 6th International Symposium on Visual Communication, 213-221.

Boggus, M. and Crawfis, R. 2010. Distance based illumination as a navigational aid. In Proceedings of the 2010 ACM SIGGRAPH Symposium on interactive 3D Graphics and Games (I3D '10). ACM, New York, NY, 1-1.

Boggus, M. and Crawfis, R. 2009. Explicit Generation of 3D Models of Solution Caves for Virtual Environments, In Proceedings of the 2009 International Conference on Computer Graphics and Virtual Reality, Las Vegas, NV, 85-90.

vi

Boggus, M. and Crawfis, R. 2009. Procedural Creation of 3D Solution Cave Models, In Proceedings of the 20th IASTED International Conference on Modelling and Simulation, Banff, Alberta, 180-186.

Fields of Study

Major Field: Computer Science and Engineering

vii

Table of Contents

Abstract ...... ii

Dedication ...... iv

Acknowledgments...... v

Vita ...... vi

List of Tables ...... xii

List of Figures ...... xiii

Chapter 1: Introduction ...... 1

Chapter 2: Related Works ...... 9

2.1: Fun and Games ...... 9

2.2: Video Game Level Design ...... 10

2.3: Speleology – the Study of Caves ...... 17

2.3.1: Solution Caves ...... 19

2.3.2: Solution Cave Passages ...... 22

2.3.3: Solution Cave Patterns ...... 25

2.4: Cave Mapping and Modeling ...... 28

2.5: Terrain Modeling and Rendering ...... 32

viii

2.5.1: Heightfields ...... 32

2.5.2: Volume Elements ...... 34

2.5.3: Run-length Encoded Terrain ...... 34

2.6: Illumination Models ...... 37

2.7: Perception and Navigation in a Virtual Cave ...... 40

Chapter 3: Linear and Branching Maze Cave Levels ...... 43

3.1: Curve and Surface Modeling ...... 43

3.2: Single Passage Cave Modeling for Linear Levels ...... 46

3.2.1: Phreatic Passages ...... 46

3.2.2: Vadose Passages ...... 48

3.2.3: Combination Passages ...... 51

3.2.4: Varying Passages ...... 52

3.3: Cave Passage Modeling for Branching Maze Levels ...... 56

Chapter 4: Island Maze and Open Cave Levels ...... 60

4.1: Terrain Modeling ...... 60

4.2: Cave Model Construction Using Cave Patterns ...... 70

4.3: Level Visualization and Evaluation ...... 80

4.3.1: Model Visualization ...... 82

4.3.2: Level Analysis ...... 86

ix

Chapter 5: Modeling and Editing of Non-Planar 3D Caves ...... 94

5.1: Prismfield Framework ...... 94

5.1.1: Prismfield Data Structure ...... 94

5.1.2: Prismfield Vertical Drilling ...... 97

5.1.3: Prismfield Horizontal Drilling ...... 99

5.1.4: Prismfield Framework Rendering ...... 101

5.2: Implementation and Performance Results ...... 104

5.2.1: Prismfield Rendering ...... 104

5.2.2: Navigation with Prismfields ...... 109

Chapter 6: Illumination of Caves in Computer Games ...... 116

6.1: Cave Illumination using Current Illumination Algorithms ...... 117

6.1.1: Light Reflectance Models ...... 117

6.1.2: Ambient Occlusion ...... 122

6.2: Light as Radiant Flux ...... 124

6.2.1: Cave Level Geometry and Volumes ...... 128

6.2.1.1: Volumes in Linear Levels ...... 130

6.2.1.2: Volumes in Branching Maze Levels ...... 131

6.2.1.3: Volumes in Island Maze Levels ...... 132

6.2.1.4: Volumes in Open Levels ...... 134

x

6.2.2: Estimating Absorptance...... 136

6.2.2.1: Absorptance and Volume Length ...... 136

6.2.2.2: Absoprtance and Volume Shape ...... 139

6.3: Path Illumination ...... 144

6.3.1: Implementation ...... 146

6.3.2: Generalization ...... 149

Chapter 7: Path Illumination for Navigational Assistance ...... 152

7.1: Distance Illumination and Navigational Aids ...... 152

7.1.1: Screen Space Pointing Arrow ...... 158

7.1.2: World or Camera Space Pointer ...... 159

7.1.3: World Space Path ...... 160

7.1.4: Screen Space Map ...... 160

7.2: User Study ...... 160

7.2.1: User Study – Quantitative Results ...... 162

7.2.2: User Study – Qualitative Results ...... 165

Chapter 8: Conclusion...... 171

References ...... 173

xi

List of Tables

Table 3.1. Linear level properties ...... 59

Table 3.2. Branching level properties ...... 62

Table 4.1. Number of possible level layouts for a given size ...... 84

Table 4.2. Navigation mesh properties ...... 94

Table 4.3. Adjacency graph properties ...... 96

Table 5.1. Construction and rendering comparison ...... 110

Table 5.2. Prismfield resolution scaling performance ...... 110

Table 6.1. Table of symbols and terms ...... 129

Table 7.1. User study times...... 166

Table 7.2. User study time/distance ratios ...... 167

Table 7.3. User study (expert times) ...... 167

Table 7.4. User study (expert time/distance ratios) ...... 168

Table 7.5. User study survey results ...... 169

xii

List of Figures

Figure 1.1 Metroid screenshot ...... 1

Figure 1.2 Donkey Kong Country screenshot...... 2

Figure 1.3 Final Fantasy VII screenshot ...... 2

Figure 1.4 Resident Evil 4 screenshot...... 3

Figure 1.5 Halo: Reach screenshot ...... 3

Figure 2.1 Linear level example ...... 13

Figure 2.2 Branching maze level example ...... 14

Figure 2.3 Island maze level example ...... 15

Figure 2.4 Open level example ...... 16

Figure 2.5 Level graph examples ...... 18

Figure 2.6 Photograph of a cave interior ...... 21

Figure 2.7 World karst map ...... 22

Figure 2.8 Water table illustration ...... 23

Figure 2.9 Cave passage cross sections ...... 24

Figure 2.10 Photograph of a phreatic cave passage interior ...... 25

Figure 2.11 Photograph of a vadose cave passage interior ...... 26

Figure 2.12 Branchwork cave patterns ...... 28

Figure 2.13 Maze cave patterns ...... 29

Figure 2.14 Overhead map of Padavka Chamber ...... 30

xiii

Figure 2.15 Extended elevation map of Rabbit Cave ...... 30

Figure 2.16 Dead Bats Cave and Cold Wind Cave model ...... 31

Figure 2.17 3D cave model composed of line segments ...... 31

Figure 2.18 Big Foot Cave model ...... 32

Figure 2.19 Lechuguilla Cave model ...... 32

Figure 2.20 Virtual cave model ...... 33

Figure 2.21 2D deformable heightfield ...... 35

Figure 2.22 Geological core ...... 37

Figure 2.23 Run-length encoding terrain rendering problem ...... 38

Figure 2.24 Blinn-Phong illumination model ...... 39

Figure 3.1 Bezier curve examples ...... 47

Figure 3.2 Curve sweeping example ...... 48

Figure 3.3 Phreatic cave passage model ...... 50

Figure 3.4 Vadose cave passage model ...... 53

Figure 3.5 Combination cave passage model ...... 54

Figure 3.6 Overlapping cave passages ...... 55

Figure 3.7 Front view of swept cave passage (rescaled cross section) ...... 56

Figure 3.8 Side view of swept cave passage (rescaled cross section) ...... 57

Figure 3.9 Front view of swept cave passage (morphed cross section) ...... 57

Figure 3.10 Side view of swept cave passage (morphed cross section) ...... 58

Figure 3.11 Branching maze level and tree ...... 60

Figure 4.1 DTEM data ...... 65

xiv

Figure 4.2 Heightfield terrain from DTEM data ...... 66

Figure 4.3 Midpoint displacement example...... 67

Figure 4.4 Terrain made by subdivision ...... 69

Figure 4.5 Terrain altered by thermal weathering (3 iterations) ...... 69

Figure 4.6 Terrain altered by thermal weathering (after 10 iterations) ...... 70

Figure 4.7 Terrain altered by thermal weathering (after 20 iterations) ...... 70

Figure 4.8 Terrain before and after clamping to from a valley ...... 71

Figure 4.9 Terrain before and after clamping to from a plateau ...... 72

Figure 4.10 Terrain smoothing example ...... 73

Figure 4.11 Artist made terrain ...... 74

Figure 4.12 Flowchart to create a planar cave ...... 75

Figure 4.13 Revised flowchart to create a planar cave ...... 77

Figure 4.14 Cave layout example ...... 78

Figure 4.15 Procedurally generated branchwork maze patterns ...... 80

Figure 4.16 Procedurally generated spongework maze pattern ...... 81

Figure 4.17 Screenshots of cave from first person view ...... 82

Figure 4.18 Cave connected component visualization ...... 86

Figure 4.19 Cave height visualization ...... 87

Figure 4.20 Cave width visualization ...... 88

Figure 4.21 Cave length visualization ...... 89

Figure 4.22 Island maze level example ...... 90

Figure 4.23 Island maze level waypoint graph example ...... 91

xv

Figure 4.24 Island maze level navigation mesh ...... 92

Figure 4.25 Island maze level navigation mesh with adjacency graph ...... 93

Figure 5.1 Prismfield example (from side) ...... 99

Figure 5.2 Prismfield example (from above) ...... 100

Figure 5.3 Prismfield vertical tunneling ...... 101

Figure 5.4 Prismfield horizontal tunneling ...... 102

Figure 5.5 3D cave model made using prismfields (1) ...... 106

Figure 5.6 3D cave model made using prismfields (2) ...... 106

Figure 5.7 Prism rendering as shown from above ...... 109

Figure 5.8 Prismfield and voxel datasets ...... 111

Figure 5.9 Vertical slice of a 3D model ...... 112

Figure 5.10 Vertical slice of a 3D model with superimposed regular grid ...... 113

Figure 5.11 Model slice represented using pixels ...... 113

Figure 5.12 Model slice represented using prismfields ...... 114

Figure 5.13 Prismfield sampling ...... 116

Figure 5.14 Prismfield waypoint graph ...... 117

Figure 5.15 Pixel waypoint graph ...... 118

Figure 6.1 Illumination example from Thief: Deadly Shadows ...... 120

Figure 6.2 Cook-Torrence reflectance model ...... 121

Figure 6.3 Map of Stuart Bat Cave ...... 122

Figure 6.4 Visualization of direct illuminaton in Stuart Bat Cave ...... 122

Figure 6.5 Map of Swamp Cave ...... 123

xvi

Figure 6.6 Visualization of direct illumination in Swamp Cave ...... 123

Figure 6.7 Visualization of light reflection in Stuart Bat Cave ...... 124

Figure 6.8 Visualization of light reflection in Swamp Cave ...... 125

Figure 6.9 Ambient occlusion example (1)...... 126

Figure 6.10 Ambient occlusion example (2) ...... 127

Figure 6.11 Radiant flux in a volume ...... 130

Figure 6.12 Decomposition of a volume...... 132

Figure 6.13 Example of linear level decomposition ...... 133

Figure 6.14 Example of branching maze level decomposition ...... 134

Figure 6.15 Example of flux in a cave with multiple entrances ...... 135

Figure 6.16 Example of island maze level decomposition ...... 137

Figure 6.17 Example of open level decomposition ...... 138

Figure 6.18 Volume with labels used to describe flux transmission ...... 139

Figure 6.19 The effect of volume length in flux transmission ...... 141

Figure 6.20 Photons traced through a cylinder ...... 143

Figure 6.21 Cylinder with surface normals of its cross sections ...... 144

Figure 6.22 Examples of truncated cone volumes ...... 145

Figure 6.23 Example of elbow volume ...... 146

Figure 6.24 Path of multiple light reflection within a cave ...... 148

Figure 6.25 Cave model lit using path illumination and area sources (1) ...... 152

Figure 6.26 Cave model lit using path illumination and area sources (2) ...... 152

Figure 6.27 Cave model lit using path illumination and a point source ...... 153

xvii

Figure 7.1 Distance field illumination of a maze as seen from above ...... 156

Figure 7.2 First person, panoramic view of maze starting position ...... 157

Figure 7.3 First person view in the maze (1) ...... 157

Figure 7.4 First person view in the maze (2) ...... 158

Figure 7.5 First person view in the maze (3) ...... 158

Figure 7.6 First person view in the maze (4) ...... 159

Figure 7.7 Four examples of navigational aids ...... 161

Figure 7.8 Two examples of navigational aids in Lego Harry Potter: Years 1-4 ...... 162

Figure 7.9 Maze used in user study ...... 165

Figure 7.10 Example of distance illumination using linear mapping (1) ...... 170

Figure 7.11 Example of distance illumination using quadratic mapping (1) ...... 171

Figure 7.12 Example of distance illumination using linear mapping (2) ...... 172

Figure 7.13 Example of distance illumination using quadratic mapping (2) ...... 172

xviii

Chapter 1: Introduction

Caves are commonly used as environments in computer games. Figures 1.1 through 1.5 show the graphical evolution of caves in computer games over the past few decades as seen in a variety of popular game franchises. Each figure represents a different generation of video game console hardware, starting from the early 80’s and continuing to the present day.

Figure 1.1: Metroid, on the Nintendo Entertainment System in 1984 (Screenshot from MobyGames, http://www.mobygames.com/game/nes/metroid/screenshots).

1

Figure 1.2: Donkey Kong Country, on the Super Nintendo Entertainment System in 1994 (Screenshot from MobyGames, http://www.mobygames.com/game/snes/donkey-kong- country/screenshots).

Figure 1.3: Final Fantasy VII, on the PlayStation in 1997 (Screenshot from MobyGames, http://www.mobygames.com/game/playstation/final-fantasy-vii/screenshots). 2

Figure 1.4: Resident Evil 4, on the GameCube in 2005 (Screenshot from MobyGames, http://www.mobygames.com/game/windows/resident-evil-4/screenshots).

Figure 1.5: Halo: Reach, on the Xbox360 in 2010 (Screenshot from Device Magazine, http://www.devicemag.com/2011/03/14/halo-reach-defiant-map-pack-review/ambush/).

3

As the popularity of open world games rises, so does the demand for expansive virtual environments. A large virtual world requires an equally large number of hours for artists to create it. The average cost of developing a game on the most recent generation of console hardware (Microsoft’s Xbox360, Sony’s PlayStation3, and Nintendo’s Wii) is

$10 million [66]. This is a significant increase from the $3-5 million on the previous generation (Microsoft’s Xbox, Sony’s PlayStation2, and Nintendo’s GameCube) [66].

Partially driven by the motivation to ease this cost, many methods and tools have been developed to procedurally create virtual worlds [26]. There are methods to make natural objects like plants [86], terrain [34][73], and rocks [25][52] as well as ones that create man-made structures like buildings [72][122]. Another group of algorithms take these objects and distribute them to form realistic looking cities [80] or landscapes [24]. While these two settings have a large body of research on procedural and artist-assisted content creation, the same is not true for caves. Also, there is limited work on automatically incorporating procedurally generated content into games. The focus of this thesis is on data structures and algorithms for modeling and illumination of caves, with particular focus on the application area of computer games. Given how frequently caves are used as an environment in computer games, this reason alone merits study of the topic. This research also benefits films that use computer models of caves. Some prominent past examples include the Harry Potter and Lord of the Rings series.

This research can also be applied outside of the entertainment industry. Another application area is support of science, technology, engineering, and mathematics (also called STEM) education. Caves are interesting to many different academic fields. For

4 biologists, caves provide samples of extremophiles: microorganisms that thrive in harsh living conditions. Geologists also find unique specimens to examine within caves.

Hydrologists study caves due to their role in the water cycle. Anthropologists and archaeologists study caves to determine how they were used and altered by humans in the past. There are many ways to study caves. A thorough understanding of modeling caves is the first step to more advanced simulations on speleogenesis (cave formation), karstification (terrain formation above caves), and groundwater transport.

Caves are also used in primary education. In popular culture caves are viewed as mysterious. The desire to explore the unknown helps the student engage and feel invested in learning more about STEM topics related to caves. The final lesson in a sequence on caves could be a field trip to gain first-hand experience. This is not reasonable for every class to do. The closest cave may be hours away. Nearby caves might be hard to maneuver in. They may also be dangerous for novices to explore and require special safety equipment. In many cases, exploring a virtual cave is a much more practical learning activity for the class.

In order to create a virtual cave environment, a couple of pieces of information are needed. First, geometry provides the general shape of the cave. There are multiple issues to consider in this task. We want to be able to specify individual walls and surfaces in the cave. We should also allow placement of multiple rooms or passages and connect them to form larger caves. The shape of cave passages must be considered when adding objects into the environment like stalagmites and stalactites. After defining the shape of the cave, adding texture and material information, when coupled with lighting, completes

5 the virtual cave environment. Since virtual caves have applications in science and entertainment, examination of physically and perceptually based illumination should be done to determine ideal lighting for each case.

The contributions of this thesis explore the topics on modeling and illumination of cave environments listed in the previous paragraph. Given the wide variety of users, there are a number of ways to evaluate the results. For a scientist the central requirement will be physical accuracy. For an elementary school student we may want to highlight key features of the cave to reinforce terms and concepts they learned in class. For a game level designer we want to know if the environment is fun to play in. There is a fairly broad amount of work on physically based modeling and perception based illumination which we will mention throughout this thesis, but our primary focus will be on evaluating the results for use in games.

The contributions of this thesis are as follows:

 An illumination model that distributes energy in a scene, creating a global

illumination effect which can be approximated in real-time.

 An illumination based navigational aid that is as effective in guidance as

existing aides but more subtle.

 Methods to visualize and evaluate spatial properties of game levels and

mazes.

 Procedural and parameterized of caves and mazes.

 A framework for interactive editing and construction of navigational data

structures for 3D mazes and caves.

6

The rest of this chapter summarizes the organization of the thesis, including where each contribution can be found.

Chapter 2 overviews the task of modeling and illuminating scenes, including caves, and introduces related works in a variety of areas. This includes Speleology (the study of caves), existing software for surveying and mapping caves, spatial data structures, illumination models, navigation within virtual environments, and game level design. Chapters 3 and 4 are centered on creating and evaluating models of caves based on four level types introduced in this chapter.

Chapter 3 describes methods to create linear and branching maze levels based on models of cave passages. A cave passage is comparable to a room or hallway in a building as well as a linear level. Passages formed by the same geological process have similar characteristics. For example, the shape of a cave passage sculpted by sediment transport via water is based on the water level within that passage over time [78].

Parameters and methods for creating different types of cave passages can be determined using domain knowledge from Speleology. Branching maze levels can be made by combining multiple linear levels, with a few adjustments. Chapter 3 concludes with discussion of metrics used to describe features of the levels that can be used by a level designer to evaluate the level.

Chapter 4 introduces methods to create the remaining game level types: island mazes and open levels. We describe two approaches: one based on cave patterns and one on and fitness evaluation. Just as individual cave passages have similarities, connected passages form distinctive patterns as well [78]. Both approaches

7 use the same representation of the model. Terrain data is used to create floors and ceilings of the cave. Cave patterns can be used to place the walls within the cave. These patterns may come from existing caves or be created procedurally. Creating the floor, ceiling, and walls procedurally creates a nearly unlimited design space of models. The final topic in this chapter is discussion of methods to evaluate these models using visualization techniques and automated methods.

While it is possible to incorporate user input in the contributions of the previous two chapters, artists need precise control in placing details of cave models in computer games. There are many existing programs for terrain editing. With these tools, artists can easily modify heightmap terrains. The goal of the third contribution of this thesis, and the content of Chapter 5, is to allow the same for cave models. Since heightmaps are limited in their ability to model caves, a new data structure and an associated framework are presented that allow interactive modeling of caves at a real time rate. This framework includes a new data structure used to represent the shape of the cave, methods to interact with it, and rendering methods to display the model.

The final contributions of this thesis, in Chapters 6 and 7, deal with illumination.

Physically based illumination of a cave will result in many areas in it being completely dark, which would make navigation within it very difficult. In Chapter 6 we introduce the use of flux-based lighting of caves that can be used to ensure complete illumination of the cave. Chapter 7 generalizes the model and describes an application for it: navigation assistance within virtual environments. In order to evaluate the claim that distance illumination is a novel, viable, and useful method to assist in navigation within a virtual

8 environment, a user study was done to compare it with existing navigational aids such as pointing devices, maps, and paths. Chapter 8 summarizes the contributions of the thesis, describes further extensions to the contributions in Chapters 3-7, and lists additional areas for future work.

9

Chapter 2: Related Works

In this chapter we discuss related works to frame the problems we address in this thesis. We intend to model and illuminate caves for use in computer games, so we provide background information on games and their purpose – fun – first.

2.1 Fun and Games

The formal definition of a game is a rule-based system in which the goal is for one player to win [18]. Some computer games are better categorized as puzzles or toys. A puzzle is a rule based system in which the goal is to find a solution. Toys provide interaction but do not have a goal to work toward. Most computer games fall between these two extremes. All of them are a form of structured playing. Playing provides a number of psychological benefits. The one most associated with games is fun or enjoyment. A recent survey of sources of fun in games can be found in [108]. While fun is difficult to define and quantify, there are several generally accepted characteristics of computer games that make them fun [62]. The first is fantasy [61]. Computer games take place in a virtual world that does not have the same limitations as the real world. This gives designers a lot of freedom, allowing physically unrealistic characters and environments.

10

The next fun characteristic of games is challenge [61]. Games that are too easy are boring and games that are too hard are frustrating. Designers can visualize challenge by plotting player difficulty over time. Aponte et al. introduce methods to assist in scaling difficulty in single player games and examine the effect that challenge has on player enjoyment of a game [3]. A more recent study shows that dynamic adjustment of difficulty increases the enjoyment of experienced players, but not novice ones [47].

The last of the commonly accepted fun characteristics of games is curiosity [61].

A concrete example of this is exploration of virtual worlds. A more abstract example is learning gameplay elements over time through experimentation and investigation.

Curiosity is often at odds with challenge. If a player is fearful of failing a challenge or losing a conflict they will be less apt to let their curiosity drive them to explore new areas of a level. The balance between curiosity and challenge is one method of classifying computer games and levels within them [61]. Caves in computer games can serve two purposes: being an interesting environment to explore or providing a space to engage in conflicts. Models for these two purposes will be designed differently. In order to evaluate models of caves for use in computer games we must know the different types of levels commonly used in computer games.

2.2 Video Game Level Design

The word level has several meanings in the context of a game. We define a level as an area within the virtual world of a computer game. There are two parts of level

11 design: environment modeling and placement of gameplay elements. Environment modeling is the creation of the general appearance of the scene including its geometry, textures, and lighting. Current computer games feature two and three dimensional environments. We focus on three dimensional environments as they take longer to create.

The amount of time needed to create a 3D game level depends on the amount of graphical detail desired. Using placeholder geometry a level designer can create a level prototype in a few hours. For a level in a commercial game, the designer has to plan the shape of the level, create the terrain, create and place objects like trees and rocks, place particle and sound special effects, texture the geometry, set exterior and interior lighting, and repeatedly test the level for bugs, game balance, and fun. A complete level can take 11 or more days or work by the designer [35]. Our goal is to improve the workflow of the designer by automating some of the steps in the level design process.

Placement of gameplay elements is a rich and interesting topic. Different areas within the environment may need to be marked for different gameplay activities or behaviors. Objects like doors, portals, teleporters, locks, and keys can be used to partition the game world and restrict player movement. Placement of allies, enemies, and resources plays a large role in balancing the difficulty of a game. Additional data to facilitate behaviour of game characters, like pathfinding nodes, may be needed as well.

While these issues pose a number of challenges to game designers, they are often specific to individual games or genres, so they will not be discussed in detail in this dissertation.

A first attempt at categorizing and analyzing gameplay patterns, which may lead to automated methods for placement of game elements, can be found in [67] and [68].

12

Spatial configurations are one way level designers categorize gameplay experiences [13][75]. The first is linear. Linear levels consist of a path on a single axis or curve. Game elements like goals, challenges, obstacles, or contests are placed along the path to create fun experiences for the player. This type of game level favors challenge over curiosity as the player does not have the option to explore. An example of a linear level is shown in Figure 2.1. It shows a level within Final Fantasy XIII where the player enters The Skywalk in the bottom right and proceeds to the next area Expressway in the top left. Along the way the player encounters monsters to fight or sneak past.

Figure 2.1: An example of a linear level from Final Fantasy XIII is shown [85]. There is only one way for the player to move from their starting location on the bottom right to the next area in the top left. 13

When a player is given a choice in multiple paths to explore, the level becomes a maze. It can also be thought of as a graph. There are two types of mazes: branching and island [27]. Branching maze levels have multiple paths, but only one that reaches the end.

An example of a branching maze from Final Fantasy XIII is shown in Figure 2.2. The player starts in the bottom at The Agora and proceeds along the Pedestrian Terraces. The circled letters are treasures that reward the player for exploring a branch that does not lead to the next level, the Western Promenade. There is only one path from the player’s starting position to the end of the level.

Figure 2.2: An example of a branching maze level from Final Fantasy XIII is shown [85]. The player starts at The Agora and can explore dead-ends on the Pedestrian Terraces, but if they choose to do so, they must backtrack to reach the next area, the Western Promenade. 14

In contrast to branching maze levels, island maze levels have multiple paths from start to end. An example of this type of level in Final Fantasy XIII is shown in Figure 2.3.

The player starts at the bottom from the Mezzanine. After moving down a corridor the player can continue forward or take a fork on the left. The two paths meet further into the level, allowing the player to take either one to reach their destination.

Figure 2.3: An example of an island maze level from Final Fantasy XIII is shown [85]. The player may go straight or turn left at the first junction in the Central Conflux. Both paths allow the player to reach the next area in the top left region of the level, which has been omitted due to the size of the entire level.

15

The last level type is called open. Open levels allow the most freedom of movement. In open levels a player does not have to follow set paths, but may have to move around obstacles. An example of an open level from Final Fantasy XIII is shown in

Figure 2.4. There are three linear corridors (top left, lower middle, and lower right) that lead in to the central open area. The open region contains some gaps and holes the player cannot move through, but there are many routes to move between locations in the level.

Every spatial environment in a computer game can be classified as one of these four level types.

Figure 2.4: An example of an open level in Final Fantasy XIII is shown [85]. In this level, the player can explore to find items, enemies, and other game elements.

16

In order to analyze levels, we can transform them into graphs. Locations in the level correspond to nodes. The ability to move between two locations defines an edge between the nodes. Figure 2.5 shows graphs corresponding to an original linear level and the levels from Figures 2.2 and 2.3. A linear level is equivalent to a linked list. In the graph on the left of Figure 2.5, assuming the player starts at the rightmost node they will never have to choose between two edges if their intention is to progress further into the level. Branching maze levels are isomorphic to trees. A node in the tree may have multiple children, but there is exactly one path from the root to any other node. For example, in the middle graph of Figure 2.5, there is only one path from the lowest node

(the start in Figure 2.2) to the rightmost (the end in Figure 2.2). Island mazes and open levels are graphs that contain cycles. There are multiple paths for the player to move between nodes in the graph. In the graph on the right of Figure 2.5, if the player starts at the bottom node and cannot visit the same node twice during traversal, there are four possible routes to reach the node with a single edge in the center of the graph. If nodes can be explored multiple times during traversal the player can continue looping forever in a cycle.

17

Figure 2.5: From left to right, graphs of linear, branching maze, and island maze levels are shown. The linear level is equivalent to a linked list. The branching maze becomes a tree after selecting a root. The island maze is a graph with cycles.

Now we compare our terminology to that of work in video game level creation and evaluation. Evolutionary algorithms are a common approach in generation and evaluation of game levels. Given a procedurally generated level, a function is used to calculate a scalar value indicating the fitness of the level. Levels with high fitness are kept and modified and the fitness evaluation process continues. In [14] the fitness function is the sum of two properties: average lifetime of the player and the free space of the level. The average lifetime of the player can only be calculated by playtesting by humans or simulation by artificially intelligent agents, which is a time consuming process. The free space of the level is used to avoid levels too small to place gameplay elements such as player spawn points, weapons, and health items. Note that using this fitness function a level can be “improved” by increasing its scale, which is not true in all cases.

18

In [33], the fitness of a gridded level is driven by accessibility, defined as the total number of cells in the grid divided by the number of cells in the largest connected component of the grid. The highest scoring levels for this fitness function are completely open, which are not interesting. To avoid this they include a parameter for the desired size of the level and halt the evolutionary process when the correct size is reached.

Both of the previous evolutionary approaches to evaluating selected levels are specific to game genres. The algorithm in [14] is for first person shooter games and [33] is for real time strategy games where a player can order units to move along connected terrain regions. A more general evolutionary approach to evaluating game content is in

[105]. The fun of a level is a time varying function with two attributes multiplied together. The first, m, can be plus or minus one (positive if the challenge of the game is fun and negative if not). The second, c(t), is the perceived difficulty at time t. Like the approach in [14], this metric requires time consuming playtesting to measure. The evaluation metrics we propose in chapters 3 and 4 can be calculated with only the spatial details of the level provided, as in [33], but are more descriptive information than the single metric from [33].

2.3 Speleology – the Study of Caves

Caves are natural underground voids large enough for a human to enter. The scientific study of caves is speleology [79]. It is primarily rooted in geology, but also draws upon cartography, hydrology, chemistry, physics, and even meteorology.

19

Speleologists categorize caves in several ways. Most often they are classified according to the processes by which they form. Most caves are formed by removal of material over time. Some examples include dissolution or erosion of rock or melting of glacial ice. A smaller number of caves are formed by additive processes like solidification of lava or coral growth. Another classification method is the type of host rock. Caves can be formed out of many different materials including limestone, granite, lava, and ice. The host material generally implies the origin of the cave, but not always. For example, glacial caves are affected by melting of ice and erosion by strong winds. The last way of classifying caves is by their shape. This method is often used by Archaeologists and

Anthropologists as it implies how a cave could have been used by humans.

Not all caves are easily accessible for human exploration. This makes taking precise measurements difficult, so most spatial data for mapping and modeling caves is limited. A common strategy for performing a survey of a cave is selecting several locations or passages within it (noting position and orientation) and taking measurements of the distances to the rock above, below, and the sides (front, back, right, and left). This sampling method does not capture all of the details of a real cave like the one pictured in

Figure 2.6. It is possible to obtain more accurate spatial data by taking laser or ultrasound scanning equipment into a cave [91][97]. This approach is costly and requires a physical space to sample. The hardware is expensive and the process takes a long time. During scanning of the Wakulla Springs underwater cave, on average one hour of work produced raw data for 84.2 meters of cave passages [1]. With a total passage length of 6,409 meters, the amount of time spent to scan the entire cave was 76.1 hours. The world’s

20 largest known cave system Mammoth Cave is about 91 times larger, with 587,410.56 meters of explored passages [117]. It would take 6,976.37 hours, or about 41.5 weeks, to scan it completely.

Figure 2.6: A photograph of the interior of a cave is shown, courtesy of E. Scott Bair.

2.3.1 Solution Caves

Solution caves are the most common type of cave [78]. They are formed by dissolution of solid rock by acidic water. Landscapes above these caves contain features

21 that indicate dissolution of soluble rocks such as fissures and sinking streams. These landscapes are called karst. Between ten and twenty percent of Earth’s land area is karst

[113]. Figure 2.7 displays these regions as shaded areas on a map of Earth. Solution caves feature unique mineral formations such as stalagmites and stalactites that are more formally known as speleothems. Since this type of cave is the most common on earth and also the most visually interesting, in this dissertation we focus on this type of cave.

Figure 2.7: A world map of karst terrain from [113] is shown. Regions shaded in blue indicate karst. Color saturation indicates a higher concentration of carbonate rocks. Karst terrain indicates the presence of solution caves underground.

In order to model solution caves we must know the details of the process that forms them. When water absorbs carbon dioxide, a weak carbonic acid is formed. This 22 can occur during rainfall or as groundwater descends through soil. The acidic water dissolves rock. Groundwater flow moves the solution containing the sediment out of the cave system. This process carves out the cave over time. Nearly all caves form by expansion of existing openings or weak points in the host material, such as joints and bedding planes [78]. Joints are gaps in rock and bedding planes are divisions between strata of sedimentary rock [31]. Because only the rock in contact with acidic water will be dissolved, we need to know about groundwater flow.

Water descends through soil and other porous material until it reaches the surface known as the water table. At this surface the groundwater provides pressure equal to the opposing atmospheric pressure, so the volume beneath is fully saturated with water.

Figure 2.8 provides a visual example of a water table. It separates the ground into two sections: above it the ground is porous and water can descend through it whereas below it the ground is fully saturated.

Figure 2.8: An illustration of the water table, modified from [64], is shown. The water table is the surface under which the ground is fully saturated with water [79].

23

The water table is the surface that separates the region fully saturated with water

(also called the zone of saturation) and the region holding air and downward moving water (also called the zone of aeration). In speleology the zone of saturation is more commonly called the phreatic zone and the zone of aeration is referred to as the vadose zone. The shape of a solution cave passage is based on which zone it forms in.

2.3.2 Solution Cave Passages

The shape of a cave passage is determined by where it forms: above or below the water table [78]. Examples of four different types of cave passage cross sections are shown in Figure 2.9.

Figure 2.9: Cave passage cross sections are shown. (Top left) Phreatic passage: The series of curves indicates the opening of the passage along a horizontal bedding plane over time. (Bottom left) Vadose passage: The horizontal lines indicate the removal of material at the bottom of the passage over time. (Right) Combination passages with phreatic and vadose characteristics.

24

Underneath the water table, phreatic passages are formed. An example of a phreatic passage widening over time is displayed in the top left of Figure 2.9. Since the region is fully saturated with water, dissolution occurs roughly evenly and the passage widens in all directions over time, resulting in rounded, horizontal tube-like shapes. A real world example of a phreatic passage is shown in Figure 2.10. Note the wide rounded arch of the ceiling and floor. The passage curves to the left from the perspective of the viewer. This indicates the direction of groundwater flow as the passage was formed.

Figure 2.10: A photograph of a phreatic passage is shown, courtesy of E. Scott Bair.

Vadose passages form above the water table by rapidly moving and descending water. The bottom left of Figure 2.9 depicts a vadose passage. The speed and amount of

25 water flowing through a vadose passage is variable. As the floor lowers over time, the width of the passage varies as well. The resulting passage looks similar to a slot in a canyon. A real world example of a vadose passage is shown in Figure 2.11. Note the variation in the width of the passage at different heights within it.

Figure 2.11: A photograph of a vadose passage is shown, courtesy of E. Scott Bair.

Since the water table can rise and fall due to hydrogeologic activity, passages may have characteristics of both types. These are called combination passages. The two types of combination passages are shown in the right-hand side of Figure 2.9. In the top right

26 example a drained phreatic passage now above the water table starts to have a vadose passage cut into its floor. In the bottom right example a vadose passage cuts so far down it opens into a phreatic passage beneath it.

Every cave passage is unique, but passages of the same type have similar shapes.

This information can be used to parameterize models of cave passages which can be used to create linear and branching maze levels for use in games. This topic is covered in more detail in Chapter 3. Just as individual passages in solution caves are similar, so are the patterns that form when the passages start to connect.

2.3.3 Solution Cave Patterns

As multiple passages open and begin to intersect, distinctive patterns form [78].

Cave patterns are visible in the plan view map of a cave. A cave may contain multiple patterns. There are two main types of cave patterns: branchwork and mazes. Each has their own subcategories.

Branchwork patterns, as seen in Figure 2.12, resemble tributaries that converge into a single confluence further downstream. They form due to multiple water sources merging further into the cave. About 60% of solution caves have branchwork patterns

[79]. The amount of fracturing of the host rock dictates how sharply the flow of water bends. As shown in Figure 2.12, streams can meander (left) or be angular (right).

27

Figure 2.12: Branchwork patterns in bedded rock (left) and jointed rock (right) are shown. Highly fractured host rock results in sharper bends in the branches.

Maze caves contain multiple closed loops that were formed at roughly the same time. The concurrency of this process is how they differ from branchwork patterns.

Loops in branchwork caves can occur if old water sources dry up and new ones flood in.

This results in the old pattern overlapping with the new one. This may or may not create a loop. Two types of maze cave patterns form due to periodic flooding that opens several paths at once. If the passages are curved the pattern is called anastomotic and if they are straight the pattern is called network. The top row of Figure 2.13 depicts these two patterns. Around 5-10% of solution caves feature anastomotic patterns and 15-20% are part network maze.

The remaining two subcategories of maze caves are spongework and ramiform, pictured on bottom row of Figure 2.13. Spongework caves are formed by expanding pores and other small openings in rock that contains no major fractures. Only 2-5% of caves feature this pattern. Most occur in caves carved into limestone along the coast of oceans and seas. Ramiform caves consist of a central region with smaller, irregular

28 sponge-like passages branching outward. Ramiform patterns appear in only 5% of solution caves.

Figure 2.13: Maze cave patterns are shown. The top row shows patterns that form due to periodic flooding (left: anastomotic, right: network). The bottom row shows maze patterns with other origins (left: spongework, right: ramiform).

Cave patterns are not easily parameterized like cave passages, but they contain the defining characteristics of large cave systems. We can use them when generating branching maze, island maze, and open levels for use in games. This topic is discussed in further detail in Chapter 4. Now that we have described the shape of solution caves, we review existing software for mapping and modeling caves.

29

2.4 Cave Mapping and Modeling

While cave survey data is limited there are several software applications that use it. Examples include Compass, Survex, Therion, and Winkarst [8][32][71][89]. The primary purpose of these programs is to edit, process, analyze, and view cave survey data. The end products are maps (shown in Figures 2.14 and 2.15) and three dimensional models (shown in Figures 2.16 through 2.19).

Figure 2.14: Overhead map of Padavka Chamber, in Czechoslovakia, produced using Therion 2D [71].

Figure 2.15: Extended elevation map of Rabbit Cave, location not given, produced using Therion 2D [71].

30

Figure 2.16: Dead Bats Cave and Cold Wind Cave, in Slovakia, including surrounding terrain produced using Therion 3D [71].

Figure 2.17: A 3D model composed of line segments produced using Survex [8].

31

Figure 2.18: Big Foot Cave, location not given, and terrain above produced using Winkarst [89].

Figure 2.19: Lechuguilla Cave, in New Mexico, produced using Compass [32].

32

While the models provide a rough idea of the shape of a cave system, they are not well suited for use in games due to lack of detail and designer control. An example of a cave model that could be used in a game is shown in Figure 2.20. It has more geometric and textural details than the models in the previous figures. Unlike the previous models, it was created by an artist instead of data driven methods.

Figure 2.20: A virtual cave, from [23], suitable for use in a computer game is shown.

The scene in Figure 2.20 took an experienced artist one week to make using 3D

Studio Max [23]. 3D caves in games are created using general purpose 3D modeling software such as 3D Studio Max, Maya, and ZBrush [29]. There are no specialized tools

33 in the gaming industry to aid in creating models of caves. Games that feature procedural environments, such as Minecraft [76], have to include custom made methods to create models of caves (voxel models in the case of Minecraft).

Outside of the game industry, there have been a few attempts at modeling of caves in academic work. Schuchardt and Bowman examine the use of virtual reality caves in examination of cave survey data [95], but did not adapt the models for use in games. Johnson et. al introduce methods to procedurally create infinite models of 2D caves, but did not evaluate their use in games [54]. One of the closest matches to our work of modeling caves for games is [83]. This paper introduces methods to model and edit arched and caved terrain. Global procedures are provided to simulate rock erosion and sand shifting, but the framework lacks local control of model features for artists. Due to the similarities between terrain and caves, we now examine methods for modeling, editing, and rendering terrain.

2.5 Terrain Modeling and Rendering

2.5.1 Heightfields

A heightfield, or heightmap, is a two dimensional grid over (x,z) containing points that store a single height value (y) [69]. This limitation restricts the data structure to representation of planar surfaces. Logically, a heightfield is the surface that separates the earth from the sky. Rendering a heightfield is done by creating a mesh from vertices

34

(x,y,z), with each connected to neighboring vertices in the grid. A survey of heightfield representations and rendering algorithms can be found in [77].

A vertex in a deformable heightfield has only two operations. Increasing its value corresponds to construction of terrain whereas decreasing its value results in destruction of terrain. One approach to selecting vertices for deformation is creating an additional object in the same space as the terrain and performing collision detection. Heightfield vertices within the other object are selected for deforming. If conservation of mass is ignored, destruction results in height values lowered to the bottom of the object at (x,z) and conversely construction is done by raising height values to the top of the object at

(x,z). An example of a deformable heightfield and both editing methods is shown in

Figure 2.21. The octagon in (b) contains three heightfield vertices, which are deformed by construction in (c) and destruction in (d).

Figure 2.21: A 2D heightfield (a) and a deforming object (b) are shown. The three points within the object are adjusted by construction (c) and destruction (d).

35

2.5.2 Volume Elements

Heightfields are a form of surface modeling. The other standard terrain rendering data structure, volume elements, uses solid modeling techniques. Volume elements, or voxels, are arranged in a three dimensional grid and may contain binary data indicating the presence of solid material or continuous data representing density. Binary voxels can be rendered as a collection of cubes. A one in the grid indicates that the voxel should be drawn and a zero means it should not. Continuous density data defines an implicit surface which requires specialized algorithms, like Marching Cubes [60], to generate meshes for rendering. Editing binary voxel elements can be done using a constructive solid geometry approach [110]. An object placed in voxel space can be used to create and remove terrain using union and difference operations.

2.5.3 Run-length Encoded Terrain

Run-length encoded terrain is an attempt to incorporate the advantages of both of the previously described methods. Introduced in [7], the data structure models geological cores, as shown in Figure 2.22. A core consists of several layers of different materials.

The layers stack on each other in the y dimension with no gaps between them.

When the layers are thick, voxels are a wasteful representation [7]. Instead, the terrain can be modeled using a run-length encoding of voxels. The landscape is stored as a two dimensional array on (x,z) of one dimensional arrays. The one dimensional arrays

36 store the height of each layer. Since there are no gaps between layers, rendering in [7] is done by constructing a heightfield where every (x,z) height is the sum of all heights in the array at (x,z). The ability to have gaps in run-length encoded terrain is proposed in a later study [107]. It can be done by having each one-dimensional array store lists of height pairs. The first indicates the bottom of a piece of terrain and its pair is the corresponding top. Unfortunately, no rendering algorithm was provided in [107].

Figure 2.22: A geological core, from [7], is shown. There are multiple stacked layers of different materials in the core.

Here we consider how to render run-length encoded terrain using heightfields since they typically can be constructed and drawn faster than voxels. In order to maintain the rendering efficiency of heightfields, the assumption of meshing by connecting adjacent vertices must be kept. However, a consistency problem occurs if deformation is allowed. We present an example with case in two dimensions, where we store one- dimensional arrays of height pairs (in the y dimension) at regular samples in the x dimension. An example rendering and deformation is shown in the images in Figure 2.23. 37

The leftmost image (a) shows the original data and rendering. The first two samples in x have two y pairs, the next four samples in x have three y pairs, and the last two samples in x have two y pairs. Each pair is connected with a line segment. Adjacent pairs are connected with a line segment if they are the same layer (where a layer is the index in the one-dimensional array of height pairs).

Initially, the points on the bottom layer are all at the same height. Now consider removing the terrain in the grey box in (b). The four height pairs are removed from the array, which changes the layer of the remaining height pairs. Before the removal there were 3 (0, 1, and 2), but now there are only 2 (0 and 1). The result of using the same rendering algorithm as in (a) on the new data is shown in (c). In (c) we again connect adjacent samples based on index (i.e. layer) in the one-dimensional array. For the four samples in the middle of (c) the bottom layer has changed. Now that some of the bottom layer has been removed, the connectivity has changed, producing undesired results.

Figure 2.23: A rendering problem for run-length encoded terrain is shown. After removing some terrain, the connectivity of adjacent vertices is altered when connecting adjacent layers in the array.

38

2.6 Illumination Models

According to the rendering equation [55], observable light at a point is equal to the sum of reflected and emitted light. All illumination methods in computer graphics attempt to determine the quantity and wavelength of light visible at a surface point according to a given viewing angle. Local illumination methods, such as Phong’s model

[84], separate light into ambient, diffuse, and specular terms. The methods use vectors related to the light source, viewer, and surface normal to determine the light reflected towards to viewer. The vectors used in the Blinn-Phong illumination model are shown in

Figure 2.24. Diffuse illumination is determined by how close in direction the normal N and direction to the light source L are. Specular illumination is determined by how close in direction the normal N and halfway vector H are. H approaches N as the viewing vector V approaches R, which is L reflected by N.

Figure 2.24: Vectors for calculating illumination in the Blinn-Phong [9] model are shown. L is the vector to the light source. N is the surface normal. R is L reflected based on N. V is the vector to the viewer. H is the vector halfway between V and L.

39

A single bounce of specular and diffuse light is computed, leaving the ambient term as an approximation for additional diffuse and specular reflection within the scene.

Other models account for these reactions. Ray tracing [123] creates images by tracing the path of rays originating from a camera. Multiple bounces of specular light are modeled by recursively reflecting rays when hitting surfaces. Tracing volumetric entities such as cones [2] and beams [43] instead of rays is also possible. Since paths from light sources are not traced, indirect diffuse light is excluded from this model.

Path tracing includes tracing rays to light sources in order to determine diffuse reflections [55]. After hitting an object, rays are generated and traced (including reflections off of diffuse surfaces) to determine if they reach a light source. Photon tracing reverses the tracing process, moving from lights to the camera [51]. Rays are generated at each light source and traced to determine if they reach the viewing window.

Further extensions of this indirect illumination model such as photon splatting [45] and multiple pass tracing [40] increase its performance. Bi-directional path tracing combines the trace from camera to light and light to camera [58][118]. Metropolis light transport extends this technique using statistical analysis [119]. The chief drawback of ray tracing methods is the quantity of rays needed to produce a realistic image.

Radiosity uses heat transfer to simulate diffuse light reactions between surface patches within a scene [39][56]. This technique assumes purely Lambertian diffuse light reflection, so specular light is excluded from this model. The central idea behind radiosity is the computation of radiant exitance of surfaces in the scene. This requires meshes to be subdivided into patches, and solving a linear system of equations that models the heat

40 transfer between surface patches. Every iteration of this method provides an additional bounce of diffuse light within the scene. The zonal method extends radiosity to include emitted light [93]. Another improvement is hierarchical subdivision of the patches [42]. It is also possible to consider removing light from patches based on antiradiance [20]. In order to accurately capture lighting effects, patch size must be small, but the corresponding increase in the number of patches increases the computation time for solving heat transport.

The cost of global illumination algorithms can prohibit their use in interactive applications. This has driven the work behind precomputed radiance transfer, or PRT

[102]. This technique involves precomputing indirect lighting effects at each point, based on nearby geometry affecting incident irradiance. This provides some support for self- shadowing and interreflection of light. Further work removes the restriction of a constant bidirectional reflectance distribution function [109] and limitations on geometry [50].

PRT provides a wide range of effects, but it comes at the cost of memory needed to store the precomputed lighting information.

Ambient occlusion [125] provides scalar values for the ambient term in local illumination by determining visibility of a point on a surface with respect to the surrounding hemisphere. Often this is done by casting out rays, lowering the ambient term for each ray intersecting scene geometry. Ambient occlusion attenuates light due to interference with nearby objects, but does not consider diffuse reflection between objects contributing to the ambient term. Kontkanen and Laine [57] and Shanmugam and Arikan

[100] both propose algorithms to accelerate calculation of ambient occlusion, making it a

41 viable real time rendering technique. Image space ambient occlusion can incorporate a single bounce of indirect illumination and can be faster than calculating ambient occlusion in world space [46][90]. The downside of ambient occlusion is that it does not account for multiple reflections of light, a key aspect of global illumination.

Caves are a dark environment. Usually the only source of light within a cave is sunlight coming in from its entrance. In this case physically accurate light simulation would produce poor visual results since most of the cave would receive no light.

Illumination in games does not have to be photorealistic. It can also be set for gameplay features or to enhance perception of details in the scene.

2.7 Perception and Navigation in a Virtual Cave

Early studies on visual search tasks showed that luminance can direct visual attention in static or animated images [114]. Lighting can also be used to direct visual attention in games [28]. Recent studies also suggest that color is an effective visual cue when objects are on opposite ends of color space [121]. Results in [5] show that when altering an image, luminance change is more effective to guide visual search than warm- cool color modulation, though the authors also suggest the best method may be image- dependent. Luminance change is still effective at guiding visual search with distracters or false positives [65]. Given an image and multiple highlighted objects in it, the user will detect them all faster than if challenged to find an object with no visual clues. Most importantly, when only changing luminance, presence and immersion are not reduced [5].

42

Ensuring safety during navigation of caves and underground mines in the physical world is important as the environments can be dangerous [6]. Exploring a virtual cave environment can be difficult due to the lack of internal (or idiothetic) sensory information. Using full human motion as input brings the sense of motion and idiothetic cues into virtual worlds, but this technology is still far from wide adoption. Instead, since adding a small amount of geometry to a virtual world is cheap, a common approach to this problem is providing more external (or allothetic) sensory information in the form of visual or aural cues. When considering this methodology, the purpose of the application must be taken into account. A realistic walkthrough of a cave should not feature bright flashing arrows. In this case, a more subtle visual hint is desired.

There are two main subtasks of navigation: exploration and search [111]. The user explores the environment to discover the goal locations (objects or points of interest within the scene), then searches for a path through the environment to reach them.

Darken and Sibert demonstrate the effectiveness of navigational aids such as landmarks and mini-maps [22]. Users were able to locate objects more quickly when using these tools than if they had no assistance. Ruddle and Lessels categorize evaluation methods for navigation aids based on time to reach goals and perceptual issues related to using the aids [92]. We use these metrics to compare and contrast existing navigational aids in

Chapter 7.

There are two ways of incorporating navigational aids in virtual environments.

The first is by adding another object to the scene. Some examples are paths [94], pointing devices [12], and multiple-resolution maps [59]. Placing a path allows the user to follow

43 a route visually. Pointing devices can provide the same information, but visual cues are needed less often, only at junctions. Maps provide spatial information on the area the user is located. The other way incorporate navigational aids in a virtual environment is to alter the environment itself. This is done by placement of landmarks within the world [120].

Usually this occurs during the design of the environment, but the process can also happen dynamically by placing waypoints between the user’s current position and goal during runtime [16]. Many navigational aids assume an outdoor environment where occlusion is limited. However, the challenges of navigation indoors are different [88]. New techniques like time rewinding after a missed turn [101] could prove to be better in a more restrictive virtual environment. It is difficult to quantify presence and immersion [21][81], but it can be an important requirement in game applications [10].

The work on a navigational aid in this thesis is directed to assisting in first person navigation of a virtual maze or cave. The task has some similarities to assisting pedestrian navigation, which is addressed in [63]. In it, five types of information useful for navigation are specified: distance, junction, road type, street name/number, and landmarks. In a user study, participants were given a map and a route for a pedestrian to follow and instructed to create a set of directions for the pedestrian. The results of the study showed that landmarks are the most common type of navigation information, comprising 72% of all cues provided. Mazes and caves may not have landmarks, greatly increasing the difficulty of navigation within them.

The study in [63] is based on real world navigation, so in comparison we also consider research on navigation in virtual environments as in [70]. In [70], thirteen

44 navigational tools or aids present in Second Life (http://secondlife.com/) are described.

We omit the full list as several are not applicable for the task of first person navigation in a maze or cave. Some deal with movement that we do not support such as flying and teleportation. A few are different types of landmarks that we cannot assume to have in a maze or cave. Lastly we have traditional navigational aids like those described earlier: directional signs, maps, and paths. Based on a user study and navigation difficulties users encountered several design guidelines for using the navigational tools and aids are proposed. Relevant guidelines include: use maps to orient the user, place labels and landmarks so that they are not heavily occluded, place signs along paths, and provide shortcuts if the purpose of the application is not exploration. In a game, navigational aids explicitly provide directions to a player, which runs counter to the goal of freedom and exploration. The navigational aid we introduce in Chapter 7 provides navigational cues more subtly than aids like maps, paths, and signs.

45

Chapter 3: Linear and Branching Maze Cave Levels

In this chapter we introduce methods to create linear and branching maze cave levels. We also evaluate the complexity of branching maze levels. The most important part in design of linear levels is placement of game elements to challenge the player’s progression. Having methods to create geometry for these levels enables the designer to spend more time on game elements. Cave passages, as described in Section 2.3, correspond to linear levels. In this chapter we propose methods to create models of cave passages for use as linear levels in computer games. We create 3D models of solution caves based on passage types: phreatic, vadose, and combined phreatic and vadose. We define parameterized methods for each passage type. Making adjustments to these parameters allows us to create a variety of models. Then we extend the approach to create branching maze levels. We conclude this chapter with methods to evaluate the complexity of linear and branching maze levels.

3.1 Curve and Surface Modeling

A curve, c, is a continuous map from a one dimensional space to an n-dimensional space. We are interested in curves in two and three dimensional space. They can be expressed as parameterized functions f t  x, yand f t  x, y, z. There are many

46 ways to create curves. A curve drawn by an artist is represented as an ordered set of

pointsP0 , P1 ,, Pn . Connecting the points with line segments forms a curve

c  P0 P1  P1P2  Pn1Pn . Intermediate points on the curve c can be generated using a piecewise function that is continuous but not differentiable everywhere. This is a zero order continuous curve.

If higher levels of continuity or smoothness are desired, we can use the set of points as parameters (called control points) to create a Bezier curve. Points on a Bezier

curve b defined by the control pointsP0 , P1 ,, Pn for t on [0,1] are defined as:

n n ni i bt   1 t t Pi . Figure 3.1 depicts two Bezier curves. The curves are drawn in i0  i  blue and the black squares are control points. The number by each control point indicates its index (0 for P0, 1 for P1, and so on).

Figure 3.1: Two Bezier curves are shown in blue. The control points used to create each curve are drawn in black.

47

A surface, s, is a two-dimensional topological manifold. A 2D topological manifold is a topological space where every point locally resembles 2D Euclidean space.

There are a few methods to generate a surface given one or more curves as input.

Rotation of a curve around an axis creates a surface of revolution. Moving a curve along a vector creates a surface of extrusion. Swept surfaces are made by specifying a curve to extrude on instead of a vector. Figure 3.2 is a swept surface created using the curves from

Figure 3.1. The curve on the left acts as the trajectory for the curve on the right.

Figure 3.2: Several views of a swept surface made from the two curves in Figure 3.1 are shown. The arch shaped curve from the right of Figure 3.1 is moved along the curve on the left of Figure 3.1 to generate the surface.

48

3.2 Single Passage Cave Modeling for Linear Levels

A model of a phreatic, vadose, or combination passage can be used as a linear level in a computer game. These passages are formed along the flow of groundwater. Let cflow be a two or three dimensional curve that indicates the direction of water flow within a passage. This curve can be artist specified or computed as a streamline in a groundwater flow field. Let ccs be a closed curve that models a cross section of the cave passage on the cflow. A model of the passage can be made by sweeping ccs on cflow. Self-intersections can be avoided using the approaches from [4] and [106]. All three passage types can be made using this sweeping approach. In the following subsections we examine ways of adding more control and parameterization to the model generation process for each passage type.

3.2.1 Phreatic Passages

As described in Section 2.3, phreatic passages are shaped like circular or oval tubes. Since phreatic passages form by roughly uniform dissolution of surrounding rock, their shapes are also fairly uniform, mostly differing in size. The ceiling of a phreatic passage mirrors the floor since both are subject to an equal amount of dissolution.

Reflecting a curve that models the passage’s ceiling on the x axis creates a closed loop which is used for ccs. An example of a model made using this process is shown in Figure

3.3.

49

Figure 3.3: A model of a phreatic passage and the curves used to create it are shown. The curve on the left is cflow. The curve on the right is used to create ccs.

First the curve on the right is reflected about the x axis. The resulting cross section is swept along the curve on the left to create the model. For further automation, we can parameterize creation of ccs for phreatic passages. The ceiling of a phreatic passage is an arch. We model its shape using a quadratic equation f x ax 2  bx  c .

We want the curve to be symmetric with respect to the y axis, sob  0 . In order for f x to have the shape of an arch, we need a < 0 and c > 0. The height of the arch is the y intercept of , so we rename c as archheight. The width of the arch is two times the x

 4a  archheight intercept of . So width  2  . Solving for a yields 2a 50

 4  archheight a  . The height of the passage is twice that of the height of the arch: width 2

 2  height height height  2  archheight . By substitution we have a  and c  . To width 2 2 construct a curve a for an arch that forms a passage of specified height (h) and width (w)

 2h h we use the following equation: a(x)   x 2  ; where a(x)  0 . w2 2

3.2.2 Vadose Passages

As described in Section 2.3, vadose passages are shaped like slots in a canyon.

The defining characteristic of a vadose passage is its walls. The width of the passage varies at different heights. The walls are shaped by how long each portion was exposed to dissolution as it was near the floor of the passage.

The two walls in a vadose passage are symmetric. We can create ccs by creating a

2D curve cwall that models the wall of the passage. Creation of cwall can be done by an

artist, as in Figure 3.4, or by simulation. Let cwall =P0 , P1 ,, Pn . P0 is the lowest point in the curve and Pn is the highest. Let dy be a constant value for the height between points

in cwall. For i = 0 to n, set Pi  0,i  dy. Next, we must determine the amount of displacement on the x axis for all points. Let d  be a value for displacement due to

dissolution and D =d0 ,d1 ,,d n be the amount of displacement for each point. We also need to account for high flood waters that dissolve material at multiple heights. Let

51

 h and H  h0 , h1 ,, hn where 0  hi  n  i . Let hi be the number of points after Pi to apply displacement di (i.e. from Pi to Pi+hi).

After creating cwall it is swept on cflow. Then cwall is reflected on the y axis and swept on cflow again. Unlike phreatic passages where symmetry is between the floor and ceiling, the symmetry of vadose passages is between the walls. In cases where P0 and Pn do not have an x coordinate of zero, polygons are drawn to connect the two walls at the top and bottom of the surfaces to create a floor and ceiling. An example of a model made using this sweeping approach, but with a manually created cwall, is shown in Figure 3.4.

The curve on the right is swept on the curve on the left, then reflected on the y axis and swept again. This results in gaps at the top and bottom of the passage that are filled by quads.

52

Figure 3.4: A vadose passage (top), its cflow (bottom left), and cwall (bottom right) are shown.

53

3.2.3 Combination Passages

Given a cross section of a combination passage, a model can be made by sweeping ccs along cflow just as with the two previous passage types. An example is provided in Figure 3.5.

Figure 3.5: A combination passage is shown. It has phreatic characteristics in its upper region and a vadose passage forming in its floor.

Alternatively, given a model of each passage type, the two can be combined to form a combination passage. After placing each passage in the same space, the polygons of each passage contained in the other must be eliminated. Intersecting polygons must be adjusted to avoid clipping, but not introduce gaps. Figure 3.6 demonstrates this process.

Geometry from the vadose passage within the phreatic passage is drawn in blue and geometry from the phreatic passage within the vadose passage is drawn in red. Fully contained polygons, which are line segments in the 2D case, are removed. Intersecting geometry is adjusted by creating new vertices at the points of intersection.

54

Figure 3.6: A combination passage is created by overlapping phreatic and vadose passages. The left images depict the combination passage before and after adjustments are made. On the right, close-ups of the gray box in the left-hand images are shown.

3.2.4 Varying Passages

A model created by sweeping ccs along cflow can be sufficient for short and simple levels but may not have enough variation to be interesting as a longer level. We provide additional control by letting the user change ccs during sweeping. An example of rescaling ccs is shown in Figure 3.7 and 3.8. Figure 3.7 shows the front of the model and Figure 3.8 shows its left side. The model in these two figures is made by scaling down ccs as it is swept along cflow. Initially, ccs is 20 feet tall and 11 feet wide. It is swept along cflow which has 200 samples and is 30 feet long. The cross section is uniformly scaled down as it is

55 swept. At the end of sweeping, ccs is 6’6.67” tall and 3’6.67” wide, three times smaller than its original size.

An example of morphing between cross sections is shown in Figures 3.9 and 3.10.

Figure 3.9 shows the front of the model followed by the view from the left in 3.10.

Again, cflow has 200 samples and is 30 feet long. The curve cflow is split into eight equally sized segments. The cross section ccs is rotated twenty degrees for each segment.

Figure 3.7: Front view of a cave passage with rescaled ccs. The cross section is scaled down as sweeping proceeds from the front of the model to the back.

56

Figure 3.8: Side view of a cave passage with rescaled ccs. The cross section is scaled down as sweeping proceeds from right to left.

Figure 3.9: Front view of a cave passage with morphing ccs. The cross section changes as sweeping proceeds from the front of the model to the back.

57

Figure 3.10: Front view of a cave passage with morphing ccs. The cross section changes as sweeping proceeds from right to left.

As described in Chapter 2, a linear level has the same structure as a linked list.

The player starts at the beginning of a single path and moves forward to its end, never needing to make a navigation decision. For the cave passage models described in this chapter, the linked list is defined by cflow. Suppose we randomly generate a set of curves as candidates for cflow. We define two properties of cflow to provide information the designer can use to select cflow. These properties are shown in Table 3.1. The length of the level is the total length of all segments of cflow. This lets the designer easily choose between long or short levels. The curviness of a level indicates how sharply the level

ˆ bends. LetVi be the ray Pi Pi1 andVi beVi normalized. Curviness is the average of dot

products between adjacentVi of cflow. Curviness is a value within [-1,1]. Curviness is one when cflow is a straight line. As cflow bends, curviness decreases. As curviness approaches negative one, cflow consists of many sharp bends with near 180 degree turns. This property 58 allows the designer to choose between straight levels that are easy to move in and winding levels that require more dexterity.

Property Equation

n1 Length  Pi Pi1 i0

n3 Curviness ˆ ˆ Vi Vi1 i0 n  2

Table 3.1: Linear level properties derived from cflow.

3.3 Cave Passage Modeling for Branching Maze Levels

As described in Chapter 2, a linear level has the same structure as a linked list while a branching maze level can be represented as a tree. The player can make navigation decisions but there is only one path from the start to the end of the level. In the previous section we created models of linear levels by sweeping along a curve cflow. In order to create a branching maze level we can sweep along a tree of curves instead. Let t be a tree with n nodes (P) and m edges (e). Nodes are endpoints of curves and edges are curves (like cflow from the previous section) between nodes. Proot is the root node of the tree and leaves is the set of all leaf nodes of the tree. The start of the level is Proot, also called Pstart. The end of the level, Pend, is a leaf node. The solution path, S, is the set of 59 nodes from Pstart to Pend, inclusively. The distance between two nodes i and j, which may

be weighted by the length of the edges, is DistPi ,Pj . The size or length of an edge is e .

Figure 3.11: A model of a branching maze level (left) and its tree (right) are shown. Each node is a curve endpoint and each edge is a curve for sweeping.

We can specify different cross sections for sweeping along each edge as in

Section 3.2.4. Self-intersections near nodes can be removed using the same constructive solid geometry approach from Section 3.2.3 that creates combination passages as the union of two other passages. An example of a branching maze cave level is shown in

Figure 3.11. A cross section is swept along a curve, starting at the bottom of the figure, 60 moving northeast. The curve splits in two at a node in the middle. One part continues northeast and the other heads northwest.

In a branching maze level, players may choose which paths to explore. This makes controlling gameplay more difficult for the designer. We can assist the designer by classifying branching levels according to the properties of their trees. These properties are shown in Table 3.2. The solution length is the distance from the start of the level to its end. The solution length is the smallest amount of exploration a player can do to complete the level. It can be used be a designer when a minimal amount of playtime is desired. Maximum length is the longest path between two nodes in the tree. It is the longest a player can go without backtracking. The total length of the tree is the length of all of its edges combined. The amount of the tree that is a dead end is the tree’s total length minus the length of the solution path. Assuming the player explores every dead end before the solution path (the worst case scenario), the distance they traverse is two times the length of the dead ends (once in each direction) plus the length of the solution path. This lets the designer put an upper limit on the amount of playtime for the level

(assuming the player does not make mistakes and explore a dead end twice). The number of dead ends in the tree, which also indicates the largest number of new paths the player can explore before reaching the end, is one smaller than the number of leaf nodes since one is the end. If the player makes every navigation choice correctly (i.e. always selecting the branch that contains the goal) the number of navigation choices made is the number of nodes in the solution path that contain branches (i.e. 3 or more edges).

61

Solution Length DistPstart , Pend 

Maximum Length MaxDistPi , Pj 

m Total Length  e i i  0

m Dead End Length  ei – DistPstart , Pend  i0

m Worst Case Length 2 ei – DistPstart , Pend  i0

Dead End Number = leaves – 1 Branching Amount

Number of nodes in the solution path Minimal Navigation Choices with edge order ≥ 3

Table 3.2: Branching level properties derived from the tree t.

These metrics can also be used to calculate information on subsections of the level. All of the metrics above are descriptive of the size and complexity of the level (as a whole or a specific subsection), which can be used to estimate the difficulty or time needed to complete the level. Existing methods to evaluate mazes focus on more general details such as the dimension of the maze, its tessellation geometry (if applicable), and its routing (linear/unicursal, branching, or island maze) [87]. These methods do not provide useful information on subsections of a maze or level. Given a fixed area for a tiled maze, the resulting mazes can be classified as perfect, braided, unicursal, or sparse. A perfect

62 maze is a branching maze with no wasted space. A braided maze is one without dead ends. A unicursal maze has no branching. A sparse maze has a lot of inaccessible space.

All of these describe the maze or the space it occupies in its entirety. They also do not distinguish between simple/easy mazes and complex/hard ones. Since our evaluation methods provide more details on maze complexity than existing descriptive properties for mazes, our metrics are better suited for use by game level designers.

63

Chapter 4: Island Maze and Open Cave Levels

This chapter introduces methods to create island maze and open levels, as described in Chapter 2. Linear and branching maze levels have the same structure as linked lists and trees. Their topology is fairly simple, so curves are sufficient to capture their design spaces. Island maze and open levels have the structure of a graph with cycles. Since they are more complex than linear and branching maze levels, we take a different approach to create them. In this chapter we describe how to construct these types of levels for single-story caves like the Yaolindong cave [38]. In [38], a 3D model of a cave is constructed by modeling its floors and ceilings. The floor is a digital elevation model generated from topographical, landform, and cross section maps. The ceiling is also a digital elevation model created using the same maps. In this chapter we use terrains to create models of caves with the same properties as island maze and open levels: multiple paths from start to finish.

4.1 Terrain Modeling

A heightfield H is a regular grid of values representing the height (y) at 2D positions (x,z). H(x,z) is the height or elevation at location (x,z). Let n be the number of rows and columns in the grid. The total number of samples in H is n2. Heightfields can be

64 constructed from real world data, procedural methods, and by artists. In this section we describe methods for creating and editing heightfields that will later be used as floors and ceilings of the cave model.

Real world data is available in terrain scanning repositories. One such collection is NGA Raster Roam from The National Geospatial-Intelligence Agency (NGA) [74].

This data comes in the format of Digital Terrain Elevation Data, or DTED, files that hold elevation values in a regularly spaced grid, compatible with a heightfield representation.

Additional terrain data (in a wide variety of formats) can be found at the U.S. Geological

Survey’s seamless data warehouse [116]. Figures 4.1 and 4.2 demonstrate an example of a heightfield created using scanned data. Figure 4.1 depicts DTEM data of an area in

Montana (100 x 100 samples) from Raster Roam using luminance to indicate height. In

Figure 4.2 the data is rendered as a heightfield.

Figure 4.1: DTEM data of a region in Montana from Raster Roam

65

Figure 4.2: Terrain constructed from the heightfield data in Figure 4.1.

There are two downsides to using scanned data to create heightfields. The first is that some data sets have gaps (missing samples). These can often be approximated by interpolating the heights of neighboring samples. The second is that scanned data is limited to real terrain. Methods that synthesize terrain do not have the same limitation.

A survey of procedural synthesis of terrain can be found in [103]. One way of classifying terrain synthesis algorithms is by their purpose: creating a base terrain or editing an existing terrain. We provide examples of the former category first. Noise based methods, such as Perlin noise [82], create patterns using turbulence. The other category of terrain generation algorithms is based on subdivision, like the midpoint displacement algorithm

[69]. The input to the midpoint displacement algorithm is four height values (one for each corner in a rectangle) and a value for scaling random displacement, r. An example is shown in Figure 4.3. The four height values are 4, 2, 6, and 8 shown in the grey circles.

66

The heights in the white circles between each of the four corners are the average of the two adjacent corners. The value in the white circle in the center is the average of all four corners plus a random value in the range [-r, r]. In Figure 4.3, the random value is one.

Each of the four sub-rectangles is subdivided using the same height calculations, but with a smaller range for random displacement, [-r/2, r/2].

Figure 4.3: Midpoint displacement example.

Subdivision and noise algorithms are often used to create terrain with self-similar features that mimic the appearance of natural terrain. Heightfield data can also be used as patches when using a subdivision approach, but must be edited to match heights at the subdivision borders [124]. The last type of terrain generation algorithms perform simulations that shape terrain using simple operations. The fault algorithm iteratively

67 generates a random line that splits the terrain into two and raises one part and lowers the other [98]. The particle deposition algorithm randomly selects a location in the terrain and raises heights within a random radius [99].

Editing and filtering algorithms alter heightfields. There are two popular types of editing algorithms: erosion simulation and image processing. Fluvial erosion is caused by rainfall and rivers. Water dissolves exposed material and deposits it elsewhere after it moves. Thermal weathering is caused by temperature changes that cause material to crumble and descend due to gravity. By definition, the talus angle is the maximal slope of the terrain due to thermal weathering. An example of thermal weathering is shown in

Figure 4.5. The initial terrain on the left is the fractal terrain from Figure 4.4. During each iteration, each vertex may move 0.2 meters of terrain to each of its four neighbors, but only if the slope between them is greater than 1. It takes several iterations before the terrain appears smooth. Figure 4.6 shows the process after ten iterations. At this point the broad faces on the side of the mountain are fairly smooth. After twenty iterations, as shown in Figure 4.7, the peaks of the mountain continue to smooth out.

68

Figure 4.4: An example of a terrain made by subdivision is shown. When the first four corners are low and the noise value is high on the first iteration of midpoint displacement the terrain has a central peak.

Figure 4.5: An initial terrain and three iterations of thermal weathering (from left to right) are shown.

69

Figure 4.6: The terrain from 4.5 after ten iterations of thermal weathering is shown.

Figure 4.7: The terrain from 4.5 after twenty iterations of thermal weathering is shown. The amount of material transferred during each iteration must be small, so the process takes several steps to achieve smooth looking terrain.

70

Since heightfields can be represented as 2D images (as in Figure 4.1), image processing and filtering operations can be used on them. Clamping is an operation that either raises low value pixels to a specified minimum or lowers high value pixels to a specified maximum. In terrain terms it can be used to create flat valleys (see Figure 4.8) or plateaus (see Figure 4.9). In Figure 4.8 a clamping value is shown as a wireframe square. On the right, terrain vertices below the clamping value have been raised, forming a flat region in the front right area of the terrain.

Figure 4.8: A terrain before (left) and after (right) clamping to form a flat valley is shown. The value to clamp to is shown as the higher of the two wireframe squares (the lower is the minimal height of the terrain).

71

The clamping value is shown in the same way in Figure 4.9. This time on the right, terrain vertices above the clamping value have been lowered, creating a plateau in the middle of the terrain.

Figure 4.9: A terrain before (left) and after (right) clamping to form a plateau is shown. The value to clamp to is shown as the higher of the two wireframe squares (the lower is the minimal height of the terrain).

Smoothing is another useful image processing filter for terrain editing. Smoothing sets each vertex as the average of itself and its neighbors. The effect is similar to thermal weathering, but will smooth all of the terrain instead of only neighboring heights with a significant difference in altitude. Figure 4.10 shows an example of smoothing terrain. The initial terrain, on the far left of the figure, is made from a white noise image. One smoothing reduces the noise, as seen in the middle of the figure, but not enough to be a reasonable terrain. After several iterations of smoothing the noise has become a hilly terrain on the right of the figure. 72

Figure 4.10: A terrain smoothing example is shown. The left image is white noise, the middle is the result after one smoothing operation, and the right is after five smoothing operations.

These generation and editing methods are included in many of the commercial toolkits for creating terrain. Some examples include

(http://www.daz3d.com/i/products/bryce/), L3DT (http://www.bundysoft.com/L3DT/), and (http://www.planetside.co.uk/). We use L3DT as an example of how an artist uses a synthetic terrain toolkit. There are several steps needed to create a terrain like the one shown in Figure 4.11. The geometry of the heightfield is set first. L3DT allows users to create flat heightmaps, noise-based heightmaps, and designable heightmaps.

Designable heightmaps are controlled by a set of parameters such as average height, average slope, noise strength, and erosion strength. There are several tools to manually alter the procedurally generated terrain. These tools raise or lower individual vertices or perform procedural operations, like bulldozing and smoothing, in local regions around a selected point. Texture generation occurs after the geometry is finalized. L3DT procedurally generates textures for different types of terrain such as grass, rock, and sand. 73

Typically an artist will edit or repaint the terrain using a mouse to select terrain area. A light map is used to store the result of illumination calculations. The geometry and texture generation of the terrain in Figure 4.11 took approximately 10 minutes. Editing the terrain to meet gameplay requirements could take many hours.

Figure 4.11 A terrain made using L3DT [11], a commercial tool for creating heightfields, is shown. We created the terrain in approximately 10 minutes using noise to create the terrain and procedural texturing (flat areas are grassy, slopes are rocky, and underwater regions are dirt).

4.2 Cave Model Construction Using Cave Patterns

The previous section introduced methods for creating heightfields. Some caves, like the Yaolindong, can be modeled using two heightfields: one for the floor and another for the ceiling [38]. Walls are where the two surfaces intersect. Using the same approach we can create models of caves using two terrain surfaces as outlined in Figure 4.12.

74

Aligning two terrains of the same size at the same (x,z) coordinates forms a model of a cave.

Figure 4.12 A flowchart for creating a planar cave model is shown. After creating two terrains, they can be placed in the same space to create a model.

We define the floor as a heightfield F and the ceiling as a heightfield C. F and C have the same size, i.e. number of samples in x and z. We define three terms to describe positions (x,z) in the model: open, closed, and wall. If F(x,z) < C(x,z), we say that (x,z) is open. In other words, it is possible to move and explore at (x,z) because the floor is lower

75 than the ceiling. If F(x,z) > C(x,z) we say that (x,z) is closed. There is no physical space between the floor and ceiling so it is not possible for an object to be placed at or move into (x,z). When F(x,z) = C(x,z) we call (x,z) a wall as it separates open and closed positions.

The open areas of the cave define the space of the level. In Chapter 2 we introduced four types of levels: linear (no navigation choices), branching maze (has navigation choices, but only one solution path), island mazes (multiple solution paths), and open (multiple routes and focus on freedom of movement). Since F and C are created independently, there is no way of knowing which of the four level types the open area will be. We have three options to deal with this problem: allow interactive editing of the model, control procedural creation of models of a desired level type, or procedurally generate and evaluate models until an acceptable one is created. We will address interactive editing in Chapter 5. In the remainder of this chapter we will describe how to control creation of the level, then how to automatically determine a model’s level type, and conclude with methods for designers and artists to evaluate the results.

The problem with the approach in Figure 4.12 is coping with the design space of the resulting models. There are no restrictions on F and C so we can make an infinite number of models. Since the space of gameplay in a model is defined by open areas, we want a way for the designer to evaluate or specify open space in a model. In Section 4.3.1 we will provide methods to evaluate levels, in the rest of this section we introduce a method to control open space in the model.

76

As described in Section 2.3.3, when multiple cave passages intersect distinctive patterns emerge. These patterns can be used to control the open and closed space in the cave. Figure 4.13 shows the new process of model creation, as altered from the original in

Figure 4.12. Again, two terrains are created. A new data structure, the cave layout, is used to control open and closed space of the cave during the “Generate Cave” process.

Figure 4.13: The framework for controlled wall creation of cave models. A new data structure, the cave layout, is used to indicate open areas in the level. An additional process, generate cave, is needed to ensure that only the cave layout results in closed space in the model.

The cave layout is an image of the same size as F and C. See Figure 4.14 for an example of a cave layout. A position (x,z) is closed if the pixel at (x,z) is white.

77

Otherwise the position is open. In the figure, the entrance of the cave is in the bottom right corner and the overall layout has a branching maze structure.

Figure 4.14: An example of a cave layout is shown. The entrance of the cave is the large opening in the bottom right corner and there are several branching paths off of the main one directed to the top left corner.

Now we will describe how to make a cave model using the cave layout. After generating F and C, we need to ensure every position is open. For all closed positions, we

F(x, z)  C(x, z) F(x, z)  C(x, z) set F(x,z) to  y and C(x,z) to  y where y is a user 2 2 specified parameter for height displacement. Alternatively we can place vertices based on only the floor F(x, z)  F(x, z) and C(x, z)  F(x, z)  2  y or only on the ceiling

F(x, z)  C(x, z)  2  y andC(x, z)  C(x, z) . Now that all regions are open, we can close them off according the cave layout. To close a position (x,z) we set F(x,z) and

F(x, z)  C(x, z) C(x,z) to their average . The final model is made by rendering the 2 adjusted heightfields F and C.

78

Two examples of models made using this approach are shown at the end of this chapter in Figure 4.17. In the top image in Figure 4.17 we procedurally created two terrains F and C then manually placed C above F. Because the two terrains were created independently, we cannot predict the amount or shape of the open space of the level, but we can calculate the amount of open space and highlight its shape to assist in placing C.

In the bottom image in Figure 4.17, we generated F using white noise that was smoothed five times. The resulting heights ranged from 5 meters to 20 meters, which we call min(F) and max(F) respectively. Then we set C by reflecting F across the plane y  max( F) 1. This gives 100% open space for the level, so we iteratively lowered C until only 75% of the level was open.

Maps of caves and cave patterns may be used as cave layouts, but a fully procedural method to create cave layouts is required. Formation of solution caves is driven by the movement of water. This is especially apparent for caves fitting the branchwork pattern. To procedurally create layouts with this type of pattern, we perform a discrete simulation of water moving on a terrain. First we create or load a heightfield.

We model the movement of water as a particle system. A water droplet w is modeled using a list of positions (x,z) in time. At the start of the simulation we create a set of water droplets W. Placement of each droplet wi can be stochastic or deterministic. For each step in the simulation, each water droplet acts independently. A droplet wi at the heightfield point (x,z) will move to the neighboring point (x 1, z 1) with the lowest height. If (x,z) is the lowest, the droplet will remain stationary. This process is similar to gradient descent and models the tendency of water to follow the path of least resistance. Once all

79 droplets are stationary the simulation ends. The simulation process is repeated for a specified number of iterations or until every heightfield point has been used as a starting position for a water droplet.

Drawing the paths of water droplets over time gives a set of lines similar to branchwork patterns. Two results of these simulations are shown on the left of Figure

4.15. If we allow movement only to the gridded positions in the heightfield, the patterns are angular. Adding noise smaller than the distance between points in the grid to the droplet locations creates a meandering effect as shown in the right side of Figure 4.15.

Figure 4.15: Procedurally generated branchwork cave patterns are shown. Adding noise to placement of vertices like in the examples on the right eliminates the angular patterns that come from the regular grid structure of the heightfield.

80

Since spongework patterns are more random, they can be used to create cave layout for open levels. To create a spongework pattern the first step is creating F and C as white noise. Next, F and C are smoothed several times to remove jaggedness. Then, for all C(x,z), C(x,z) = C(x,z) + max(F). This ensures that all areas in the level are open.

Then C is lowered uniformly in an iterative process, for all C(x,z), C(x,z) = C(x,z) - ∆y where ∆y is a user specified constant. As C lowers, random pockets will become closed, which forms the sponge pattern. In order to determine when to stop the descent of C, the connected components of the open regions are computed. Ideally, the level will have one large connected component of open area. The descent of C stops once the largest component of open area is less than a user specified threshold of the total area. This placement attempts to retain a large amount of open area accessible while retaining the porous, but not completely open, structure that a spongework pattern has. Figure 4.16 depicts a view of a spongework pattern made using this process. The darker shaded areas are open and the lighter shaded areas are closed.

Figure 4.16: The top view of a spongework cave layout is shown. The lighter shaded polygons are the floor and the darker ones are the ceiling. The open areas are where the ceiling is visible, i.e. above the floor. There are some isolated unreachable open areas, but the majority of the cave can be freely explored. 81

Figure 4.17: Examples of first person views within two cave levels. 82

4.3 Level Visualization and Evaluation

Now that we have established methods to create models, we examine the design space of all possible models. Let F and C each be m be m heightfields whose heights are limited to the range [0,Y], where Y is a positive integer. We estimate a lower bound on the number of configurations of F and C by limiting heights to integer values. There are Y+1 possible values for each height and each height is independent of the others. To find the lower bound on the total number of models, we calculate a k-permutation with repetitions: kn, where k is the number of possible values for each element (Y+1 in this case) and n is the number of elements (2m2 in this case). By substitution we have

2 (Y 1) 2m . Consider the case where F and C are represented using 32 by 32 8-bit texture maps, i.e. m=32 and Y=255. Even in this extremely coarse representation, there are approximately 1.19*104932 configurations of F and C. For all practical purposes, to the designer this is an infinite space of configurations. The designer is left with the task of determining if a configuration is good for gameplay. This forces the designer to spend time manually editing the model and performing playtests for evaluation. In this section we describe methods to calculate and visualize game level information of models to assist in model evaluation.

The cave layout described in the previous section has a significantly smaller design space than the resulting 3D model. Caves layouts are represented as 2D binary images with the same resolution as F and C. This is equivalent to an m2 binary bit vector.

We use the formula for k-permutations with repetitions, this time with n = m2 and k = 2,

83

2 which gives 2m . For a 32 by 32 layout, there are approximately 1.8*10308 configurations, which is approximately 6.61*104623 times smaller than the number of model configurations. A significant decrease in complexity, but still enough that the designer will need help to explore the design space. Table 4.1 provides examples of the number of layouts for increasing values of m.

number of

m layouts

1 2

2 16

3 512

4 65536

5 33554432

16 1.16E+77

32 1.80E+308

64 1.04E+1233

128 1.19E+4932

256 2.00E+19728

Table 4.1: Number of possible level layouts for a given size

84

The design space of this problem is exponential and grows quickly. In order to assist designers in exploring this space, we calculate spatial and navigational information that can be used by an artist or designer to select or alter models.

4.3.1 Model Visualization

In this section we consider models created using the framework in Section 4.2.

The models consist of two heightfields: the floor and ceiling. The layout is implied by open and closed regions of the models. We make no assumptions on the shape of the two surfaces. Our goal is to provide visualizations to help designers gather specific spatial information on the models.

The open regions in a model are where gameplay can occur. There may be disjoint open regions in the model, so highlighting all open areas does not provide complete information. If the player cannot move between disjoint regions, much of the level’s space is wasted, and the designer wants to avoid this problem. To illustrate connectivity between regions in the level, we display each connected component of open space with a different color. Figure 4.18 shows an example of a model with two disjoint connected components of open area.

85

Figure 4.18: Two connected components (in different shapes of green) of a model are shown. There is no way to move between the lighter green area to the darker green one without exiting the model, so each is a separate connected component.

We calculate the connected component of the model with the following algorithm. First, construct a 2D matrix of the same resolution of the heightfields. The matrix will store integer values where -1 is a temporary value to indicate the position is unexplored, 0 indicates a closed position, and positive integer values correspond to a unique connected component. A counter is used to track the number of connected components and is initialized to 1. After initializing the matrix with -1 and 0 values, from right to left and top to bottom continue until a -1 is found. Set the value in the matrix to the counter’s value and perform a flood fill to neighboring values in the matrix that hold -

1. After the flood fill finishes, increment the counter and continue searching for a -1 value. The scanning process ends at the bottom right value in the matrix.

86

The connected components show how much of the level the player can explore. In that sense it illustrates a global property of navigation in the level. We also want to display local information such as how tall, long, and wide regions in the model are. We consider illustrating height differences first. In other words, showing how tall the cave is at a given location. Coloring the surfaces according to how far apart the floor and ceiling are at that position illustrates this information. An example is shown in Figure 4.19.

Figure 4.19: The distance between ceiling and floor is used to set the intensity of surfaces. There is a large open dome in the right which is brighter than other areas in the visualization.

The component on the left is uniform in distance between the floor and ceiling

(indicated by the constant color) while on the right the model gradually expands into a large dome (indicated by the brightening color).

87

Next we consider illustrating width of open space regions in the level. A model may have a lot of space between its floor and ceiling but consist only of skinny passages.

In order to illustrate the width of a region, we color the surfaces with the distance to the nearest wall. As shown in Figure 4.20, this results in brighter spots running through the middle of passages and in wide open spaces like the dome on the right and the pocket in the bottom left.

Figure 4.20: The distance to walls is used to set the intensity of the surfaces. Tight passages are dark while large open areas are bright.

Lastly we consider how to illustrate the length of open passages in the level. We show this information by coloring the surfaces according to the distance to the boundaries of the model. An example is shown in Figure 4.21. The model is bright at the borders where a player could enter or exit the level and darker at dead ends deeper into the cave.

88

Figure 4.21: The distance to entrances and exits is used to set the intensity of the surfaces. The model becomes darker further into the cave.

All of these visualizations are useful in determining how open a level is, which gives the level designer an idea for how much space a player has access to. Using a single solid color to display a level does not provide as much spatial information as these visualizations. Given a pair or set of procedurally generated levels, a designer can compare the visualizations of the levels instead of estimating the space of each level individually through play testing.

4.3.2 Level Analysis

The visualizations in the previous section provide information useful for designers in evaluating a model for use as a level in a computer game. In this section we provide

89 methods to calculate spatial information of the models. This data can be used to automatically cull levels from a set of procedurally created levels. Just as in the previous chapter, the metrics provide spatial information on the entire level or subsections, unlike existing maze descriptive properties that only describe the space in its entirety. In order to calculate spatial data for a game level we use data structures used for navigation in computer games: waypoint graphs and navigation meshes.

A waypoint is a reference point in the space of a level. If there are no obstructions between two waypoints and the distance between the points is less than a user specified threshold, then there is an edge connecting them. The set of all waypoints and edges is called a waypoint graph. Figure 4.22 shows an island maze level and Figure 4.23 shows an example of a waypoint graph for that level.

Figure 4.22: A simple island maze level is shown.

90

Figure 4.23: An example of a waypoint graph for the level in Figure 4.22 is shown. The nodes are the brown circles and the edges are the line segments between the nodes.

The waypoint graph in Figure 4.23 was created by uniformly sampling the space of the level (every 100 meters) and connecting them when the line between them did not pass outside the level or exceed the distance limit (√200 meters). Waypoint graphs do not accurately model the amount of choice a player has when moving through a level. In the level in Figure 4.22 there are two routes for a player to move from the bottom left corner to the top right. The waypoint graph in Figure 4.23 has more than two ways to move from the node in the lower left to the node in the top right.

Waypoint graphs can be used to determine the length of a level. The shortest path between two nodes indicates the distance to travel between those two nodes. The distance between the start and end locations sets a lower bound on the length of the level. The pair of nodes with the longest shortest path indicates the longest path a player can take 91 without backtracking. Waypoint graphs can be used to classify a level as open or not.

Open levels have more freedom of movement than other levels so the waypoint graph for an open level will have more edges than graphs for other level types when using a high sampling density.

To automatically determine level type, we use navigation meshes. Waypoint graphs are discrete data structures created by sampling the environment. Navigation meshes are meshes of convex polygons that define valid areas of object or character movement in the environment. Navigation meshes were introduced in [104]. There are many ways to construct navigation meshes, including Space Filling [115], Triangular

Decomposition [44], and Adaptive Space Filling Volumes [41]. Figure 4.24 shows an example of a navigation mesh for the level in Figure 4.22. It was constructed using a greedy method that repeatedly finds the largest convex uncovered area of the level and creates a polygon in the mesh that covers it.

Figure 4.24: Navigation mesh of level. The polygons in the mesh are outlined in black.

92

Figure 4.25: Navigation mesh with adjacency graph. A node (brown circle) is placed at the center of each polygon. Adjacent polygons have connections between their nodes.

Navigation meshes also include an adjacency graph that indicates which polygons are connected. Figure 4.25 shows the adjacency graph embedded in the same space as the navigation mesh. The adjacency graph can be used to determine the level type: linear, branching maze, or island maze. If the entire graph is equivalent to a linked list the level is linear. From any point a player may move forward or backward, each corresponding to a neighboring node in the list. If the graph is a tree it is a branching maze. At some locations a player may make navigation choices (determining which child node to move to), but there is exactly one path from one node to another. If the graph has cycles it is an island maze or open level. A cycle can be explored in either direction, so there are two routes for each cycle. In Figure 4.25 four nodes form a cycle so we know the level must be open or an island maze.

93

From a navigation mesh we can calculate several properties that describe the geometry of the level. They are shown in Table 4.2.

n Total Area  ai i0

n m1 v j v j1 i0 j0 v j v j1 Interior Edge Length (IEL) ( if exists for px where

x  i )/2

n m1 Boundary v j v j1  IEL i0 j0

n mi Average Polygon Complexity i0 n

n  ai Average Polygon Size i0 n

Table 4.2 Navigation mesh properties

Let p be a polygon and PM  p0 , p1 ,, pn be the set of polygons in the mesh PM. For

a polygon pi we denote its verticesV  v0 ,v1 ,,vm1, number of vertices mi, perimeter pi and area ai. There are two ways to estimate the size of the level: the total area and its boundary. The total area of the navigation mesh is computed by summing the area of each polygon. The boundary of the level is found by summing the perimeter of each polygon and subtracting the length of shared edges. The navigation mesh of an open level 94 can have polygons with a higher number of vertices. The average number of vertices (or complexity in Table 4.2) indicates this value. The size of polygons in the mesh increases as the amount of open or unobstructed space increases.

The adjacency graph can be used to calculate information regarding the topology of the level. For a polygon pi we denote its node as qi. If two polygons pi and pj share an edge we add an edge qij to the adjacency graph. Let u be the total number of edges in the adjacency graph and ui be the number of edges for node qi. A cycle c is a simple path (i.e. one without duplicate nodes) that starts and ends at the same node. Let li be the number of nodes in the cycle ci. Let k be the number of cycles in the adjacency graph. The edge complexity is the average number of edges for a node in the graph. High edge complexity implies many alternative paths or dead ends in the level. Dead ends are nodes with only one edge. Every branch has a corresponding dead end, so the number of dead ends can be used to determine the amount of non-looping branching. The length of cycles in the graph also provides some spatial information. A longer cycle implies divergent paths that converge later. Short cycles are more likely to be caused by an obstacle in the level, which is the case in open levels, rather than alternative paths in maze levels. We summarize these values in Table 4.3.

95

u Edge complexity n

n Number of dead ends (DE) 1 i0 if ui = 1, else 0

Number of branches DE 1

k Average cycle length li i0

Table 4.3 Adjacency graph properties

In addition to determining the level type, these metrics and data structures can be used to determine other information useful to level designers. The size of the level and the number of dead ends in it can be used to estimate the amount of time a player will spend to get through it, similar to the metrics in the previous chapter. Island maze and open levels offer multiple routes for a player to proceed through the level. Performing searches on the adjacency graph gives the number of solution paths (paths from start to goal) for the level. A node that is in all solution paths is a choke-point. The designer knows that the player must pass through it. If a node is in a high percentage of the solution paths, the designer could place navigational cues to suggest the player move toward or away from it, depending on if they want to player to have longer or shorter gameplay time.

96

Chapter 5: Modeling and Editing of Non-Planar 3D Caves

The previous chapter introduced methods to create planar (single story) models of cave levels. This chapter eliminates the planar restriction and introduces interactive editing of models. First, we propose a new data structure called a prismfield similar to the heightfields used in Chapter 4. Next we discuss how to remove material from the model in a process similar to drilling. This step also includes introduction of a framework to model a multiple story cave using prismfields. We conclude by comparing the framework’s rendering performance and use in spatial navigation to existing methods used to model 3D caves.

5.1 Prismfield Framework

5.1.1 Prismfield Data Structure

Most caves form by removal of material over time, so the focus of this chapter is defining a framework that allows tunneling or drilling through solid material. We ignore conservation of mass and the need to support weight to avoid imposing limits on the artist. The first step in creating a framework for modeling non-planar 3D caves is defining the data structure used to model the solid material of the cave. Previous works,

97 as described in Chapter 2, used volume elements and run length encoded volumes to model caves. We would like to be able to apply the methods in the previous chapter to our non-planar models, so we propose a new data structure that can be viewed as an extension of heightfields.

A heightfield represents the surface between ground and air. Extruding the surface downward forms a corresponding three dimensional solid bounded by the original surface on top and the extruded surface on the bottom. A grid of quadrilaterals becomes a grid of polyhedra. The polyhedra are right prismoids, but for the sake of simplicity we refer to the data structure as a prismfield. A prismfield is a 3D solid that encodes the volume between two heightfields: the upper surface and the lower surface. Internally, we represent a prismfield P as two regular grids, the upper U and the lower L, of values representing height (y) at 2D positions (x,z). U and L have the same resolution, n by n.

For all values of x and z, Ux, z Lx, z.

A 2D example of a prismfield is given in Figure 5.1. The circles are vertices in the heightfields. The upper and lower vertices are connected in addition to the heightfield connectivity (left/right). The shared lines between adjacent prismoids are shared polygon faces in the 3D case. This data structure could be used to encode the open space of a planar cave as described in the previous chapter. In this chapter, we will examine the use of multiple prismfields, each representing a slab of solid material, stacked on top of each other to model a non-planar cave.

98

Figure 5.1: An example of a prismfield is shown. Circles are vertices and lines indicate connectivity between adjacent vertices. The result of deformation actions on the prismfield are depicted in Figures 5.3 and 5.4.

Heightfield deformation is done by selecting one or more vertices and raising or lowering them. Because heightfield data has a 2D structure, 2D brushes are used to select vertices. Since prismfields are stored as two heightfields, we can use the same 2D brushes to edit prismfields. The only difference is that we must handle the cases where

Ux, z Lx, z. From a physical standpoint, since we are dealing with volumes we cannot allow the upper surface to be at or below the lower one. Along with U and L, we store another grid, active, with Boolean values instead of height values. If active[x,z] is true then material is present at [x,z], otherwise no material is present. When rendering, prisms that contain inactive vertices are not drawn. In Figure 5.2, there are seven prisms that are not drawn because they include an inactive (shown in grey) vertex.

99

Figure 5.2: An example of a prismfield, as seen from above, is shown. Active values are true for black circles and false for grey circles. All prisms that contain an inactive vertex are not drawn.

Prismfields also support a form of constructive solid geometry editing using 3D volumes.

We place a convex 3D polyhedron, which we call a tool, in the same space as the prismfield. The editing process is split into two steps: vertical and horizontal drilling.

5.1.2 Prismfield Vertical Drilling

In the vertical drilling step, the active vertices of the prismfield are checked to determine if they are contained within the tool. Vertices in U are updated exactly the same as deformable heightfields. Removal of material is done by lowering height values.

100

Addition of material would be done by raising height values. The logic for vertices in L is reversed. Heights need to be raised to remove material and lowered to add it. After vertices are updated, in cases whereUx, z Lx, z, active[x,z] is set to false. An example of vertical drilling is shown in Figure 5.3. Here U and L are arrays of length 15

(indexed 0 to 14). A tool removes a large portion of material (lowering U[4] through U[8] and raising L[6]). Since U[6] < L[6], active[6] becomes false. The two prisms that contain

U[6] and L[6] are not drawn in the prismfield on the right, creating a vertical tunnel.

Figure 5.3: An example of vertical tunneling is shown. Before updating (a), the tool contains five vertices from U and one from L. Afterwards (b), four of the top vertices are lowered and one becomes inactive.

Since a single prismfield stores only two height values, horizontal drilling is not possible.

To incorporate this effect, a refinement to the framework using multiple prismfields is introduced in the next section.

101

5.1.3 Prismfield Framework and Horizontal Drilling

To allow horizontal tunneling in single and multiple storied cave models, we must use multiple prismfields. By splitting one prismfield into two, which we call the top and bottom prismfields, we can create a horizontal opening (i.e. the space between the U of the bottom and L of the top). Figure 5.4 shows an example of horizontal drilling.

First we identify cases where splitting should occur. Each prism edge (i.e. U[x,z] to

L[x,z]) is checked for collision with the tool. If the edge at [x,z] overlaps with the tool but

U[x,z] and L[x,z] do not, then we say the edge at [x,z] is a splitting edge. In Figure 5.4, out of edges 0 to 14, the splitting edges are 5, 6, and 7.

Figure 5.4: An example of horizontal tunneling is shown. Before updating (a), the tool is occupying the space between three upper and lower vertices. After updating (b), the prismfield has been split into two where the black vertices belong to the top prismfield, white belong to the bottom prismfield, and gray vertices are white and black vertices overlapping.

102

If there is a splitting edge and each of its neighbors are also splitting edges, then we split the original prismfield into two layered prismfields which we call the top prismfield and the bottom prismfield. After splitting, the top and bottom prismfields occupy the same space as the original without the region where the tool was.

Now we describe the splitting process and how vertices in the top and bottom prismfields are set. U of the top prismfield is U of the original prismfield. Likewise, L of the bottom prismfield is L of the original prismfield. Vertices in L of the top prismfield and U of the bottom prismfield are set to the average of the original U and L. Then the vertices for splitting edges are altered similar to the vertical drilling case. L[x,z] of the top prismfield are set to the max of the tool at [x,z] and U[x,z] of the bottom prismfield are set to the min of the tool at [x,z]. Further horizontal digging can require additional splitting, resulting in an array of prismfields. The lowest prismfield is at index 0. We refer to the prismfield at index i as Pi with upper surface Pi[U] and lower surface Pi[L]. Maintaining an array of prismfields complicates the vertical drilling step because adjacent prismfields may overlap. We say that Pi overlaps with Pi+1 if for any x,z, Pi[U[x,z]] > Pi[L[x,z]]. If this occurs after updating Pi[U[x,z]] we set it to Pi[L[x,z]] and if this occurs after updating

Pi[L[x,z]] we set it to Pi[U[x,z]].

Horizontal prismfield drilling splits a prism in one cell into two. After multiple instances of horizontal drilling, we have a list of prisms in the cell. For efficiency reasons, instead of storing an unordered set of prisms, we can encode the prisms as a set of heightfields.

103

5.1.4 Prismfield Framework Rendering

Rendering the array of prismfields is done by rendering each prismfield independently. Algorithm 5.1 is for rendering a prismfield of resolution n by m. Quad is a function that draws a quadrilateral given four vertices. Note that the algorithm is similar to rendering a heightfield, but instead of one quad per cell in the regular grid, a prismfield needs six quads per cell in the regular grid. This algorithm draws shared faces between prisms twice as well as occluded areas. We address this problem in the next section. The complexity of this algorithm is θ(nm), so the complexity of rendering the framework is

θ(nmk), where k is the size of the prismfield array. Two examples of prismfield framework renderings are shown in Figure 5.5 and Figure 5.6. Both have prismfields of resolution 256 by 256 and run at interactive frame rates.

104

Algorithm 5.1: Render Prismfield. for(x = 0; x < n-1; x++) { for(z = 0; z < m-1; z++) { // only draw if active if( active[x,z], active[x,z+1], active [x+1,z+1], active [x+1,z] ) { // top side of prism Quad( U[x,z], U[x,z+1], U[x+1,z+1], U[x+1,z])

// bottom side of prism Quad( L[x,z], L[x+1,z], L[x+1,z+1], L[x,z+1])

// left side of prism Quad( L[x,z], L[x,z+1], U[x,z+1], U[x,z])

// right side of prism Quad( L[x+1,z], U[x+1,z], U[x+1,z+1], L[x+1,z+1])

// front side of prism Quad( L[x,z], U[x,z], U[x+1,z], L[x+1,z])

// back side of prism Quad( L[x,z+1], L[x+1,z+1], U[x+1,z+1], U[x,z+1]) } } }

105

Figure 5.5: A model made using the prismfield framework is shown. The surfaces of the prismfields were generated procedurally. Then a user moved a tool that added material through the center of P0 and P1.

Figure 5.6: A model made using the prismfield framework is shown. Several cavities were drilled into a solid cube. The resulting model is represented using five prismfields. The boundaries of the prismfields on the cube borders have been outlined.

106

5.2 Implementation and Performance Results

We implemented the prismfield framework and editing operations using C++ and

OpenGL. For comparison, we also implemented a comparable application that used binary voxels. The voxel resolution (n3) was the same as the prismfield resolution on the x and z axes (n by n). Conversion from prismfields to voxels was done as follows: for each voxel (x,y,z), if L[x,z] ≤ y ≤ U[x,z] and active[x,z] = true for any prismfield, the voxel (x,y,z) is one (or active), otherwise zero (or inactive). All performance tests were done on a PC with an Intel Pentium 4 CPU clocked at 3.20GHz, with 3GB RAM, using an Nvidia GeForce 6800GT. Since we are interested in using the prismfield framework for games we examine two problems: rendering and navigation.

5.2.1 Prismfield Rendering

Algorithm 5.1 contains redundant rendering since adjacent prisms share left/right and front/back sides. Only the boundary faces – those between solid material and air – must be rendered. As an example, the prismfield in Figure 5.1 is equivalent to a heightfield. A heightfield is the boundary between air and solid ground below, so for

Figure 5.1 the prismfield’s boundary is its top surface. In addition to the brute force rendering Algorithm 5.1 we implemented an optimized approach that renders only boundary faces. Similarly, two rendering methods were implemented for binary voxels.

107

The brute force approach renders O(n3) cubes and an optimized version only draws boundary faces.

We refer to non-boundary polygons and faces as interior, as they are logically contained within solid material. If a prism or voxel is being drawn we say it is active, otherwise it is inactive. A face of an active voxel is interior if and only if the voxel sharing the face is also active. The same is true for prismfields. The side of an active prism is interior if and only if the adjacent prism that shares the face is also active. To determine if the top face of a prism is interior, we determine if there is a prismfield above with an active prism in the same (x,y) position then compare the top face of the current prism to the bottom face of the prism above. The check to see if the bottom face is interior is analogous. Examples of interior and boundary faces (for horizontally adjacent prisms) are shown in Figure 5.7. The figure shows several prisms from above. Active vertices are black and inactive are white. The gray area is solid and white area is air.

By definition, all faces for an inactive prism or voxel do not require rendering, so they are not drawn. In the optimized rendering algorithms, for an active prism or voxel we render all faces except interior ones. The prism pcenter is drawn because all four of its vertices are active. The prisms pup, pleft, and pright, are not drawn because each contains at least one inactive vertex. The dashed lines in Figure 5.7 indicated faces that do not need to be drawn. Solid lines indicate faces that are drawn when rendering pcenter and pdown. The only face of pcenter that is not drawn is the one between pcenter and pdown. This face is interior because it is between two solid prisms. The faces between pcenter and its other neighbors are drawn because they are boundary faces that separate air and solid material.

108

Figure 5.7: The top view of rendering a prism, pcenter, is shown. Active vertices are black, inactive vertices are white, and sides of pcenter that must be rendered (i.e. not interior) are solid lines. The prisms pup, pleft, and pright are not drawn, so the sides pcenter shares with these prisms are the boundary between solid material and air. The side shared between pdown and pcenter is interior since it is between two solid prisms.

Four data sets were created to compare rendering performance between the prismfield framework and voxels. Screenshots of the models are shown in Figure 5.8 at the end of this section. The first (a) was a heightfield formed by smoothing white noise values for U and a plane for L. The second (b) was made by scaling and reflecting a

Digital Terrain Elevation Data file. The third (c) was a cave system composed of three horizontal passages stacked vertically, created using the editing operations described in this paper. The last (d) was created by starting with a solid cube, and iteratively removing material according to a randomly moved sphere within the cube. Thirteen prismfields were present in the final result. Table 5.1 shows the number of milliseconds to construct and draw all faces of the model using the optimized rendering algorithms.

109

a b c d

prismfields 17.17 ms 33.47 ms 63.69 ms 75.02 ms

voxels 66.67 213.68 236.41 159.74

Table 5.1: Construction and rendering comparison, given in milliseconds

In these test cases, prismfields outperform voxels. The speed of the prismfield framework is inversely proportional to the number of prismfields needed to represent the environment. The amount of time needed to render the model increases with the addition of each new prismfield, from one (a) to two (b) to four (c). Performance is also dependent on the number of inactive prisms. Data set (d) used thirteen prismfields but the time to render it was only slightly longer than (c) despite having nine more prismfields.

Additional testing was performed to determine the scaling capabilities of prismfields. A single prismfield was rendered with different grid resolutions. The results are shown in

Table 5.2. Logically, rendering a prismfield is similar to rendering a connected pair of heightfields, so its performance at higher resolutions scales better than voxels, but not as well as heightfields.

prismfield resolution 64 x 64 128 x 128 256 x 256

Interior removed rendering 17.17 ms 66.09 ms 182.15 ms

Table 5.2: Prismfield resolution scaling performance, given in milliseconds.

110

Prismfields Voxels

Dataset (a)

Dataset (b)

Dataset (c)

Dataset (d)

Figure 5.8: Prismfield and Voxel data sets. Prismfield resolution is 642 and Voxel resolution is 643. The number of prismfields for each set is: 1 (a), 2 (b), 4 (c), and 13 (d).

111

5.2.2 Navigation with Prismfields

Now we examine the use of prismfields in another common game task: navigation. Figure 5.9 shows a vertical slice of a model that we will use as an example for discussing navigation when using the prismfield framework or voxels to model an environment. The grey portions of the scene are solid material and whitespace is open air

(where characters and objects may move in). Since prismfields and voxels both use a regular sampling method, we show the scene with a regular grid in Figure 5.10. The binary voxel representation of this environment is shown in Figure 5.11 and prismfield framework representation is shown in Figure 5.12.

Figure 5.9: A vertical slice of a scene is shown. Solid material is colored in grey. Open air is white.

112

Figure 5.10: The scene from Figure 5.9 is shown with a superimposed regular grid.

Figure 5.11: The scene from 5.9 represented with voxels (pixels in this 2D case). A voxel is on (grey) if any material is present in the corresponding cell of the regular grid.

113

Figure 5.12: The model from Figure 5.9 represented with three prismfields outlined in black. Only the upper and lower surfaces are shown, the interior prisms are omitted.

In Figure 5.11 a voxel is on and shown in grey if there is any solid material in the corresponding regular grid cell. Otherwise the voxel is off and shown in white. The scene can be modeled using three prismfields as seen in Figure 5.12 which we call prismfield 0,

1, and 2. Prismfield 0 is used to represent the bottom layer of solid material, prismfield 1 above it covers the ledge jutting out of the right side of the scene and a small chunk of the left but has inactive prisms in the center, and prismfield 2 represents the top layer of solid material.

Now we describe how to create a waypoint graph using voxels. Waypoint graphs, as described in Chapter 4, consist of nodes (sample positions in the environment) and edges (paths between nearby nodes). Every inactive voxel is a node in the graph and 114 edges are defined between nodes of adjacent inactive voxels. Consider the voxels in

Figure 5.11. Each white (inactive) voxel is a node in the graph. For the sample scene there are 72 nodes in the vertical slice. Edges are defined by two adjacent white voxels.

Here there are 119 edges. Now we propose a method to create a waypoint graph for a prismfield framework model. Prismfields encode solid material so the waypoint graph needs to fill the space between each layer of prismfields. Figure 5.13 shows this space with the same sampling resolution as the voxel grid. We define a sample of prismfields to be the ordered list of prism vertices heights at a given position (x,z). Because prismfields can have holes, there are a few different cases that must be handled. In Figure 5.13 there are fifteen samples (positions on x axis) out of eighteen samples that include open space in this scene. Consider sample with open space the furthest left, which we will call sample 2. The open space starts at U of prismfield 0 and continues to L of prismfield 2 because prismfield 1 does not have solid material at this sample. Continuing to the right, at sample 9 all three prismfields are present. The sample is split into two segments: one from U of prismfield 0 to L of prismfield 1 and the other from U of prismfield 1 to L of prismfield 2.

115

Figure 5.13: The space between prismfields from Figure 5.12 is regularly sampled.

A sample can have 0 to k-1 segments where k is the number of prismfields. A segment may span several prismfields. The spans of two samples are shown in Figure

5.13. Sample 8 spans from 0 to 2 (the indices of the prismfields) and sample 10 spans 0 to

1 (the lower segment) and 1 to 2 (the higher segment). We denote the span of a segment s as span(s). Each node in the waypoint graph corresponds to a segment. In Figure 5.14 they are shown as circles at the lowest point (i.e. at U of the lower prismfield in the span) of the segments in 5.13. The placement of these nodes assumes objects travel on the ground, but we could also place them anywhere along the segment. Edges connect segments that are horizontally adjacent. Segments i and j are horizontally adjacent if and only if i 1 j and ( span(i)  span( j) or span( j)  span(i) ). 116

Figure 5.14: Waypoint graph with nodes on U surfaces and edges from horizontal span adjacency.

For most locations in this example the spans for neighboring segments are the same, which results in two edges, one for each neighbor. The exception is sample 9 which has three edges. It has a span [0,2] and its left neighbor has span [0,2], making an edge. It has two right neighbors with spans [0,1] and [1,2]. Both of these are contained in

[0,2] so they both result in edges.

The waypoint graph constructed using prismfields is significantly smaller than the one for voxels, shown in Figure 5.15. In the example provided in Figures 5.9 through

5.15, there are 3.6 times as many nodes and 6.26 times as many edges in the voxel graph versus the prismfield graph. In general, prismfield waypoint graphs are more compact

117 than voxels due to increased compression of samples in the y dimension. For example, the column with the greatest number of white voxels generated eight nodes while the column with the most nodes for prismfields was two.

Figure 5.15: Waypoint graph with nodes and edges for each inactive voxels.

118

Chapter 6: Illumination of Caves in Computer Games

Speed is essential in rendering for games [49], so current games use pre- calculated illumination and local illumination models rather than costly real-time global illumination [19][30][37]. A survey of illumination models suitable for real time rendering in games can be found in [96]. Global illumination effects in games are driven by specialized algorithms, covered in Chapter 2. Illumination in computer games is used for many purposes. Some are akin to theatrical lighting, such as visibility of characters and objects, controlling focus of the audience, and setting the mood of a scene.

Illumination can also be used as a gameplay element. One example is Thief: Deadly

Shadows [48]. In Thief, the player can avoid enemies by hiding in darkness. The player can extinguish torches and turn off lights to create more areas to hide. Figure 6.1 shows an example of a scene in Thief: Deadly Shadows before and after a torch is snuffed out.

The area around the torch becomes darker after it is extinguished.

119

Figure 6.1: A scene from Thief: Deadly Shadows [48] before (left) and after (right) the player extinguishes a torch.

In this chapter we introduce an illumination model suitable for rendering of caves in games. The only natural light inside a cave comes from its entrances. In Section 6.1 we examine the use of existing illumination models given the condition of a single area light source positioned at each cave entrance. Under these conditions, many areas of the cave receive little to no light, which is a poor result. To address this problem, we introduce an illumination model based on radiant flux that can be parameterized so that all areas of a cave, maze, or game level receive enough light even if there is only one light source.

Conceptually, the model treats light as energy flowing through the environment much like the flow of water.

6.1 Cave Illumination using Current Illumination Algorithms

120

6.1.1 Light Reflectance Models

In this section we describe the behavior of illumination within a cave. The only natural light source in a cave is sunlight coming from its entrances. For performance reasons, most interactive graphics applications use a single bounce reflectance model for illumination. Figure 6.2 shows an example; the Cook-Torrance model [17].

Figure 6.2 The Cook-Torrance reflectance model from [17] is shown.

N is the surface normal at point P, L is the unit vector from P to the light source,

V is the unit vector in the direction of the viewer, H is the unit angular bisector of V and

L, and the α and θ values are angles between the vectors. If the light source is occluded at

P, diffuse and specular illumination at P is 0. Figures 6.3 and 6.4 show an example of a physical cave and a visualization of the areas in it where diffuse and specular lighting is zero (black regions) when the only light source is an area light at the entrance of the cave and no occlusion occurs in the interior of the cave passage. The majority of the cave is dark. Figures 6.5 and 6.6 show a similar example using a map of a cave from a video game. Almost the entire cave is dark. 121

Figure 6.3: A map of the Stuart Bat Cave [112] is shown.

Figure 6.4: A visualization of natural light in the cave from Figure 6.3 is shown. The blackened areas indicate areas with no specular or diffuse light when using a single bounce light reflection model.

122

Figure 6.5: A map of the Swamp Cave from The Witcher [15] is shown.

Figure 6.6: A visualization of natural light in the cave from Figure 6.5 is shown. The blackened areas indicate areas with no specular or diffuse light when using a single bounce light reflection model.

123

Using a multiple bounce reflectance model, such as radiosity [39] or photon mapping [51] still produces poor results. Cave walls have low albedo and reflect light poorly. Nearly all light is lost after two or three bounces. There are still regions in these caves that receive no light, even in the best case scenarios. Figures 6.7 and 6.8 visualize the minimal number of light reflections required to reach surfaces deep in the caves in

Figures 6.3 and 6.5. Due to low light reflection, there will be no light in these regions even when using multiple reflections.

Figure 6.7: A visualization of light reflection in the cave from Figure 6.3 is shown. Light must bounce at least five times to reach a surface deep in the cave.

124

Figure 6.8: A visualization of light reflection in the cave from Figure 6.5 is shown. Light must bounce at least six times to reach a surface deep in the cave.

6.1.2 Ambient Occlusion

Since reflection models produce poor results for illuminating caves under natural lighting conditions, we examine the use of an illumination algorithm that does not involve reflection: ambient occlusion. Ambient occlusion is used to crudely approximate global illumination without simulating multiple reflections of light. We need global illumination to provide light deeper in the cave but do not obtain good results using reflection based models as demonstrated in the previous section.

Ambient occlusion models the attenuation of light at a point x with normal n by integrating the visibility function V(x,ω) over the hemisphere at x oriented according to n

[125]. The visibility function V(x,ω) is zero if the ray in direction ω intersects geometry 125 and one otherwise. Ambient occlusion calculates the amount of energy at a point x, with

1 normal n, as A(x, n) : V (x,)  n d . An example is illustrated in Figure 6.9.  

Points closer to the corners will be darker than those further away due to more occlusion of the visibility function.

Figure 6.9: An example of ambient occlusion is shown. Rays are sent from point x to determine how many are occluded. The occluded ray, ω2, has a cross over it. Rays sent out from x in the white regions in the hemi-circle will reach the light source and rays from the gray regions will not.

Figure 6.10 shows the result of ambient occlusion at a point in Figure 6.5, more specifically the second light reflection from Figure 6.8. When using ambient occlusion, this point in completely in shadow. Ambient occlusion produces poor results for closed environments such as caves.

126

Figure 6.10: An example of ambient occlusion is shown. The visibility function for every ray originating from point 2 is zero, which makes the point completely in shadow when using ambient occlusion.

6.2 Light as Radiant Flux

The problem with existing illumination models when rendering a cave using only natural light sources is that large areas of the cave are completely dark. We propose a new illumination model to address this problem. We model the behavior of light using an optical density model that measures transmittance and absoptance of radiant flux in a medium. It can also be thought of as a path loss (or path attenuation) model that causes a reduction in power density of an electromagnetic wave as it propagates through space.

Given a scalar value representing the intensity of light entering the cave, by controlling

127 the rate that light is absorbed as it propagates through the cave, we can ensure a varying

(and non-zero) amount of light in every area of the cave. We calculate illumination as the amount of light reaching a point rather than how much light that point reflects or how occluded it is globally. The approach can also incorporate ambient occlusion for local illumination details, similar to [36]. Table 6.1 contains a list of symbols used for the remainder of the chapter.

Intuitively, the deeper inside of a cave, less light will be present. We want to be able to estimate its rate of decay in order to determine how much light should be present at different areas within the scene. Photons are elementary particles of light that carry radiant energy, denoted as Q. The amount of radiant energy sent out from a light source over time, denoted as t, is radiant power, denoted as Φ and is also known as radiant flux.

The amount of power incident to a surface is irradiance, I. The amount of power radiated by a surface is radiant emittance, M. Radiant flux is propagated through volumes. In this case we model light propagated through air. We denote the amount of radiant flux at a point x within a volume v as RF(x,v) and use this as the amount of light at x. For the remainder of this section we describe how to calculate radiant flux.

128

Symbol Meaning x Point in R3

ω Vector in R3 v Volume in R3

S 2D surface in R3 n Surface Normal

Q Energy t Time

Φ = dQ/dt Radiant Power [or Radiant Flux] dA Differential area of a surface

I = dΦ/dA Irradiance

M = dΦ/dA Radiant Emittance

RF (x,v) Radiant Flux at x within volume v

Senter 2D surface light enters volume

Sexit 2D surface light exits volume

RFenter Flux at an entrance of a volume

RFexit Flux at an exit of a volume a(v) Absorptance of a volume vlength Volume length parameter vshape Volume shape parameter

Table 6.1: Table of symbols and terms

129

We denote the amount of energy entering a volume through a surface Senter as

RFenter and the amount of energy leaving the volume through surface Sexit as RFexit. We assume the amount of energy at every point on Senter is the same. We make the same assumption on the amount of energy at every point on and Sexit. In other words, we assume M and I and constant on Senter and Sexit. An example is shown in Figure 6.11. By definition, the value for radiant flux two different points on the entering surface, x1 and x2, are both equal to RFenter and the value for radiant flux two points on the exiting surface, x3 and x4, are both equal to RFexit. We can calculate RF(x,v) based on how much flux is lost, or absorbed by the time it reaches x.

Figure 6.11: Radiant flux in a volume v is shown. Points on the surface where light enters the volume have the same radiant flux. Similarly, points on the surface where light exits the volume also share radiant flux values.

130

Absorptance, which we denote as a, is the ratio of radiant flux absorbed by a volume v. Absorptance is defined as:

RF  RF a(v)  enter exit Eq. (6.1) RFenter

The amount of light entering the cave, Q, is given as input and can be used as a value for RFenter. In order to determine illumination, we need to know the amount of light exiting the volume:

RFexit  RFenter 1 a(v) Eq. (6.2)

Absorptance, a, is based on the length and shape of the volume the flux is passing through. Length, vlength, is the path distance from the entrance of the volume to its exit.

Absorptance is directly proportional to length. Intuitively, the longer the passage, the less light will reach the end. Revising Eq. 6.1 yields

RFenter  RFexit  a(v)  vlength Eq. (6.3) RFenter

Taking the limit of Eq. (6.3) as vlength approaches zero yields a = 0 and the exiting flux equal to the entering flux. In order to calculate RF(x,v) we need to estimate a(v) based on vlength and vshape and create a method to relate RFexit to RF(x,v). To do this, we first examine creation of volumes based on cave level geometry.

6.2.1 Cave Level Geometry and Volumes

131

One way to calculate RF(x,v) is by decomposing a volume into sub- volumes. We ignore backward transmission of flux between sub-volumes. An example is shown in Figure 6.12. By splitting v into v0 and v1, with the assumption that radiant flux is constant on Sexit, we know that the radiant flux at x is equal to RFexit of v0, the amount of flux exiting the first volume.

Figure 6.12: A decomposition of the volume from Figure 6.11 is shown. RF(x,v) is the same as the exiting flux of v0 since we assume radiant flux is constant on entrance and exit surfaces of volumes.

The selection of the surface between v0 and v1 in Figure 6.12 is not arbitrary. First we find the point, p, on the centerline of v closest to x. The surface is perpendicular to the centerline at p. Essentially this makes radiant flux flow along the centerline. We can subdivide a level by sampling at regular intervals of the centerline. The shape of sub- volumes created depends on the shape of the original volume, which we can classify as

132 fitting one of the four level types. Now we discuss common sub-volumes created when decomposing each of the four level types.

6.2.1.1 Volumes in Linear Levels

Linear levels decompose into cylinders, cones, and elbows. A cylinder has Senter and Sexit with approximately equal area and orientation. A cone has Senter and Sexit with approximately equal orientation but different areas. An elbow has Senter and Sexit with different orientations (areas may be the same or different). An example of a subdivided linear level is shown in Figure 6.13. The initial straightaway, v0 has a cylinder-like form, followed by an elbow bending left v1, an elbow bending right v2, and ending with a cone- like form v3. The green lines indicate the entrances and exits of the volumes.

Figure 6.13: A top-down view of a linear level (left) and a subdivision of it (right) are shown. Flux enters the volumes in order of increasing numeric subscript. We ignore 133 backwards propagation, so flux entering v1 will not be transmitted to v0. Arrows at each cross section indicate the direction of flow.

6.2.1.2 Volumes in Branching Maze Levels

Branching maze introduce sub-volumes with multiple exits. We call this type of sub-volume a junction. An example is shown in Figure 6.14. The volume v2 recieves flux from v1 and has two adjacent volumes, v3 and v4 for flux to exit. RFenter for v2 is equal to the sum of the flux decay within it plus RFenter for v3 and v4. The volume v4 is a dead-end.

Since it has no exit and flux only propagates forward, there is no RFexit value for v4.

Figure 6.14: A branching maze level is shown. Now volume v2 is a junction with two adjacent volumes to transmit flux to. A new region v4 is a dead-end with no exit or exiting flux.

134

6.2.1.3 Volumes in Island Maze Levels

Island maze levels introduce junctions with multiple surfaces of entering flux, which can potentially introduce loops in propagation. To handle this problem, we first consider how to illuminate a cave with multiple entrances. Consider the linear cave from

Figure 6.12, but now instead of an entrance and exit, each is an entrance where light comes into the cave. This is illustrated in Figure 6.15. The flux within a sub-volume is the sum of radiant-flux coming from each of the two entrances. In general, when light may reach a sub-volume from more than one direction, entrance, or path, we calculate the amount of flux by summing each unique contribution of light.

Figure 6.15: A cave with two entrances is shown. The flux from each entrance (indicated by the color of the arrow on each cross section, black for the left entrance, gray for the right) propagates through the cave. The flux within one sub-volume is the sum of the two entering fluxes.

135

Figure 6.16 shows an example of an island maze level that contains junctions.

Here v0, v1, and v2 are adjacent to each other. Flux can enter v2 from v0 and v1. Likewise flux can enter v1 from v0 and v2. This means we cannot simply proceed in order of increasing volume subscripts to calculate incoming flux, since v2 propagates some to v1.

We must consider the path that flux travels to avoid loops and backwards propagation of flux. The amount of flux entering a volume is the sum of all flux coming from each unique path from the source to the volume. For the level in Figure 6.16, the entering flux of v0 is known. The flux in v1 is the sum of RFexit on the surface between v0 and v1 and

RFexit on the surface between v2 and v1 (where RFenter is on the surface between v0 and v2.

In other words, entering flux in v1 comes from two paths: v0 to v1 and v0 to v2 to v1. A volume may have multiple values for entering flux, and a sub-volume can appear in more than one path (as v0 did in this case), but each volume may only appear once in each path

(this avoids backwards propagation and loops). This type of sub-volume affects calculation of entering flux for all volumes, not just junctions. Even though v3 has one surface for flux to enter from, its entering flux is the sum of flux from two paths: v0 to v1 to v2 and v0 to v2.

136

Figure 6.16: An island maze level is shown. Now v0 and v2 are junctions. The black arrows indicate one path of flux flow and the gray arrows indicate another path caused by the junction v0. There is a cycle between v0, v1, and v2. To determine the amount of flux entering each volume, we follow each unique path from the entrance to each volume, keeping the restriction of no backwards propogation of flux. No looping is allowed during the flux propagation process, so each subvolume may appear once in each flux path.

6.2.1.4 Volumes in Open Levels

Decomposition of open levels into volumes requires a different approach, as they cannot be limited to pipe-like shapes such as cylinders, cones, elbows, and junctions.

Instead we use a more general spatial subdivision approach such as regular grids. Figure

6.17 shows an example of dividing an open level with regular grids. Many of the volumes are cubes, but boundary cases have irregular shapes. Just as with island maze levels, the flux in a volume is the sum of all flux coming from each unique path from the source into the volume. The paths cannot contain loops as this would violate the restriction of no

137 backtracking. Three examples of paths that start at the entrance and reach v0 are shown in

Figure 6.17. The paths are drawn as curves for illustrative purposes; a path only consists of the sequence of grid cells (i.e. sub-volumes) flux moves through. Paths p0 and p1 are unique even though they start in the same volume since they do not pass through the same series of volumes in the same order. Path p2 is not a valid for our model of flux flow because it contains a case of backward propagation.

Figure 6.17: An open level (left) subdivided using a regular grid (right) is shown. In the right image, there are many routes to traverse through the grid to reach v0. Paths may run through the same volume, such as p0 and p1. Paths may not reenter volumes like p2 does at the black x over its path. The amount of flux at v0 is the sum of flux from each unique path (with no loops) through the sub-volumes that begins at the entrance and ends at v0.

138

6.2.2 Estimating Absorptance

Having defined a subdivision for flux propagation, we need to determine how the length and shape of a volume affects flux propagation. We consider flux propagation in a volume with a single entrance which provides a single value for entering flux. A volume may receive flux from many surfaces, but we can process them one at a time and sum the contributions to find the total flux. We examine how the length of a volume affects flux propagation first.

6.2.2.1 Absorptance and Volume Length

In the previous section we reasoned that the volumes length is proportional to its absorption. To more precisely estimate this relationship we examine the effect of vlength of a cylinder. Figure 6.18 shows an example of a cylinder with a point on the surface where flux enters the volume.

Figure 6.18: A volume with labels for its length, half-width, surfaces of flux entering and exiting, and a point on the entering surface with its normal are shown. 139

Flux enters the volume as photons, which are points, p, we assume are equally distributed on Senter. Each photon also has a direction, ωp, which is a random vector in the hemisphere oriented on the normal at p. If the photon reaches Sexit its energy will contribute to RFexit. Given a ray at p in direction ωp, there are two cases: it intersects Sexit first or it intersects with scene geometry first. In the first case, the photon contributes to

RFexit. In the second case the photon is absorbed or reflected based on the surface’s bidirectional reflectance function. For the purpose of calculating the effect of vlength we assume these photons do not contribute to RFexit. Note that this is effectively the same assumption of single bounce light reflectance models.

To estimate the amount of flux from one point p on Senter that propagates to Sexit we consider each direction on the hemisphere oriented on the point’s normal:

1 RFexit ( p, n) : V ( p,)  n d where the visibility function V( p,) is 1 if the ray   intersects Sexit first and 0 otherwise. The total amount of radiant flux considers the

1 contribution of each point on Senter: RFexit (Senter ) : V( p,)  n d dA. S  

We want to know how fast V ( p,)   n d decreases as vlength increases. This    occurs at a quadratic rate. Figure 6.19 illustrates this with a geometric example. A slice of two volumes are shown, one with twice the length of the other. In the top slice,

v / 2 v / 2 tan( / 2)  width . In the bottom slice, tan( / 2)  width . This is a linear decay. vlength / 2 vlength

The other slicing orientation has the same linear decay, so the total decay of flux 140 propagation for a volume based on vlength is quadratic. Since absorption is a percentage, we consider the length of the subvolume compared to the length of the entire volume when calculating the effect of vlength.

Figure 6.19: Two volume slices, one with twice the length of the other are shown. The value of θ in the top slice is roughly twice as large as the value of θ in the bottom slice.

Now that we have a more precise value for absorption based on vlength, we update

2  volume_ length  our equation for volume absorption (Eq. 6.3) to   , where a(v)     vshape  total _ length  141 volume_length is the length of the subvolume and total_length is the length of the cave.

max More specifically, total_length is shortest _ pathpi , penter , where pi is a point in pi the cave, penter is the entrance point of the cave, shortest_path is a function that gives the distance of the shortest path between the two points. The division by total_length ensures the vlength ranges from [0,1]. Now we turn our attention to determining how the shape of a volume affects absorptance.

6.2.2.2 Absoprtance and Volume Shape

One way to determine how shape affects the rate of radiant flux absorptance in a volume is to consider the path that photons follow in a volume. Consider the example in

Figure 6.20 which shows several paths that photons can travel through a cylinder. In the top image photons oriented on the normal of Senter will all reach Sexit. Photons headed in a different direction in the hemisphere around the normal of Senter may reach Sexit after one or more bounces or not at all due to absorption on collisions with the volume’s boundary.

In the previous section we defined the amount of radiant flux exiting the value as

1 RFexit (Senter ) : V( p,)  n d dA. We can use the same formula if we change S  

V( p,) to be one if a photon reaches Sexit after one or more reflections in addition to those that reach Sexit with no reflections. V( p,) is zero if the photon is absorbed on a collision or if it is reflects back to Senter.

142

Figure 6.20: Two sets of photons traced through a cylinder are shown. Photons on the entrance cross section may have headings perpendicular to the entrance (top) or randomly distributed (bottom). Line thickness indicates quantity of photons along the ray. The exiting flux for the top case is the same as entering flux whereas exiting flux decreases for the bottom case.

There are two problems with this approach. The first is thatV( p,) is dependent on the length of the volume, so it is calculating a(v) rather than vshape. The second is that it will give results similar to multiple reflection models of illumination. Every elbow will cause a large amount of absorption and loss of radiant flux. Since our goal is to isolate the effect of shape on absorption, we propose a model for vshape based solely on Senter and Sexit.

In order to determine how Senter and Sexit affect the absorptance of a volume, first we examine the relationship between Senter and Sexit and how it varies for the different volumes: cylinders, cones, elbows, and junctions. Figure 6.21 shows a cylinder and the normal vectors on its entering and exiting surfaces. As the length of a cylinder 143 approaches zero the two surfaces are the same, so the exiting flux should be equal to the entering flux and absorption is 0.

Figure 6.21: A cylinder with surface normals on Senter and Sexit are shown. The two normal vectors are the same and Senter and Sexit have the same area.

Figure 6.22 shows two examples of truncated cones, one where the area of Senter is less than the area of Sexit and the other where the area of Senter is greater than the area Sexit.

As the length of the left cone approaches zero, all of Senter overlaps with Sexit so all flux should propagate through the volume. As the length of the right cone approaches zero, parts of Senter will not overlap with Sexit, this area indicates the proportion of flux that does not propagate through the volume. In general, the areas of the enter and exit surfaces

 area  area  contribute to absorptance as follows:  enter exit  , where area a(v)  min1,  enter  areaenter  is the area of Senter and areaexit is the area of Sexit.

144

Figure 6.22: Two cones are shown with surface normal vectors on their entrances and exits. In the left cone, the exit is larger than the entrance and in the right cone the exit is smaller than the entrance. Less flux will propagate through the cone with a smaller exit.

Elbows can also have different areas for Senter and Sexit. We handle it the same way as cones, by taking the ratio of the areas. Elbows also have different normal vectors at the entrance and exit of the volume. In Figure 6.23 the angle between the normals is shown as θ. For a cylinder this angle is 0 and all flux propagates through. The worst case for flux propagation is when the angle is π. In this case, flux would be propagating backward.

Since we ignore backwards propagation, the exiting flux is 0 in this case. In general, the unit normal vectors of Senter and Sexit contribute to absorptance as follows:

 nˆ  nˆ  1 a(v)  enter exit  . 2 2

145

Figure 6.23: An example of a cone is shown. The angle between the normal vectors of the surfaces is θ. Absorption of the volume decreases as θ approaches zero.

Combining the contribution of areas and normal vectors of the entrance and exit

 areaenter  areaexit    nˆ  nˆ  1  surfaces we have   enter exit . Lastly, we a(v)  min1,       areaenter   2 2  must consider the effect of multiple exits in junction volumes. Calculating exiting flux for each exit independently may result in the sum of all exiting flux for all exits exceeding the entering flux, which is invalid. To avoid this problem, we assume that radiant flux has an equal chance to leave through each exit. We update our formula for absorption based

 nˆenter  nˆexit  1  area  area    enter exit  2 2 on shape to a(v)  min1,   , where num_exits is  areaenter  num _ exits 146 the number of exiting surfaces in the volume. Thus the final formula for calculating the absorption of a single exit of a volume is:

 nˆenter  nˆexit  1 2   volume_ length   area  area  a (v)  a (v)     min1, enter exit   2 2 . length shape      total _ length   areaenter  num _ exits

6.3 Radiant Flux Illumination

Now that we have a model for absorption and flux propagation in a scene, we discuss how the value of radiant flux can be used for illumination and compare the results with the examples from earlier in this chapter. The calculation of radiant flux provides a scalar value at every point in a scene. The model also provides vectors for the entering and exiting surfaces of the volume the point is contained in. There are two ways we can use radiant flux for illumination, one based on local illumination models and the other based on ambient occlusion.

Recall that for local illumination of a point we need a normal vector at the point, a light source (intensity and vector to the point we are shading), and the vector to the viewer (which is given). For the surface normal, we can use the normal of the point in the volume (since we ignore surface details when calculating flux) or the normal of the geometry at the point. For the light source, the scalar radiant flux value can be used as the light intensity. The light vector can be the normal of the entering surface of the volume, or the vector of the centerline of the volume closest to the point. Since the surface normal and centerline vector can vary within the volume, the resulting shading is not flat.

147

The alternative method of illumination is to take the scalar radiant flux value and map directly to ambient illumination, similar to ambient occlusion. Ambient occlusion defines illumination at a point based on the percentage (a scalar value) that is occluded by scene geometry. We can use the same approach if we map radiant flux values to percentages. There are multiple ways to do this, but the easiest way is to divide by the initial energy entering the scene since this is a maximal value for radiant flux. Now that we have multiple ways to use radiant flux for illumination we discuss its results.

Consider radiant flux propagation in the level from Figure 6.5. Figure 6.8 showed a path for multiple light reflections in the level. For comparison, we will consider flux along this path rather than the shortest path as described in the previous section. The illustration is repeated in Figure 6.24 for the sake of convenience. We consider the amount of radiant flux at each point of reflection in the path.

Figure 6.24: A path for multiple light reflections in a cave level is shown.

148

We examine the effect of vlength first. The path in Figure 6.24 is 684 meters long.

Along the path, point 1 is at 44 meters, point 2 is at 170 meters, point 3 is at 314 meters, and point 4 is at 484 meters. When vshape is ignored and quadratic attenuation is applied

2  length  based on vlength, i.e. a    , these points correspond to radiant flux losses  total _ length  of 0.4%, 6%, 21%, and 50% of the original entering flux. Now we consider the effect of vshape. Assuming the entrance is a cylinder, there is no radiant flux loss due to shape at 1.

To reach 2, flux passes through an elbow bending near an angle π/2, a loss of 50%, bringing flux down to 50%. At point 3, flux has passed through a junction with two exits again at an angle near π/2, which is a loss of 75% of flux, bringing the total to 12.5% of flux. Point 4 is reached after a junction with two exits but through an exit with a near parallel orientation. This is a loss of 50%, bringing the total down to 6.25%.

Combining the effects of vlength and vshape yields the following percentage of original flux at the points: 99.6%, 47%, 9.875%, and 3.125%. At point 4, which is roughly two thirds of the way through the cave, nearly all light is lost. The radiant flux model propagates light through the scene, but the rate of energy loss is still too high.

Since vshape causes the majority of radiant flux loss, we propose lowering its contribution to absorption in order allow for more light deeper into the level. We update our formula to weight the effect of length and shape, giving absorption

a(v) length  vlength  shape  vshape. To limit the effect of vshape, we set shapeto a small value. Alternatively, absorption can be used to determine where additional light is needed. This would drive placement of additional light entrances or local light sources.

149

6.3.1 Implementation

Now we consider how to implement illumination using path distance. Let the amount of light intensity entering the cave be Q. In order to determine the illumination at a point x within the scene, we need to compute the distance of the path from entrance of the level to x. Let path(x) be a function that searches for the shortest path and returns the distance d the path covers. Call path on every vertex in the scene. This results in a range of distance values [0, dmax] where dmax is the distance to the vertex furthest away from the entrance in meters. The amount of ambient illumination at x can be set with units

Q luminance per meter2 as or as percent of luminance based on flux decay pathx2

2  pathx Q    . Calling path repeatedly introduces redundant computation. Vertices  d max  close to each other will have similar distance values, so there is no need to search for the entire path if we already know the distance value of a nearby point. We can approximate path using an all pairs shortest path algorithm such as the Floyd-Warshall algorithm, which takes O(V3) time where V is the number of vertices. Accurate surface detail of rock surfaces and speleothems in a cave requires a large number of vertices, so we calculate path at spatial subdivision centers.

To calculate path values, we store values in a regularly sampled grid in three dimensional space. The values encode distance to the surfaces where flux enters the volume. This data structure is called a distance field. In computer graphics, distance fields typically store the distance to the nearest object in the scene. Here, it stores the 150 distance to the entrance. There are many ways to construct distance fields [53]. The simplest way is by performing a breadth first search. Let df[x,y,z] denote the distance field value at point (x,y,z). Initially, all df values are set as -1 to denote they are unexplored. Distance field samples at the entrance are set to 0. The breadth first search assigns newly explored samples as one higher than the sample that found them. Each df sample is explored once and the search terminates when the list of samples to explore is empty. To illuminate a vertex in the scene, we generate a path value by tri-linear interpolation of the surrounding regular grid samples. The distance field construction process takes O(V+E) time, where V is the number of nodes in the graph and E is the

3 number of edges. For a regular grid of resolution n in three dimensional space, V is n and

E is O(n3), so the total time is O(n3). For a planar cave, we can sample a 2D grid, bringing the time down to O(n2). Similar to radiant flux, path illumination provides scalar values. We can use the same two approaches to using the scalar value for illumination: as the intensity of local light source or as light intensity similar to ambient occlusion. Within a distance field cell, by comparing its distance value to that of neighboring cells we can determine which direction(s) light come from to compute a light direction vector. Figures

6.25 and 6.26 show examples of a simple cave environment lit with path illumination, where the scalar values are mapped directly to ambient illumination. After adding openings in the back of the cave, the regions around the new openings are brighter.

151

Figure 6.25: A cave lit using path illumination is shown. In this scene, all six faces of the bounding box of the model are treated as entrances.

Figure 6.26: A cave lit using path illumination is shown. As in Figure 6.25, all six faces of the bounding box of the model are treated as entrances. Note the change in illumination when material on the back face of the cube is removed, letting additional light into the scene.

152

6.3.2 Generalization

Up until this point we assumed the only source of ambient illumination came from the outside of the cave level, but this may not always be true. In cases where light sources are brought into the cave, we can extend our approach to include multiple light sources both outside and inside the cave. For a light source inside the cave, instead of initializing grid samples at the entrance to zero, we set samples by the light source position to zero. The remainder of the algorithm is unchanged. Figure 6.27 shows an example of a simple cave scene lit using path illumination and a point source. The effect is similar to single reflection illumination when using a low intensity light source, with two key differences. First, polygons with a normal facing away from the source receive the same illumination as those with normal towards the light source. Second, polygons that are occluded from the light source still receive illumination. Both of these differences err on the side of over-illuminating rather than under-illuminating (the common problem in single bounce light reflection models).

Multiple light sources are supported by storing a distance field for each light source. Given lights l1, l2, …, ln, let dfi be the distance field for light li. We calculate illumination as a weighted sum of the contribution of each light source. To determine the amount of light present at a point, the intensity of each light is modulated according to its df value at the point and added with the contributions of the other lights.

153

Figure 6.27: A cave lit using path illumination and a point source is shown. The point is shown as a sphere with a black outline and a drop-shadow to indicate its position in three dimension space.

For a scene with light sources of uniform intensity and sparse placement (i.e. little to no overlapping of light at any point in the level), we can approximate this by taking the minimum df value at the point, denoted dfmin. In this case, we do not need a separate distance field for each light. We can obtain the same value by having one distance field, initializing values for every light source, and performing the breadth-first search as usual.

Each df value will be dfmin from the original case. Only one distance field is needed for illumination instead of one for each light. This lets the number of lights scale up with constant cost rather than linear, but adding a second light source in the same location will not make the scene around it brighter.

154

Chapter 7: Path Illumination for Navigational Assistance

In this chapter we examine an application area of path illumination: navigational assistance in virtual environments. To do this, we briefly discuss generalizing path illumination for use outside of illumination of caves, then overview existing navigational aids, and finally provide results of a user study validating the use of path illumination as a navigational aid.

7.1 Distance Illumination and Navigational Aids

The result of path illumination using distance fields brightens areas closer to the entrance of the cave, essentially highlighting the shortest path to the entrance or exit of the cave. Distance fields are a general tool, so we are not restricted to only using lights as sources when constructing the distance field. We can use any geometry or object(s) of interest within the scene. Therefore, we can use path illumination to highlight areas of importance in a scene. Figure 7.1 shows an example of this in a generic maze model. The goal for the user is to find a black sphere placed within the maze. The path the user takes to reach it is shown in orange. Orange circles are the positions of the user at various junctions that are shown in Figures 7.2 to 7.6. In general, the areas close to the goal are

155 brighter than those far away, where the user starts. Figure 7.2 shows the initial position of the user.

Figure 7.1: Distance field based illumination of a maze as viewed from above. The distance field is constructed with the black dot as its source. The orange circles are user positions within the maze over time. The orange path represents the movement of the user within the environment. The user’s navigation decisions were driven by perception of illumination within the maze.

156

Figure 7.2: A view from the starting location of the user within the maze is shown. Brighter areas can be seen further into the maze on the left and right, but the right is brighter.

Figure 7.3: This is the view the user sees at the first junction after initially heading right. The regions on the left are brighter now. 157

Figure 7.4: This is the view immediately after the user turns left at the first junction. The walls on the left and right have similar brightness, so the user arbitrarily chooses to move left to get around the obstacle in the middle.

Figure 7.5: This is the view after the user passes the obstacle in the middle of Figure 7.4. A very bright wall can be seen in the center of the screen, deeper into the maze.

158

Figure 7.6: The view of the user finding the goal is shown. Off in the distance the maze is darker.

In Figure 7.2 the user has two choices – left or right. Since the user can see brighter walls on the right, they move in that direction. The user continues in that direction until reaching the junction in Figure 7.3. The interior of the maze is brighter, so the user turns left to go deeper in. Almost immediately after turning, there are walls blocking the user from moving straight forward in Figure 7.4. The walls on either side have roughly the same shading, so the user could choose to go around either way. After moving around the walls by moving left, the user can see further into the maze in Figure

7.5. The user continues to move towards the light, ending at the goal as seen in Figure

7.6. In each of these locations, the user could determine which direction to move, continuing to move closer to the goal.

159

To test the use of distance illumination in the role of navigation assistance, a user study was performed, comparing it with existing navigational aids. One way to classify navigational aids is by how much instruction they provide the user. Some provide step- by-step directions. The user can reach their destination by following the directions without doing any route planning of their own. However, at any given point in time the user may not know the exact location of their destination. In contrast, other aids provide information about the destination and environment instead of giving directions. As long as the user is given enough information, they can plan their own route to determine which direction they should move. Support for multiple destinations is another way that navigational aids can vary. A pointing device can only refer to one destination, so multiple pointers are required for multiple goals. In contrast, a single mini-map can provide information about many destinations simultaneously. Figure 7.7 provides several examples of navigational aids. Again the user’s target to reach is a black sphere. In the top left an arrow in screen space prompts the user to continue moving straight. Other orientations indicate the need to turn left, right, or move backward. In the top right a line in camera space extends in the direction of the goal. In the bottom left a path from the user to the goal is drawn. In the bottom right a mini-map indicates the player and goal positions.

160

Figure 7.7: Four navigational aids are shown. An arrow indicates that the user should move forward (top left). A line extends in the direction of a goal (top right). A path from the user to the goal is drawn within the environment (bottom left). A map depicts the locations of the user (gray circle) and goals (black circles) within the environment (bottom right).

7.1.1 Screen Space Pointing Arrow

An arrow in screen space is shown in Figure 7.7 (top left). The arrow is placed to the left of the viewing window that displays the world. Its orientation is based on the shortest path to the goal and the user’s current heading. The arrow provides the action the user should take to reach the goal: up and down mean move forward or backward while left and right indicate a direction to turn.

161

7.1.2 World or Camera Space Pointer

Alternatively, we can place a pointing device in world or camera space. A line indicates the vector from the user’s current position to a goal. The line comes out of a cube so the user has a visual reference on where the line starts. This is shown in Figure

7.7 (top right). The pointer provides information on the direction to the goal’s location.

The previous aid provided all of the necessary information to solve the navigation problem. With this aid we can provide the user with some assistance – indicating where the goal is – without giving a solution (i.e. the actual path). This can lead to situations where the aid points towards a wall, which is frustrating to users who do not understand the intent of the aid. An example of a pointing device in a commercial video game is shown in Figure 7.8. An arrow points to the next location in the storyline. A path of Lego discs leads up to the arrow.

Figure 7.8: Two examples of navigational aids used in Lego Harry Potter: Years 1–4 are shown. Semi-transparent Lego discs create a path for the player to follow an arrow points to the entryway to the next location.

162

7.1.3 World Space Path

Rather than give directions to follow the shortest path, instead we can render the path within the world. This provides a guideline for the user to follow and the location of the goal when it is in view. This aid is shown in Figure 7.7 (bottom left). A dark line above the grid the user is walking on leads to the goal. A path can be drawn in screen space if it is drawn on top of the next navigational aid, a mini-map.

7.1.4 Screen Space Map

Rendering a map in screen space (i.e. a minimap) allows the user to see their location as well as multiple goals. Minimaps can also give information about the environment such as walls that restrict movement. An example of the minimap in a case without walls is shown in Figure 7.7 (bottom right). The color of icons on the minimap indicates object type: black for goals and gray for the user.

7.2 User Study

To test the viability of distance based illumination assisting in navigation, we developed an application that included the aids described in the previous section as well as distance illumination. Virtual environments in the test program were defined by a 100 by 100 grid, dark cells indicating walls and light cells indicating open space. Movement

163 and viewing of the environment was done from a first person perspective. Goals were placed in the environment for the user to find. The two types of pointing devices and path lead to one goal at a time. After finding three goals using one aid, each user repeated the task with three new goals and the next aid, until they had used all five navigation aids.

The program was viewed on a seventeen inch LCD monitor in a room lit with fluorescent lamps. When using one of the four existing aids, the virtual environment was lit with a constant amount of ambient illumination. For distance illumination, cells containing the goals received 100% of a value for ambient illumination. Cells further away received a lower percent, with the furthest away receiving 0% of it. The distance field was reconstructed after each goal was found.

The study consisted of a brief training period to familiarize users with the navigational aids and controls for the test program. The test program was structured as a series of five trials. Each trial consisted of finding three goals in the environment, aided by one of the navigation aids. Multiple goals were used to determine if the limitation of guiding to one goal at a time was a significant detriment to user assistance. The maze-like environment used in each trial is shown in Figure 7.9. The same maze was used in every trial to eliminate the variable of difficulty caused by the organization of the environment itself. The maze was designed to be complex in order to keep users from learning the layout which would skew results of later trials. Since the same maze is used for each trial, we did not want to use the same goal positions every time as users may recognize this pattern and memorize a route to find all of the goals quickly without any navigation aid.

Since the position of goals was randomized, we present results as the time to complete

164 the trial and the ratio of time to distance from each goal to the starting position. Due to the difficulty of the task, users were allowed to give up on a trial. In this case, an indication of quitting a trial was recorded along with the time passed before doing so.

After the test program was completed, users filled out a questionnaire reacting to their experiences with each of the aids.

Figure 7.9: The maze used for the user study is shown.

7.2.1 User Study – Quantitative Results

We recruited seventeen volunteers of varying levels of familiarity with navigation in virtual environments. Most had little experience. Of the seventeen, seven reported no previous experience with three dimensional first person perspective computer games.

Trials where users quit are omitted from the results. Six users gave up on the screen space arrow, thirteen on the world space pointer, one on distance illumination, and none on

165 paths and minimaps. The average time to complete each trial is shown in Table 7.1 and the average time/distance ratio is shown in Table 7.2. The average time for distance illumination trials is the lowest, but on average the distance to reach the goals for this technique was slightly lower than others. Still, when factoring in distance, distance illumination was the second most efficient navigation aid. While the screen space arrow gave a solution to the problem, the information was discrete and limited to neighboring cells in the distance field, so planning ahead was difficult. The limited information and easy misinterpretation of the global pointer causes delays due to having to bypass obstacles. The ease of use for paths was countered by the time spent backtracking in cases where the first goal found was actually the furthest away. The minimap provided consistent results, but was slower than paths and distance illumination since users had to mentally construct their own routes.

screen world world distance

arrow pointer path minimap illumination

average 239.09 206.82 145.59 174.84 143.94

std.dev. 82.92 72.84 47.30 65.46 64.13

Table 7.1: User study times. The average time (in seconds) to complete each trial is shown.

166

screen world world distance

arrow pointer path minimap illumination

average 0.77 0.75 0.45 0.58 0.53

std.dev. 0.30 0.19 0.15 0.24 0.25

Table 7.2: User study time/distance ratios. The average time/distance ratio to complete each trial is shown

Since the majority of our user study consisted of novice users, we performed an additional study with a user more experienced with navigation in three dimensional virtual environments. After fifteen practice runs, the user was allowed to take the test program ten times. The results are shown in Tables 7.3 and 7.4. The average time to distance ratios are proportionally similar to that of the novices, though the ratio for the pointing cube is slightly lower in this case. Again, distance illumination is proven to be useful as a navigation aid in the challenge of exploring and searching a virtual environment.

screen world world distance

arrow pointer path minimap illumination

average 72.77 59.34 34.94 37.47 33.64

std.dev 38.46 21.53 14.07 9.49 6.28

Table 7.3: User study (expert times). The average time (in seconds) for the expert to complete each trial is shown. 167

screen world world distance

arrow pointer path minimap illumination

average 0.25 0.20 0.11 0.13 0.12

std.dev. 0.11 0.07 0.03 0.06 0.03

Table 7.4: User study (expert time/distance ratios). The average time/distance ratio for the expert to complete each trial is shown.

7.2.2 User Study – Qualitative Results

On the questionnaire, the seventeen users selected how much they liked each navigation aid on a scale from 1 to 5, representing strong dislike to strong enjoyment, with 3 as a neutral rating. They were also prompted to explain their answers. Table 7.5 shows the average rating of each of the navigation aids. Unsurprisingly, the techniques with more efficient performance are rated higher. The higher the number of quit trials for a technique, the lower the average rating was. While distance illumination was not the highest rated, it was consistently rated positively. Considering the fact that distance illumination is a new technique and does not map to a real world counterpart like paths and maps may explain the difference in its rating. Further study with broader test settings and users is required for more extensive qualitative comparison.

168

screen world world distance

arrow pointer path minimap illumination

averages 3.24 2.24 4.47 4.59 4.12

std.dev. 1.09 1.35 0.72 0.62 0.93

Table 7.5: User study survey results. The average rating, on a range of 1-5, of each navigation aid is presented.

The user comments indicated frequent confusion in how to interpret pointing devices and that the map, path, and illumination methods were easier to follow. One user’s comments were particularly insightful, “I liked the arrow because it was helpful to navigate with but it was not exactly precise. I hated the pointing cube, it was frustrating to use. The path, map, and lighting/coloring were the easiest. I like having a vision of where I was headed and I could move there more quickly”. The comment of the user who quit the trial for distance illumination also provided insight, “[after I found the second goal], it went pitch black and I couldn't find my way out. Eventually I became really frustrated with this [aid].” The mapping from distance field value to illumination is important. There is a delicate balance between illuminating the entire environment and providing enough contrast between nearby areas to be noticeable. Increasing contrast and avoiding “pitch black” areas is a topic of future work, but it is expected that this deficiency can be easily overcome by dynamic rescaling of illumination or dynamically placing local light sources.

169

The study shows that distance illumination is a viable navigation aid. Note that we are not arguing for the superiority of distance illumination over existing navigational aids, only that it is a useful method for navigation assistance. When it comes to selecting a navigation aid, ease of use and interpretation are extremely important, but the purpose of the application should be considered as well. Each navigation aid has its own set of pros and cons. One of distance illumination’s unique advantages is that it can provide navigational cues within world space by altering the scene itself rather than adding more objects to it. This is useful when immersion in the virtual world is desired. The technique provides information to make navigation easier without providing a solution as bluntly as a pointing device. The downside to distance illumination is that since it does not correspond to a navigational aid in the real world, it is dependent on giving sufficient contrast to capture the user’s visual attention strongly enough to encourage exploration of the brighter areas closer to the point of interest.

Figure 7.10: A colored example of distance illumination. The user (orange dot in the top down view on the right) is close to the source (black dot) so a linear mapping produces bright results.

170

Solving this problem in the general case is no easy task. When the user is close to the source of illumination, the environment tends toward oversaturation as in Figure 7.10.

Increasing the scale from a linear mapping from distance to intensity [0,1] to a quadratic scale makes it easier to see the color gradient (see Figure 7.11).

Figure 7.11: The scene from Figure 7.10 is shown but with a quadratic scale for illumination instead of a linear one. The difference in color intensity between near and far walls is more discernible.

This same change in scale is not desirable if the user is further away from the source. In Figure 7.12 the user is far away from the source and it is difficult to determine illumination levels. Figure 7.13 shows the same effect of changing from a linear mapping to a quadratic one. The illumination goes from dark to nearly non-existent.

171

Figure 7.12: A colored example of distance illumination. The user (orange dot in the top down view on the right) is far to the source (black dot) so a linear mapping produces dark results. The illumination is the same as in Figure 7.10.

Figure 7.13: The scene from Figure 7.12 is shown but with a quadratic scale for illumination instead of a linear one. The difference in color intensity between near and far walls is less discernible.

172

In practice we need to change how distance maps to illumination as the user’s distance to the goal varies and smoothly transition between the mappings. Optimal and alternative methods of implementing path illumination are an interesting topic for future research.

173

Chapter 8: Conclusion

In this dissertation, we propose several contributions for modeling, editing, evaluating, and illuminating 3D cave environments for games. These contributions address the growing challenge of creating larger and more detailed virtual environments, which is very time consuming and labor intensive for artists and designers. Geometry modeling topics are covered in Chapters 3 through 5 and illumination is discussed in

Chapter 6 and 7.

The first two contributions of this thesis introduce methods of creating cave models based on game level classifications. The first contribution, proposed in Chapter 3, describes parameterization of three different types of cave passages (phreatic, vadose, and combination) from Speleology, the study of caves. Using these parameters, it is easy to create a wide variety of single passage caves that are suitable for use as linear levels in games. The second contribution, proposed in Chapter 4, introduces methods to create models of cave systems with multiple passages that can be used for the other types of levels (branching maze, island maze, and open). This work leverages the wealth of existing repositories and algorithms for terrain generation and introduces methods to automatically categorize models by game level type.

The third contribution, discussed in Chapter 5, extends the techniques from

Chapter 4 by allowing multiple story cave models. The prismfield framework introduces

174 a new way of modeling 3D caves, but can also be used to model any three dimensional object. In the average case, prismfields are more efficient than voxels for rendering and computation of navigation data.

The fourth and final contribution of the thesis is distance illumination and its application in games. This is discussed in Chapter 6 and 7. The technique illuminates a scene based on distance to objects within it, such as boundaries or goal locations. We introduced methods to use distance illumination to approximate natural light in a cave as well as act as a navigational aid. Distance illumination is as effective as existing navigational aids, but does not detract from player engagement.

Broadly speaking, this dissertation covers three topics lacking in current research on computer graphics and procedural generation of content. The first is the subject area: creation of caves has not been explored in as much depth as other environments and objects like terrain and cities. The second is in spatial data analysis: to procedurally create game levels, we must categorize levels and develop methods that are able to classify 3D scenes according to our categories. The third is conceptual: the process of illuminating procedural worlds is largely ignored compared to the task of modeling and texturing them. While this dissertation introduces and discusses these three topics, there is still room in each for additional research.

175

References

[1] am Ende, B. A. 2001. 3D Mapping of Underwater Caves. IEEE Comput. Graph. Appl. 21, 2, 14-20. [2] Amanatides, J. 1984. Ray tracing with cones. In Proceedings of the 11th annual conference on Computer Graphics and interactive techniques (SIGGRAPH '84), Christiansen, H. (Ed.). ACM, New York, NY, 129-135. [3] Aponte, M.-V., Levieux, G., and Natkin, S. 2009. Scaling the Level of Difficulty in Single Player Video Games. In Proceedings of the 8th International Conference on Entertainment Computing (ICEC '09), Natkin, S. and Dupire, J. (Eds.). Springer- Verlag, Berlin, Heidelberg, 24-35. [4] Azernikov, S. 2008. Sweeping solids on manifolds. In Proceedings of the 2008 ACM symposium on Solid and physical modeling (SPM '08). ACM, New York 249-255. [5] Bailey, R., McNamara, A., Sudarsanam, N., and Grimm, C. 2009. Subtle gaze direction. ACM Trans. Graph. 28, 4, 1-14. [6] Bakambu, J. N. and Polotski, V. 2007. Autonomous system for navigation and surveying in underground mines: Field Reports. J. Field Robot. 24, 10, 829-847. [7] Benes, B. and Forsbach, R. 2001. Layered Data Representation for Visual Simulation of Terrain Erosion. In Proceedings of the 17th Spring conference on Computer graphics, 80-86. [8] Betts, O. and Wookey. 2010. The Survex Project, http://survex.com/ [9] Blinn, J. F. 1977. Models of light reflection for computer synthesized pictures. SIGGRAPH Comput. Graph. 11, 2, 192-198. [10] Bostan, B. 2009. Requirements analysis of presence: Insights from a RPG game. Comput. Entertain. 7, 1, 1-17. [11] Bundysoft. 2012. L3DT - Large 3D Terrain Generator, http://www.bundysoft.com/L3DT/ [12] Burigat, S. and Chittaro, L. 2007. Navigation in 3D virtual environments: Effects of user experience and location-pointing navigation aids. Int. J. Hum.-Comput. Stud. 65, 11, 945-958. [13] Byrne, E. 2005. Game Level Design. (Charles River Media). [14] Cardamone, L., Yannakakis, G. N., Togelius, J., and Lanzi, P. L. 2011. Evolving interesting maps for a first person shooter. In Proceedings of the 2011 international conference on Applications of evolutionary computation - Volume Part I (EvoApplications'11), Chio, C. D., Cagnoni, S., Cotta, C., Ebner, M., and Ekárt A. (Eds.), Vol. Part I. Springer-Verlag, Berlin, Heidelberg, 63-72. [15] CD Projekt RED. 2007. The Witcher. (Atari, Inc.). [16] Cliburn, D., Winlock, T., Rilea, S., and Van Donsel, M. 2007. Dynamic landmark placement as a navigation aid in virtual worlds. In Proceedings of the 2007 ACM symposium on Virtual reality software and technology (VRST '07), Spencer, Stephen N. (Ed.). ACM, New York, NY, 211-214.

176

[17] Cook, R. L. and Torrance, K. E. 1982. A Reflectance Model for Computer Graphics. ACM Trans. Graph. 1, 1, 7-24. [18] Crawford, C. 1984. The Art Of Computer Game Design: Reflections Of A Master Game Designer. (Osborne/McGraw-Hill). [19] Dachsbacher, C. and Kautz, J. 2009. Real-time global illumination for dynamic scenes. In ACM SIGGRAPH 2009 Courses (SIGGRAPH '09). ACM, New York, NY, Article 19, 217 pages. [20] Dachsbacher, C., Stamminger, M., Drettakis, G., and Durand, F. 2007. Implicit visibility and antiradiance for interactive global illumination. ACM Trans. Graph. 26, 3, Article 61. [21] Darken, R. P., Bernatovich, D., Lawson J.P., and Peterson, B. 1999. Quantitative measures of presence in virtual environments: the roles of attention and spatial comprehension. Cyberpsychol Behav. 2, 4, 337-347. [22] Darken, R. P. and Sibert, J. L. 1996. Navigating large virtual spaces. Int. J. Hum.- Comput. Interact. 8, 1, 49-71. [23] De Jong, S. 2006. Tutorials – Cave Modeling. http://www.hourences.com/tutorials- cave-modeling/ [24] Deussen, O., Hanrahan, P., Lintermann, B., Mech, R., Pharr, M. and Prusinkiewicz, P. 1998. Realistic modeling and rendering of plant ecosystems. In Proceedings of the 25th annual conference on Computer graphics and interactive techniques (SIGGRAPH '98). ACM, New York, NY, 275-286. [25] Dorsey, J., Edelman, A., Jensen, H. W., Legakis, J., and Pedersen, H. K. 1999. Modeling and rendering of weathered stone. In Proceedings of the 26th annual conference on Computer graphics and interactive techniques (SIGGRAPH '99). ACM Press/Addison-Wesley Publishing Co., New York, NY, 225-234. [26] Ebert, D. S., Musgrave, K. F., Peachey, D., Perlin, K. and Worley, S. 2002. Texturing & Modeling: A Procedural Approach, Third Edition (Morgan Kaufmann). [27] Edkins, J. 2008. History of Mazes and Labyrinths, http://gwydir.demon.co.uk/jo/maze/index.htm [28] El-Nasr, M. S., Vasilakos, T., Rao, C., and Zupko, J. 2009. Dynamic Intelligent Lighting for Directing Visual Attention in Interactive 3D Scenes. IEEE Trans. Comput. Intell. AI in Games. 1, 2, 145-153. [29] Epic Games Forums. 2008. Modeling a cave for a level, http://forums.epicgames.com/showthread.php?t=629467 [30] Evans, A. 2006. Fast approximations for global illumination on dynamic scenes. In ACM SIGGRAPH 2006 Courses, ACM, New York, NY, 153-171. [31] Filipponi, M. and Jeannin, P.-Y. 2008. What makes a bedding plane favourable to karstification? - The role of the primary rock permeability. In Proceedings of the 4th European Speleological Congress, Vercors, France, 32-37. [32] Fish, L. 2010. Compass, http://fountainware.com/compass/ [33] Frade, M., Fernandez de Vega, F., and Cotta, C. 2010. Evolution of artificial terrains for video games based on accessibility. In Proceedings of the 2010 international conference on Applications of Evolutionary Computation - Volume Part I

177

(EvoApplicatons'10), Chio, C., Cagnoni, S., Cotta, C., Ebner, M., and Ekárt, A. (Eds.), Vol. Part I. Springer-Verlag, Berlin, Heidelberg, 90-99. [34] Gain, J., Marais, P., and Straßer, W. 2009. Terrain sketching. In Proceedings of the 2009 symposium on Interactive 3D graphics and games (I3D '09). ACM, New York, NY, 31-38. [35] Galuzin, A. 2011. 11 Day Level Design, http://www.worldofleveldesign.com/store/udk-11-day-level-design.php [36] Geiss, R. 2007. Generating complex procedural terrains using the gpu, GPU Gems 3. (Addison-Wesley Professional). 7-37. [37] Gregory, J. 2009. Game Engine Architecture, Lander, J. and Whiting, M. (Eds.). (A K Peters). [38] Gong, J., Lin, H., and Yin, X. 2000. Three-dimensional Reconstruction of the Yaolindong. Cartography and Geographic Information Science, 27, 1, 31-40. [39] Goral, C. M., Torrance, K. E., Greenberg, D. P., and Battaile, B. 1984. Modeling the interaction of light between diffuse surfaces. In Proceedings of the 11th annual conference on Computer graphics and interactive techniques (SIGGRAPH '84), Christiansen, H. (Ed.). ACM, New York, NY, 213-222. [40] Hachisuka, T., Ogaki, S., and Jensen, H. W. 2008. Progressive photon mapping. ACM Trans. Graph. 27, 5, 1-8. [41] Hale, D. H., Youngblood, G. M., and Dixit. P. 2008. Automatically-generated Convex Region Decomposition for Real-time Spatial Agent Navigation in Virtual Worlds. In Proceedings of the 4th AAAI Artificial Intelligence and Interactive Digital Entertainment Conference, 173–178. [42] Hanrahan, P., Salzman, D., and Aupperle, L. 1991. A rapid hierarchical radiosity algorithm In Proceedings of the 18th annual conference on Computer graphics and interactive techniques (SIGGRAPH '91). ACM, New York, NY, 197-206. [43] Heckbert, P. S. and Hanrahan, P. 1984. Beam tracing polygonal objects. In Proceedings of the 11th annual conference on Computer graphics and interactive techniques (SIGGRAPH '84), Christiansen, H. (Ed.). ACM, New York, NY, 119-127. [44] Hertel, S. and Mehlhorn, K. 1983. Fast Triangulation of Simple Polygons, In Proceedings of the 1983 International FCT-Conference on Fundamentals of Computation Theory, 207-218. [45] Herzog, R., Havran, V., Kinuwaki, S., Myszkowski, K., and Seidel, H.-P. 2007. Global illumination using photon ray splatting. Computer Graphics Forum 26, 3, 503-513. [46] Hoang, T.-D. and Low, K.-L. 2010. Multi-resolution screen-space ambient occlusion. In Proceedings of the 17th ACM Symposium on Virtual Reality Software and Technology (VRST '10). ACM, New York, NY, 101-102. [47] Hunicke, R. 2005. The case for dynamic difficulty adjustment in games. In Proceedings of the 2005 ACM SIGCHI International Conference on Advances in computer entertainment technology (ACE '05). ACM, New York, NY, 429-433. [48] Ion Storm, Inc. 2004. Thief: Deadly Shadows. (Eidos Interactive). [49] Iones, A. Krupkin, A., Sbert, M., and Zhukov, S. 2003. Fast, Realistic Lighting for Video Games. IEEE Comput. Graph. Appl. 23, 3, 54-64. 178

[50] Iwasaki, K., Dobashi, Y., Yoshimoto, F., and Nishita, T. 2007. Precomputed radiance transfer for dynamic scenes taking into account light interreflection. In Proceedings of the Eurographics Symposium on Rendering, 35-44. [51] Jensen, H. W. 1996. Global illumination using photon maps. In Proceedings of the Eurographics Workshop on Rendering Techniques (Porto, Portugal), Pueyo, X. and Schröder, P. (Eds.) Springer-Verlag, London, 21-30. [52] Jones, M. D., Farley, M., Butler, J., and Beardall, M. 2010. Directable Weathering of Concave Rock Using Curvature Estimation. IEEE Transactions on Visualization and Computer Graphics 16, 1, 81-94. [53] Jones, M. W., Baerentzen, J. A., and Sramek, M. 2006. 3D Distance Fields: A Survey of Techniques and Applications. IEEE Transactions on Visualization and Computer Graphics 12, 4, 581-599. [54] Johnson, L., Yannakakis, G. N., and Togelius, J. 2010. Cellular automata for real- time generation of infinite cave levels. In Proceedings of the 2010 Workshop on Procedural Content Generation in Games (PCGames '10). ACM, New York, NY, Article 10, 4 pages. [55] Kajiya, J. T. 1986. The rendering equation. In Proceedings of the 13th annual conference on Computer graphics and interactive techniques (SIGGRAPH '86), Evans, D. C. and Athay, R. J. (Eds.) ACM, New York, NY, 143-150. [56] Keller, A. 1997. Instant radiosity. In Proceedings of the 24th annual conference on Computer graphics and interactive techniques (SIGGRAPH '97). ACM Press/Addison-Wesley Publishing Co., New York, NY, 49-56. [57] Kontkanen, J. and Laine, S. 2005. Ambient occlusion fields. In Proceedings of the 2005 Symposium on interactive 3D Graphics and Games (I3D '05). ACM, New York, NY, 41-48. [58] Lafortune, E. P., and Willems, Y. D. 1993. Bi-directional path tracing. In CompuGraphics Proceedings, 145-153. [59] Lam, H. 2007. Overview Use in Multiple Visual Information Resolution Interfaces. IEEE Transactions on Visualization and Computer Graphics 13, 6, 1278-1285. [60] Lorensen, W. E. and Cline, H. E. 1987. Marching cubes: A high resolution 3D surface construction algorithm. SIGGRAPH Comput. Graph. 21, 4, 163-169. [61] Malone, T. W. 1980. What makes things fun to learn? heuristics for designing instructional computer games. In Proceedings of the 3rd ACM SIGSMALL symposium and the first SIGPC symposium on Small systems (SIGSMALL '80). ACM, New York, NY, 162-169. [62] Malone, T.W. 1981. What makes computer games fun? Byte, 6, 258-277. [63] May, A. J., Ross, T., Bayer, S. H., and Tarkiainen, M. J. 2003. Pedestrian navigation aids: information requirements and design implications. Personal Ubiquitous Comput. 7, 6, 331-338. [64] McCann, A. 2006. Groundwater Movement and Protection, http://www.uri.edu/ce/wq/has/Private%20Wells/GROUNDWATER.htm [65] McNamara, A., Bailey, R., and Grimm, C. 2009. Search task performance using subtle gaze direction with the presence of distractions. ACM Trans. Appl. Percept. 6, 3, 1-19. 179

[66] Meloni, W. 2009. M2 Research, http://www.m2research.com/the-brief-2009-ups-and- downs.htm [67] Milam, D. and El-Nasr, M. S. 2010. Analysis of level design 'push & pull' within 21 games. In Proceedings of the Fifth International Conference on the Foundations of Digital Games (FDG '10). ACM, New York, NY, 139-146. [68] Milam, D. and El-Nasr, M. S. 2010. Design patterns to guide player movement in 3D games. In Proceedings of the 5th ACM SIGGRAPH Symposium on Video Games (Sandbox '10), Spencer, S. N. (Ed.). ACM, New York, NY, 37-42. [69] Miller, G. S. 1986. The definition and rendering of terrain maps. SIGGRAPH Comput. Graph. 20, 4, 39-48. [70] Minocha, S. and Hardy, C. L. 2011. Designing navigation and wayfinding in 3D virtual learning spaces. In Proceedings of the 23rd Australian Computer-Human Interaction Conference (OzCHI '11). ACM, New York, NY, USA, 211-220. [71] Mudrák, S. and Budaj, M. 2010. Therion, http://therion.speleo.sk/ [72] Müller, P., Wonka, P., Haegler, S., Ulmer, A., and Van Gool, L. 2006. Procedural modeling of buildings. ACM Trans. Graph. 25, 3, 614-623. [73] Musgrave, F. K., Kolb, C. E., and Mace, R. S. 1989. The synthesis and rendering of eroded fractal terrains. In Proceedings of the 16th annual conference on Computer graphics and interactive techniques (SIGGRAPH '89). ACM, New York, NY, 41–50. [74] National Geospatial-Intelligence Agency. 2010. NGA Raster Roam, http://geoengine.nima.mil/ [75] Nitsche, M. 2009. Video Game Spaces: Image, Play, and Structure in 3D Worlds. (MIT Press). [76] Notch. 2011. Minecraft. http://www.minecraft.net/ [77] Pajarola, R. and Gobbetti, E. 2007. Survey of semi-regular multiresolution models for interactive terrain rendering. Vis. Comput. 23, 8, 583-605. [78] Palmer, A. N. 1991. Origin and morphology of limestone caves. Geological Society of America Bulletin 103, 1, 1-21. [79] Palmer, A. N. 2007. Cave Geology. (Cave Books). [80] Parish, Y. I. and Müller, P. 2001. Procedural modeling of cities, In Proceedings of the 28th annual conference on Computer graphics and interactive techniques (SIGGRAPH '01). ACM, New York, NY, 301-308. [81] Pausch, R., Proffitt, D., and Williams, G. 1997. Quantifying immersion in virtual reality. In Proceedings of the 24th annual conference on Computer graphics and interactive techniques (SIGGRAPH '97). ACM Press/Addison-Wesley Publishing Co., New York, NY, 13-18. [82] Perlin, K. 1985. An image synthesizer. SIGGRAPH Comput. Graph. 19, 3, 287-296. [83] Peytavie, A., Galin, E., Grosjean, J., and Merillou, S. 2009. Arches: a Framework for Modeling Complex Terrains. Computer Graphics Forum 28, 2, 457-467. [84] Phong, B. T. 1975. Illumination for computer generated pictures. Commun. ACM 18, 6, 311-317. [85] Price, J. 2010. Final Fantasy XIII: Complete Official Guide. (Random House Inc). [86] Prusinkiewicz, P. and Lindenmayer, A. 1990. The Algorithmic Beauty of Plants (Springer-Verlag). 180

[87] Pullen, W. D. 2011. Think Labyrinth: Maze Algorithms. http://www.astrolog.org/labyrnth/algrithm.htm [88] Ramirez, L., Denef, S., and Dyrks, T. 2009. Towards human-centered support for indoor navigation. In Proceedings of the 27th international conference on Human factors in computing systems (CHI '09). ACM, New York, NY, 1279-1282. [89] Resurgent Software. 2010. WinKarst, http://www.resurgentsoftware.com/winkarst.html [90] Ritschel, T., Grosch, T., and Seidel, H. 2009. Approximating dynamic global illumination in image space. In Proceedings of the 2009 symposium on Interactive 3D graphics and games (I3D '09). ACM, New York, NY, 75-82. [91] Robson Brown, K. A., Chalmers, A., Saigol, T., Green, C., and d'Errico, F. 2001. An automated laser scan survey of the Upper Palaeolithic rock shelter of Cap Blanc. Journal of Archaeological Science 28, 3, 283-289. [92] Ruddle, R. A. and Lessels, S. 2006. Three levels of metric for evaluating wayfinding. Presence: Teleoper. Virtual Environ. 15, 6, 637-654. [93] Rushmeier, H. E. and Torrance, K. E. 1987. The zonal method for calculating light intensities in the presence of a participating medium. In Proceedings of the 14th annual conference on Computer graphics and interactive techniques (SIGGRAPH '87), Stone, M. C. (Ed.). ACM, New York, NY, 293-302. [94] Salomon, B., Garber, M., Lin, M. C., and Manocha, D. 2003. Interactive navigation in complex environments using path planning. In Proceedings of the 2003 symposium on Interactive 3D graphics (I3D '03). ACM, New York, NY, 41-50. [95] Schuchardt, P. and Bowman, D. A. 2007. The benefits of immersion for spatial understanding of complex underground cave systems. In Proceedings of the 2007 ACM symposium on Virtual reality software and technology (VRST '07), Spencer, S. N. (Ed.). ACM, New York, NY, 121-124. [96] Schwenk, K. 2008. A Survey of Shading Models for Real-time Rendering, http://www.devmaster.net/articles/survey-of-shading-models/ [97] Sellers, W. I., and Chamberlain, A. T. 1998. Ultrasonic cave mapping. Journal of Archaeological Science 25, 9, 867-873. [98] Shankel, J. 2000. Fractal Terrain Generation - Fault Formation, Game Programming Gems 1, DeLoura, M. (Ed.). (Charles River Media). 499-502. [99] Shankel, J. 2000. Fractal Terrain Generation - Particle Deposition, Game Programming Gems 1, DeLoura, M. (Ed.). (Charles River Media). 508-511. [100] Shanmugam, P. and Arikan, O. 2007. Hardware accelerated ambient occlusion techniques on GPUs. In Proceedings of the 2007 symposium on Interactive 3D graphics and games (I3D '07). ACM, New York, NY, 73-80. [101] Simon, A. and Stern, C. 2007. Active guideline: spatiotemporal history as a motion technique and navigation aid for virtual environments. In Proceedings of the 2007 ACM symposium on Virtual reality software and technology (VRST '07), Spencer, S. N. (Ed.). ACM, New York, NY, 199-202. [102] Sloan, P.-P., Kautz, J., and Snyder, J. 2002. Precomputed radiance transfer for real- time rendering in dynamic, low-frequency lighting environments. ACM Trans. Graph. 21, 3, 527–536. 181

[103] Smelik, R. M., De Kraker, K. J., Tutenel, T., Bidarra, R., & Groenewegen, S. A. 2009. A Survey of Procedural Methods for Terrain Modelling, In Proceedings of the CASA Workshop on 3D Advanced Media In Gaming And Simulation 3AMIGAS. [104] Snook, G. 2000. Simplified 3D Movement and Pathfinding using Navigation Meshes, Game Programming Gems 1, DeLoura, M. (Ed.) (Charles River Media). [105] Sorenson, N. and Pasquier, P. 2010. Towards a generic framework for automated video game level creation. In Proceedings of the 2010 international conference on Applications of Evolutionary Computation - Volume Part I (EvoApplicatons'10), Chio, C., Cagnoni, S., Cotta, C., Ebner, M., and Ekárt, A. (Eds.), Vol. Part I. Springer-Verlag, Berlin, Heidelberg, 131-140. [106] Sourin, A. and Pasko. A. 1995. Function representation for sweeping by a moving solid. In Proceedings of the third ACM symposium on Solid modeling and applications (SMA '95), Chris Hoffmann and Jarek Rossignac (Eds.). ACM, New York, 383-391. [107] Stava, O., Krivanek, J., Benes, B., and Brisbin, M. 2008. Interactive Terrain Modeling Using Hydraulic Erosion. In Proceedings of the 2008 ACM SIGGRAPH/Eurographics Symposium on Computer Animation (SCA '08). Eurographics Association, Aire-la-Ville, Switzerland, Switzerland 201- 210. [108] Sweetser, P. and Wyeth, P. 2005. GameFlow: a model for evaluating player enjoyment in games. Comput. Entertain. 3, 3, 3-3. [109] Sun, X., Zhou, K., Chen, Y., Lin, S., Shi, J., and Guo, B. 2007. Interactive relighting with dynamic BRDFs. ACM Trans. Graph. 26, 3, Article 27. [110] Tan, X., Bian, F., and Li, J. 2002. Research on object-oriented three dimensional data model. In Symposium on Geospatial Theory, Processing and Applications. Volume XXXIV, Part 4. [111] Tan, D. S., Robertson, G. G., and Czerwinski, M. 2001. Exploring 3D navigation: combining speed-coupled flying with orbiting. In Proceedings of the SIGCHI conference on Human factors in computing systems (CHI '01). ACM, New York, NY, 418-425. [112] Texas Speleological Survey. 2008. Stuart Bat Cave Tours, http://www.utexas.edu/tmm/sponsored_sites/tss/wildcavetours/tssstuartbatcave.htm [113] The University of Auckland. 2010. World Karst Map, http://www.sges.auckland.ac.nz/research/karst.shtml [114] Theeuwes, J. 1995. Abrupt luminance change pops out; abrupt color change does not. Journal of Attention, Perception, & Psychophysics, 57, 5, 637-644. [115] Tozour. P. 2004. AI Game Programming Wisdom 2, Chapter 2.1 Search Space Representations. (Charles River Media). 85-102. [116] U.S. Geological Survey. 2011. USGS Seamless Data Warehouse, http://seamless.usgs.gov/ [117] U.S. National Park Service. 2010. Mammoth Cave National Park, http://www.nps.gov/maca/faqs.htm [118] Veach, E., and Guibas, L. 1994. Bidirectional estimators for light transport. In Proceedings of the Fifth Eurographics Workshop on Rendering, Darmstadt, Germany, 147-162. 182

[119] Veach, E. and Guibas, L. J. 1997. Metropolis light transport. In Proceedings of the 24th annual conference on Computer graphics and interactive techniques (SIGGRAPH '97). ACM Press/Addison-Wesley Publishing Co., New York, NY, 65- 76. [120] Vinson, N. G. 1999. Design guidelines for landmarks to support navigation in virtual environments. In Proceedings of the SIGCHI conference on Human factors in computing systems: the CHI is the limit (CHI '99). ACM, New York, NY, 278-285. [121] Wolfe, J. M. and Horowitz, T. S. 2004. What attributes guide the deployment of visual attention and how do they do it? Nature Reviews Neuroscience 5, 6, 1-7. [122] Whiting, E., Ochsendorf, J., and Durand, F. 2009. Procedural modeling of structurally-sound masonry buildings. In ACM SIGGRAPH Asia 2009 papers (SIGGRAPH Asia '09). ACM, New York, NY, Article 112. [123] Whitted, T. 1980. An improved illumination model for shaded display. Commun. ACM 23, 6, 343-349. [124] Zhou, H., Sun, J., Turk, G., and Rehg, J.M. 2007. Terrain Synthesis from Digital Elevation Models. IEEE Transactions on Visualization and Computer Graphics 13, 4, 834-848. [125] Zhukov, S., Iones, A., and Kronin, G. 1998. An ambient light illumination model. In Eurographics Rendering Workshop, 45-56.

183