Real-Time Massive Terrain Generation Using Procedural Erosion on the GPU
Total Page:16
File Type:pdf, Size:1020Kb
SBC { Proceedings of SBGames 2018 | ISSN: 2179-2259 Computing Track { Short Papers Real-Time Massive Terrain Generation using Procedural Erosion on the GPU Gabriel Costa Backes, Tiago Augusto Engel, Cesar Tadeu Pozzer PPGCC - Programa de Pos-Graduac¸´ ao˜ em Cienciaˆ da Computac¸ao˜ UFSM - Universidade Federal de Santa Maria Santa Maria, Brazil gbackes, tengel, pozzer @inf.ufsm.br { } Abstract—Although terrain modeling is a widely explored on a fractional Brownian motion (fBm) that uses a con- field, problems such as scalability remain present when it comes tinuous procedural Perlin function to define the elevation to massive terrain sizes. While procedural methods have disad- data [1]. Moreover, we provide different kinds of primitives vantages regarding controllability and visual fidelity, it provides a great effectiveness handling with extremely large terrains to work around the terrain natural properties, providing the due its computational performance. Our approach consists of global control over the features. generating the elevation data using a procedural function in The coarse features are defined by the base parameters, real-time. We provide an intuitive set of parameters that allow such as the terrain height scale, the highlight on mountains control of several landscape characteristic. Real-world natural and valleys, and the terrain roughness and details on its com- aspects were taken into account on the generation process. The terrain is represented by a dynamic quadtree structure and position. While these parameters can generate interesting the elevation data is stored in a virtual texture. To address terrains, its intrinsic features are far from real. In the real real-time performance, we adopt a GPU-based approach for world, the terrain has many complex features of different the heightmap generation. Furthermore, a GPU instancing sizes on its composition. Pinter and Brandon [2] shown approach was used for rendering. that natural agents modify these features, causing irregularly Keywords-massive terrains, procedural generation, perlin distribution. While higher elevations are characterized by an noise, erosive noise, fractional brownian motion, real time irregular surfaces due to, among other factors, its average rendering. temperature and scrub vegetation, lower elevations tend to be more flat, once they concentrate more sedimentation. To I. INTRODUCTION replicate these properties, we propose a procedural erosion Procedural terrain generation is a widely explored field set, which controls the amount details over the terrain due to its significance in the entertainment industry, more altitude, steepness and curvature. specifically in movies and video games. It is imperative for Unlike physics-based approach, the procedural erosion such applications to generate visually appealing and detail allows us to generate credible terrains at real-time frame rich landscapes. While physically plausible landscapes can rates. An infinity of complex terrains can be easily defined be generated by hydraulic and wind erosion, and tectonic through the intuitive input set. Our model is computationally uplifting simulations, such approaches are not feasible for efficient and provides a flexible control over the terrain generating elevation data in real-time and often lack on con- features. As result, it is suitable for editing and rendering trollability. On the other hand, the terrain can be manually massive terrains. sketched or entirely loaded by an input data. However, these approaches are not scalable for extremely large terrains, II. RELATED WORKS which may extent several kilometers at the resolution of Procedural algorithms have been used in the terrain gener- centimeters. ation field for more than three decades. Usually, the terrain is Example-based approaches use real world datasets, so its discretized by a regular grid, which stores the elevation data resolution and size are limited by the input. Physically- in a texture, called as heightmap. Early methods were based based approaches demand lengthy preprocessing times and on iterative subdivision of the grid. Fournier [3] presented are accurate, being a suitable approach for movies and games a method that became known as midpoint displacement. with limited scenarios. Differently, open-world games often Level of details are generated by displacing a new vertex allow the user to interact with massive worlds. Fractal-based by the parents average height of a coarse level combined procedural approaches are efficient but lack realism and by a random value. Noise based approaches, such as Perlin controllability. We therefore provide a process for generating noise [4], were shown as promising due its computational visually appealing terrains using fractals without compro- costs. The details are created by summing several noise mising performance. octaves on differentes frequencies and scaled amplitudes [1]. In this paper we introduce an novel approach to address Despite these methods produce many particular features, its massively terrain generation in real-time. Our work is based distribution are regular over the surface. XVII SBGames { Foz do Igua¸cu{ PR { Brazil, October 29th { November 1st, 2018 675 SBC { Proceedings of SBGames 2018 | ISSN: 2179-2259 Computing Track { Short Papers Physics-based approaches were incorporated to introduce The elevation data of each tile is stored on a virtual texture. natural aspects over the terrain features. Musgrave addresses A view frustum culling is performed on CPU to select geomorphic agents by two erosion algorithms to simulate hy- the quadtree nodes to be rendered. However, since the draulic erosion and thermal weathering [5]. Nevertheless, its Perlin noise is locally independent, i.e., the heights can be computational cost hinder the use on large terrains with high evaluated in parallel, a GPU-based approach was adopted to level of details. Vanek [6] introduced a GPU-based approach, perform the heightmap generation. Furthermore, we used a in which large terrains are divided into tiles of different GPU-instancing approach to render the terrain. In this step, resolutions, the physics-based simulation use different level the vertexes of a grid mesh are displaced by the elevation of details to speedup the computation. Unfortunately, due data on the vertex shader. to the heights evaluation are locally dependent, GPU-based approaches can not deplete parallel programing potential and IV. PROCEDURAL TERRAIN GENERATION the scalability remains a problem. The terrain base is provided by the fBm method based on Sketched-based methods address the low controllability 2D Perlin noise, denoted by F . Since perlin noise evaluates of the procedural generation. Rusnell [7] describes a ter- the noise value individually, the heights for a given patch rain synthesis method based on distances in a weighted can be computed in parallel. graph created from user-specified generator nodes. Gain [8] The naive fBm algorithm calculates a weighted sum introduces a height map generation using silhouette and of scaled noises from several octaves. The amplitude and bounds of mountains user sketched. Hnaidi [9] proposed a frequency of the noise are modified, respectively, by a gain method based on diffusion of constraints, in which the user and lacunarity on each octave, thus, originating features of control the landforms by feature curves. Recently, Gnevaux manifold size. The equation is defined as follows: [10] presents a hierarchical procedural model that combines n 1 feature-based primitives to create complex terrains. It has − been extended by Gurin [11], in which proposed a proce- F (p) = ξiN(λip) (1) i=0 dural modeling that can automatically generate large scale X terrain rather than authoring the terrain interactively by hand. where n represents the number of octaves and i the current octave, ξ [0, 1] represents the amplitude. N(p) is the perlin ∈ III. OVERVIEW noise function, in which given a position p returns a scalar An overview of the proposed terrain generation is shown s [ 1, 1]. λ represents the frequency. ∈ − in the Fig. 1. The terrain base is defined by the 2D Perlin Although the fBm can create really interesting terrains,the noise, in which, along with a fBm, introduce details to the noise distribution is uniform. Thus, there is no variations on terrain. The visual appealing relies on an intuitive parameters the terrain features. To address this natural lack aspect, we set, which provides the user a global controllability. The presented bellow some intuitive parameters to be introduced inputs manage the terrain scale, roughness and geometric on the fBm, modifying the geometric characteristics. characteristics. Moreover, an additional manageable erosion set improves the terrain natural aspect, damping the details A. Terrain roughness, sharpness and scale on particular regions, as specific altitudes, slopes or concav- The terrain roughness is directly controlled by the ampli- ities. The proposed approach is inspired by Carpentier [12], tude ξ and the frequency λ. The amplitude in each octave which present a brush editing using several noises primitives. ξi is given by the multiplication of an initial value Ia with a Our approach relies on discretizing the terrain into multi gain g [0, 1] (Equation 2a). In the same way, the frequency ∈ resolution tiles using a dynamic quadtree structure. In this λi is given by the multiplication of an initial value If with way, once we adopted an continuous procedural function, a lacunarity l (Equation 2b). Lower values to g will make