Upload
lawrence-harrington
View
214
Download
0
Tags:
Embed Size (px)
Citation preview
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Last Time
• Terrain Dynamic LOD
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Today
• Terrain Generation– Most examples taken from Game Programming Gems
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Terrain Generation Methods
• Paint the height field (artist generated)
• Various pseudo-random processes– Independent random height at each point
– Fault generation methods (based on random lines)
– Particle deposition
– Fractal terrain from meshes
• Triangulated point sample methods
• Plenty of commercial tools for terrain generation
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Painting Terrain
• An artist paints a gray image– Light represents high points, dark is low
– The pixels directly give the function values on the grid
• The preferred method when good control is required and not too much terrain needs too be generated
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Painted Terrain Example
Height
Color
Texture
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Surface Attributes
• Rather than painting texture and color directly, paint attributes– E.g. Grass, Trees, Water, …
– Features can have game-play characteristics: speed of motion, impassable, …
• Then automatically generate colors/textures– Care must be taken at the boundaries of the regions
• Can also work for the terrain itself– E.g. Maps that have a finite number of possible heights, with ramps
between them
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Random Processes
• The claim is that real terrain looks “random” over may scales
• Hence, random processes should generate realistic terrain– The catch is knowing which random processes
• Some advantages:– Lots of terrain with almost no effort– If the random values are repeatable, the terrain can be generated on
the fly, which saves on storage
• Some disadvantages:– Very poor control over the outcome– Non-intuitive parameter settings
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Random Points
• Randomly choose a value for each grid point– Can make each point independent (don’t
consider neighbors)– Can make points dependent on previous
points - a spatial Markov process
• Generally must smooth the resulting terrain– Various smoothing filters could be used
• Advantage: Relatively easy to generate on the fly
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Repeatable Random Values
• Most “random” number generators on computers are actually “pseudo-random”– Generated by functions that highly de-correlate their input
• Standard random number generators produce a sequence of values given some initial seed– Warning: Most implementations are poor, so find your own– Not good enough for on-the-fly terrain, because we don’t know
what order the terrain will be required• Hashing functions take a value and transform it into another
value with the appearance of randomness– Used in hash tables to transform keys to hash indexes– Great for terrain – Use (x,y) as the key, and hash it to the height
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Fault Formation
• Claimed to model real fault lines, but not at all like real faults
• Process 1:– Generate a random line and lift everything on one side of the line by d
– Scale d and repeat
– What does the terrain typically look like?
• Process 2:– Generate a random line and lift the terrain adjacent to the line
– Repeat (maybe with a scale function)
– What does the terrain look like?
• Smoothing is very important
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Fault Formation Example
Initial Smoothed
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Fault Formation Example
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Particle Deposition
• Supposed to model lava flow (or glacial drumlins!)
• Process:– Drop a particle onto the terrain
– Jiggle it around until it it is at most one unit higher than each of its neighbors
– Repeat
– Occasionally move the drop point around
• To do volcanoes, invert everything above a plane
• To do sinkholes, invert the hill
• To do rows of hills, move the drop point along a line
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Particle Deposition Process
?
?In 3D, more scope for random choices on jiggling particles
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Particle Deposition Image
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Fractal Terrain
• Based on subdivision of a course polygon mesh
• Each subdivision adds detail to the mesh in a random way
• Algorithm (starting with a triangular mesh):– Split each edge, and shift the new vertex up or down by a random
amount
– Subdivide the triangles using the new vertices
– Repeat
• Also algorithms for quadrilateral meshes
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Subdivision Method No 1
Note: Works on any triangular mesh - does not have to be regular or have equal sized trianglesSee my lecture notes from CS559 for implementation details
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Subdivision Method No 2
• Generates a triangle bintree from the top down
• Useful for LOD, as we have seen• Ideally, works for right-angled
isosceles triangles
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Subdivision Method No 3
• Note that the middle of each square is not on an edge, so what is its initial value?
• Answers vary
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Fractal Terrain Details
• The original mesh vertices don’t move, so it defines the overall shape of the terrain (mountains, valleys, etc)
• There are options for choosing where to move the new vertices– Uniform random offset
– Normally distributed offset – small motions more likely
– Procedural rule – eg Perlin noise
• If desired, boundary vertices can be left unmoved, to maintain the boundary edge
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Fractal Terrain Scaling
• Scaling the offset of new points according to the subdivision level is essential– For the subdivision to converge to a smooth surface, the
offset must be reduced for each level (to less than half its previous value)
– Why? (Intuitively)
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Fractal Terrains
http://members.aol.com/maksoy/vistfrac/sunset.htm
This mesh probably doesn’t reduce the offset by much at each step.Very jagged terrain
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Terrain, clouds generated using procedural textures and Perlin noisehttp://www.planetside.co.uk/ -- tool is called Terragen
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Terrain, clouds generated using procedural textures and Perlin noisehttp://www.planetside.co.uk/ -- tool is called Terragen
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Triangulated Point Sets
• Start with a set of points that define specific points on the terrain– Tops of mountains, and bottoms of valleys, for example
• Triangulate the point set, and then start doing fractal subdivision• What makes a good point set triangulation?
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Delaunay Triangulation
• A triangulation with the circum-circle property:
• Several algorithms for computing it - look in any computational geometry book
For every triangle, a circle through its points does not contain any other point
DelaunayNot - points inside this circle
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Populating Terrain
• Coloring terrain:– Paint texture maps
– Base color on height (with some randomness)
• Trees:– Paint densities, or randomly set density
– Then place trees randomly within regions according to density
• Rivers (and lakes):– Trace local minima, and estimate catchment areas
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Terrain Generation Trade-Offs
• Control vs Automation:– Painting gives most control
– Fractal terrain next best control because you can always specify more points
– Random methods give little control - generate lots and choose the one you like
• Generate on-the-fly:– Random points and fractal terrain could be generated on the fly, but
fractal terrain generation is quite slow
– Tilings can also be generated on the fly
10/21/03 CS679 - Fall 2003 - Copyright Univ. of Wisconsin
Todo
• By Monday, Nov 3, Stage 3 demo
• Thursday, Nov 6, Midterm– In class
– Material up to and including today’s lecture, but not beyond