20
Procedural terrain on the GPU Chalmers University of Technology Advanced computer graphics – DAT205 David Sundelius Adam Scott

Procedural terrain on the GPU

Embed Size (px)

DESCRIPTION

Chalmers University of Technology Advanced computer graphics – DAT205. Procedural terrain on the GPU. David Sundelius Adam Scott. Introduction. Generating terrain is a task fitted well for parallelization and thus for the GPU - PowerPoint PPT Presentation

Citation preview

Page 1: Procedural  terrain  on the GPU

Procedural terrain on the GPU

Chalmers University of TechnologyAdvanced computer graphics – DAT205

David SundeliusAdam Scott

Page 2: Procedural  terrain  on the GPU

Introduction

• Generating terrain is a task fitted well for parallelization and thus for the GPU

• A technique to generate terrain, with textures and lighting during runtime.

• Divides the world into cubic blocks containing voxels

Page 3: Procedural  terrain  on the GPU

Agenda

• Overview• Density function and noise generation• Marching cubes algorithm• Texturing, shading and lighting• Demo• Questions

Page 4: Procedural  terrain  on the GPU

Terrain generation overview

• Divide environment in blocks of voxels• Parallelize block calculation by using pixelshaders• Use a density function to create the basic environment• Apply noise to the generated density function• Use the marching cubes algorithm to generate geometry• Add textures and texture coordinates• Render scene

Page 5: Procedural  terrain  on the GPU

Density function

• Function used to create the basic environment

• A three dimensional function

• Positive and negative values

• float density = -1;• float density = -ws.y;• float density = rad – length(ws- float3(0,rad,0));

Page 6: Procedural  terrain  on the GPU

Noise generation

• Generate some noise 3d texture repeating• Modify the density function with random sampling from our

noise texture• Use interpolation to warp the area• Able to create a hard floor or flat areas, just clamp the density

function• Possibility to use hand made textures• Generate cave structure

Page 7: Procedural  terrain  on the GPU

Marching cubes - Blocks

• March through voxels in blocks

• For each voxel we create an array with information of corners from the density function

Page 8: Procedural  terrain  on the GPU

Marching cubes – Lookup tables

• Lookup constructed array

• Pregenereted lookuptables

Page 9: Procedural  terrain  on the GPU

Marching cubes - geometry

• Geometry shader

• Calculate position of vertex

• Calculate normal

• Three different methods to generate blocks

Page 10: Procedural  terrain  on the GPU

Block generation method 1

• 1. Fill volume

• 2. Generate vertices

• The slowest method

Page 11: Procedural  terrain  on the GPU

Block generation method 2

• 1. Fill density volume

• 2. Lightweight marker point

• 3. Generate vertices

Page 12: Procedural  terrain  on the GPU

Block generation method 3

• 1. Fill volume

• 2. List non-empty cells

• 3. List vertices to generate

• 4. Generate vertices

• 5. Splat vertices

• 6. Make triangles

Page 13: Procedural  terrain  on the GPU

Lighting and ambient occlusion

• Easy to implement

• Calculating normals

• Ray casting

• Long/short rays

Page 14: Procedural  terrain  on the GPU

Premade textures

• Pros and cons

• Loading textures (such as photographs)

• Triplanar texturing – project on axis with least distorted normal

Page 15: Procedural  terrain  on the GPU

Generating textures

• Generating textures

• Marble textures

Page 16: Procedural  terrain  on the GPU

Pros and cons

• Requires a lot of memory on the GPU• Can compromize valitity of data (not exact), ambiguity in model • Can have holes

• Fast way to generate procedural environments• Easy and fast to manipulate environment• High resolution (easy to extend use to LoD)

Page 17: Procedural  terrain  on the GPU

Applications

• Level of detail• Collisions• Lighting

• Other use: create 3d models from sampling i.e. MRI

Page 18: Procedural  terrain  on the GPU

Demonstration

• Video

Page 20: Procedural  terrain  on the GPU

Questions

?