1 / 25

Today

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

hernando
Download Presentation

Today

An Image/Link below is provided (as is) to download presentation 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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Today • Terrain • Generating terrain CS 638, Fall 2001

  2. 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 • When rendering, some of the terrain is close, and other parts are far away, leading to terrain LOD algorithms CS 638, Fall 2001

  3. Representing Terrain • 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

  4. 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 CS 638, Fall 2001

  5. 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 CS 638, Fall 2001

  6. 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 • A disadvantage: • Very poor control over the outcome • Non-intuitive parameter settings CS 638, Fall 2001

  7. 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

  8. 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 CS 638, Fall 2001

  9. 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

  10. Fault Formation Example Initial Smoothed From Gems page 489 CS 638, Fall 2001

  11. Fault Formation Example Gems color plate 1 CS 638, Fall 2001

  12. 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

  13. Particle Deposition Process ? ? In 3D, more scope for random choices on jiggling particles CS 638, Fall 2001

  14. Particle Deposition Image Gems color plate 3 CS 638, Fall 2001

  15. 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 (See Gems Chapter 4.18) CS 638, Fall 2001

  16. Subdivision Method No 1 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

  17. Subdivision Method No 2 • 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

  18. Subdivision Method No 3 • 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

  19. 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 • 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

  20. Fractal Terrains 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

  21. Terrain, clouds generated using procedural textures and Perlin noise http://www.planetside.co.uk/ -- tool is called Terragen CS 638, Fall 2001

  22. 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? CS 638, Fall 2001

  23. 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 Delaunay Not - points inside this circle CS 638, Fall 2001

  24. 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 CS 638, Fall 2001

  25. 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 • Fault generation could be modified by tiling, but continuity across tiles is difficult CS 638, Fall 2001

More Related