1 / 25

# Today - PowerPoint PPT Presentation

Today. Terrain Generating terrain. Terrain. Terrain is obviously important to many games As a model, it is very large Creating every point explicitly by hand is not feasible, so automated terrain generation methods are common

Related searches for Today

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'Today' - hernando

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

• Terrain

• Generating terrain

CS 638, Fall 2001

• Terrain is obviously important to many games

• As a model, it is very large

• Creating every point explicitly by hand is not feasible, so automated terrain generation methods are common

• When rendering, some of the terrain is close, and other parts are far away, leading to terrain LOD algorithms

CS 638, Fall 2001

• Terrain is typically an example of a height field

• z=f(x,y) for (x,y) within the limits of the space

• Precludes things like caves and overhangs

• There are two common ways to represent the function f(x,y)

• Explicitly store the value of f(x,y) for a discrete grid of (x,y) locations

• Generally interpolate (bilinear) or triangulate to get points not on the grid

• Easy to figure out what the height of the terrain is at any given (x,y)

• Expensive to store the entire terrain

• Store a polygonal mesh

• Cheaper if the terrain has large flat areas

• Harder to figure out what the height is under the player (have to know which triangle they are in)

CS 638, Fall 2001

• 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

CS 638, Fall 2001

• 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

CS 638, Fall 2001

• 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

• 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

• Very poor control over the outcome

• Non-intuitive parameter settings

CS 638, Fall 2001

Random Points(Gems Ch 4.16)

• Randomly choose a value for each grid point

• Can make each point independent (don’t consider neighbors)

• Can make points dependent on previous points

• Called a Markov process

• Generally must smooth the resulting terrain

• Various smoothing filters could be used

• Advantage: Relatively easy to generate on the fly

CS 638, Fall 2001

• 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

CS 638, Fall 2001

Fault Formation(Gems Ch 4.17)

• 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

• The smoothing method in chapter 4.17 has some very bad properties

CS 638, Fall 2001

Initial

Smoothed

From Gems page 489

CS 638, Fall 2001

Gems color plate 1

CS 638, Fall 2001

Particle Deposition(Gems Ch 4.19)

• 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

CS 638, Fall 2001

?

?

In 3D, more scope for random choices on jiggling particles

CS 638, Fall 2001

Gems color plate 3

CS 638, Fall 2001

• 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 (See Gems Chapter 4.18)

CS 638, Fall 2001

Note: Works on any triangular mesh - does not have to be regular or have equal sized triangles

See my lecture notes from CS559 for implementation details

CS 638, Fall 2001

• Generates a triangle bintree from the top down

• Useful for LOD, as we shall see

• Ideally, works for right-angled isosceles triangles

CS 638, Fall 2001

• Note that the middle of each square is not on an edge, so what is its initial value?

• Answers vary, and Gems has one possibility

CS 638, Fall 2001

• 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

• 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

• If desired, boundary vertices can be left unmoved, to maintain the boundary edge

CS 638, Fall 2001

This mesh probably doesn’t reduce the offset by much at each step.

Very jagged terrain

http://members.aol.com/maksoy/vistfrac/sunset.htm

CS 638, Fall 2001

http://www.planetside.co.uk/ -- tool is called Terragen

CS 638, Fall 2001

Triangulated Point Sets Perlin noise

• 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?

CS 638, Fall 2001

Delaunay Triangulation Perlin noise

• 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

Delaunay

Not - points inside this circle

CS 638, Fall 2001

Populating Terrain Perlin noise

• 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

CS 638, Fall 2001

• 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

• Fault generation could be modified by tiling, but continuity across tiles is difficult

CS 638, Fall 2001