Title: 3D Terrain Generation
13D Terrain Generation
- Pablo Saldarriaga
- CSE4431
2Why virtual terrains?
- There are many applications for 3d terrains
- Just to name a few
- Virtual tourism and travel planning
- Education
- Civil engineering, urban planning
- Weather visualizations
- Real Estate
- Games
- Movies
- Placement of communication signal towers
3Background
- The defense industry created virtual terrains as
early as the 1970s - Their purpose were ballistics and training
simulations - TINs (Triangulated Irregular Networks) appeared
in 1973, developed by Randolph Franklin at Simon
Fraser University - TIN vector based representation of the physical
land surface or sea bottom - In the 1980s procedural techniques are developed
and they are used to generate artificial terrains - This was the time Perlin created his noise
functions - It was only until the late 1980s that fractals
and polygonal subdivision techniques started to
become more widespread in artificial terrain
generation
4Military simulation software SIMDIS
Triangulated Irregular Network(TIN)
Emil Multifractal terrain by Kenton Musgrave
5- A virtual terrain generated using Terragen 2 from
- Planetside software
Image created by Hannes Janetzko.
6How are virtual terrains generated?
- Heightfields
- Widespread approach for generating virtual
terrain - games and simulators use heightfields as a rough
terrain model - This lecture will be focused in this approach
- Voxels
- Volume based values in a 3D grid
- Meshes
- TINs, tesselation schemes such as ROAM (Realtime
optimally adapting mesh) and other LOD(Level of
Detail) techniques
7ROAM
Voxel Terrain
8Topics
- Glsl vertex displacement using height maps
- Fractal Terrain generation
- Midpoint displacement Alg.
- Diamond Square Alg.
- Fault Line Alg.
- Particle deposition
9- In Glsl, terrain can be generated relatively easy
if - a heightmap texture is available to the vertex
shader - the surface that is going to be displaced is
tesselated fine enough to show the heightmap
details - If this is the case then add the following to the
vertex shader - //make sure your height value is in the desired
range (for example from 0 to 1) - float h texture(heightmap, st).r Scale Bias
- //ensures that the displacement happens in the
direction of the normal of the current vertex - vec3 newPos currentPos currentNormal h
- gl_Position uModelViewProjectionMatrix
vec4(newPos,1.)
10 11Fractal Terrains
- first approach would be to generate a heightmap
using fBm noise - results look ok but not very realistic
- since fBm is homogeneous and isotropic
12- A better choice would be to use Multifractals
- These are fractals whose dimension/roughness
varies with location - So how do you generate a Multifractal?
Multifractal terrain by Kenton Musgrave. Texturing
and Modeling a Procedural Approach 3rd edition,
pg 490
13Multiplicative Multifractal
14- The above multifractal function is considered to
be unstable - It varies from highly heterogenous (at offset
0) to flat (offset diverges to infinity) - Its output usually needs to be rescaled
H controls the roughness of the fractal
Multifractal terrain patch with an offset of 0.8
15Other kinds of Multifractals
- Hybrid multifractals
- Called hybrid because they are both additive and
multiplicative multifractals - Ridged multifractals
- Similar to Perlins turbulence noise
- They calculate 1-abs(noise) so that the resulting
canyons from abs(noise) become high ridges
Ridged multifractal terrains taken from
Texturing and Modeling A Procedural Approach pg
518 (left) pg 480(right)
16Midpoint displacement 1D version
- Type of polygon subdivision algorithm, also a
fractal function - Created to simulate tectonic uplift of mountain
ranges - One of its main input parameters is the roughness
constant r
Step 0
Displace the midpoint of the line by some random
value between (-d, d)
Now reduce the range of your random
function depending on r by d pow( 2 , -r)
Step 1
Again displace the midpoint of all the line
segments and reduce your Random functions range
Step 2
17Keep iterating until you get the required detail
Always remembering to reduce d After every step
Step 3
How does r affect the outcome? If r 1 Your d
will half each iteration If r gt 1 d increases
faster generates smooth terrain If lt 1 d
increases slowly generates chaotic terrain
Nth step
18Diamond- Square
- Also called the cloud fractal , plasma fractal or
random midpoint displacement - The 2D version of the original Midpoint
displacement algorithm - Therefore it also has a roughness constant
-
- The diamond-square alg. works best if it is run
on square grids of width 2n - This ensures that the rectangle size will have an
integer value at each iteration
19- the algorithm starts with a 2 x 2 grid
- The heights at the corners can be set to either
zero, a random value or some predefined value
20- the first step involves calculating the midpoint
of the grid based on its corners and then adding
the maximum displacement for the current
iteration - This is called the Diamond step ,
- Because if you render this terrain you will see
four diamond shapes
E (ABCD)/4 Rand(d)
Rand(d) can generate random values between -d
and d
21- Next is the Square step
- Calculate the midpoints of the edges between the
corners - Since the first iteration is complete, now d is
reduced by - d pow(2,-r) where r is the roughness
constant
wrapping G (ABEE)/4 rand(d) H (BDEE)
/4 rand(d) I (DCEE)/4 rand(d) F
(ACEE)/4 rand(d)
Non-wrapping G (ABE)/3 rand(d) same for
H,I,F
22- Start the second iteration
- Again perform the diamond step
B
J (AGFE)/4 rand(d) K (GBEH)/4
rand(d) L (FEDI)/4 rand(d) M (EHIC)/4
rand(d)
Remember this d is smaller than the one in the
first iteration
C
D
23- Perform the square step
- Continue subdividing until you reach the desired
level of detail
wrapping O (AGJJ)/4 rand(d) P
(JGKE)/4 rand(d) Q (JELF)/4 rand(d) N
(AFJJ)/4 rand(d)
Non-wrapping O (AGJ)/3 rand(d) N
(AFJ)/3 rand(d)
24- To summarize,
- Diamond - Square alg.
- While length of square sides gt 0
- Pass through the whole array and apply the
diamond step for each square - Pass through the whole array and apply the square
step for each diamond - Reduce the range of the random displacement
25Fault line algorithm
- Created to approximate real world terrain
features such as escarpments, mesas, and seaside
cliffs
First step in faulting process
Terrain generated after 400 iterations
Pictures from http//www.lighthouse3d.com/opengl/t
errain/index.php?fault
26- One way of generating fault lines in a height
field grid - randomly pick two grid points p1 p2
- calculate the line between them
- Go through all the points in the height field and
add or subtract an offset value depending on what
side of the line they are located - Before the next fault is drawn, reduce the range
of the offset by some amount
27- Height fields generated by this algorithm need to
be filtered in order to look like realistic
terrain - A low pass filter is usually used
28- some variations to the fault line algorithm
Cosine
Sine
29Particle Deposition
- Simulates volcanic mountain ranges and island
systems - drop random particles in a blank grid
- Determine if the particles neighboring cells are
of a lower height - If this is the case increment the height of the
lowest cell - keep checking its surrounding cells for a set
number of steps or until it is the lowest height
among its surrounding cells - If not increment the height of the current
- cell
Generated after 5 series of 1000 iterations
30Issues with using Height fields
- They cannot generate overhangs or caves
- Some solutions, for example
- mushrooming effects that involve the
manipulation of vertex normals in order to render
height field textures with overhangs - the game Halo Wars implemented a new type of
height field called a vector height field which
stored a vector to displace a vertex instead of
a height value
31(No Transcript)
32Bibliography
- De Carpentier, Giliam J.P.. Interactively
synthesizing and editing virtual outdoor
terrain.MA thesis. Delft University of
Technology, 2007. http//www.decarpentier.nl/downl
oads/InteractivelySynthesizingAndEditingVirtualOut
DoorTerrain_report.pdf - DeLoura, Mark. Game Programming Gems. Charles
River Media, 2002. - Ebert, David S., Musgrave, F. Kenton, Peachey,
Darwyn, Perlin, Ken and Worley, Steve.Texturing
and Modeling A Procedural Approach, 3rd edition.
USA. Morgan Kaufman Publishers, 2003. - Martz, Paul. Generating Random Fractal Terrain.
Game Programmer. Publisher Robert C. - Pendleton, 1997. http//www.gameprogrammer.com/fra
ctal.htmlmidpoint - McAnlis, Colt. HALO WARS The Terrain of
Next-Gen. GDC Vault, 2009. lthttp//www.gdcvault.c
om/play/1277/HALO-WARS-The-Terrain-ofgt
33- Olsen, Jacob. Realtime Procedural Terrain
Generation. Department of Mathematics and
Computer Science, IMADA, University of Southern
Denmark, 2004. lthttp//web.mit.edu/cesium/Public/t
errain.pdfgt - OpenGL. yaldex.com. http//www.yaldex.com/open-g
l/ch20lev1sec2.html - Polack, Trent. Focus on 3D Terrain Programming.
Cengage Learning, 2002. - Ramirez F., António. Terrain Tutorial. Open GL.
Lighthouse 3D., 2012. lthttp//www.lighthouse3d.com
/opengl/terrain/index.php3?introductiongt - Tamshi. RE Heightmap, Voxel, Polygon (geometry)
terrains. Game Development. StackExchange Inc.,
2011. lthttp//gamedev.stackexchange.com/questions/
15573/heightmap-voxel-polygon-geometry-terrainsgt - Welcome to the Virtual Terrain Project.
VTERRAIN.org, 2011. lthttp//vterrain.orggt