Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Terrain Rendering and Level of Detail Week 7 Advanced Programming for 3D Applications CE00383-3.

Similar presentations


Presentation on theme: "1 Terrain Rendering and Level of Detail Week 7 Advanced Programming for 3D Applications CE00383-3."— Presentation transcript:

1 1 Terrain Rendering and Level of Detail Week 7 Advanced Programming for 3D Applications CE00383-3

2 22Terrain Terrain is important to many games Terrain is important to many games As a model, it is very large As a model, it is very large Creating every point explicitly by hand is not feasible, so automated terrain generation methods are common 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 When rendering, some of the terrain is close, and other parts are far away, leading to terrain LOD algorithms

3 33Terrain A terrain mesh is nothing more than a triangle grid, with has heights of each vertex in the grid specified in such a way that the grid models a smooth transition from mountain to valley, simulating a natural terrain. To make it realistic we apply a nice texture showing sandy beaches, grassy hills, and snowy mountains

4 44Terrain To generate terrain a simple solution consists in using a brute force approach. – –it simply stores the entire terrain vertex/index data and then renders it. – –For games requiring a small terrain, this approach is workable with modern graphics cards that support hardware vertex processing. However, for games requiring larger terrains, you have to do some kind of level of detail or culling because the enormous amount of geometry data needed to model such huge terrains can be overwhelming for a brute force approach.

5 55 What is the Problem? Terrains tend to be huge Terrains tend to be huge Visualizing a terrain of 16384 x 16384 samples (164 x 164 km, samples 10 m apart) requires drawing 536,805,378 triangles (268,435,456 vertices) Visualizing a terrain of 16384 x 16384 samples (164 x 164 km, samples 10 m apart) requires drawing 536,805,378 triangles (268,435,456 vertices) Adding a 32 bit RGBA texture and having 16 bit heights, the total memory consumption is above 1.5 Gb! Adding a 32 bit RGBA texture and having 16 bit heights, the total memory consumption is above 1.5 Gb!

6 66 Terrain Generation Methods Paint the height field (artist generated) Paint the height field (artist generated) Various pseudo-random processes 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 Triangulated point sample methods Plenty of research and commercial tools for terrain generation Plenty of research and commercial tools for terrain generation –http://www.vterrain.org/LOD/Implementations/

7 77 Surface Attributes Rather than painting texture and color directly, paint 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 Then automatically generate colors/textures –Care must be taken at the boundaries of the regions Can also work for the terrain itself Can also work for the terrain itself –E.g. Maps that have a finite number of possible heights, with ramps between them

8 88 Terrain Representation Terrains are often represented using elevation maps Terrains are often represented using elevation maps An elevation map is a 2D array of regularly spaced height samples An elevation map is a 2D array of regularly spaced height samples

9 99 Painted Terrain Example Height Color Texture

10 1010 Representing Terrain The base representation for terrain is usually a height field The base representation for terrain is usually a height field –z=f(x,y) for (x,y) within the limits of the space There are two common ways to represent the function f(x,y) 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 or triangulate to get points not on the grid Generally interpolate 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) Easy to figure out what the height of the terrain is at any given (x,y) Expensive to store the entire terrain Expensive to store the entire terrain –Store a polygonal mesh Cheaper if the terrain has large flat areas 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) Harder to figure out what the height is under the player (have to know which triangle they are in)

11 1111Heightmaps We use a heightmap to describe the hills and valleys of the terrain. A heightmap is an array where each element specifies the height of a particular vertex in the terrain grid. One of the possible graphical representations of a heightmap is a grayscale map, where darker values reflect portions of the terrain with low altitudes and whiter values reflect portions of the terrain with higher altitudes.

12 1212 Create Heightmap as Grayscale Heightmaps can be generated either : -procedurally or -In an image editor such as Adobe Photoshop. Using an image editor is probably the easiest way to go, and it allows you to create the terrain interactively and visually as you want it. In addition, you can take advantage of your image editor features, such as filters, to create interesting heightmaps.

13 1313 Random Processes Generation The claim is that real terrain looks “random” over many scales The claim is that real terrain looks “random” over many scales Hence, random processes should generate realistic terrain Hence, random processes should generate realistic terrain –The catch is knowing which random processes Some advantages: 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: Some disadvantages: –Very poor control over the outcome –Non-intuitive parameter settings

14 1414 Random Points Randomly choose a value for each grid point 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 Generally must smooth the resulting terrain –Various smoothing filters could be used Advantage: Relatively easy to generate on the fly Advantage: Relatively easy to generate on the fly

15 1515 Fault Formation Claimed to model real fault lines, but not at all like real faults Claimed to model real fault lines, but not at all like real faults Process 1: Process 1: –Generate a random line and lift everything on one side of the line by d –Scale d and repeat Process 2: Process 2: –Generate a random line and lift the terrain adjacent to the line –Repeat (maybe with a scale function) Smoothing is important Smoothing is important

16 1616 Fault Formation Example Initial Smoothed

17 1717 Particle Deposition Supposed to model lava flow (or glacial drumlins!) Supposed to model lava flow (or glacial drumlins!) Process: Process: –Drop a particle onto the terrain –Jiggle it around until 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 volcanoes, invert everything above a plane To do sinkholes, invert the hill To do sinkholes, invert the hill To do rows of hills, move the drop point along a line To do rows of hills, move the drop point along a line

18 1818 Particle Deposition Process ? ? In 3D, more scope for random choices on jiggling particles

19 1919 Fractal Terrain Based on subdivision of a course polygon mesh Based on subdivision of a course polygon mesh Each subdivision adds detail to the mesh in a random way Each subdivision adds detail to the mesh in a random way Algorithm (starting with a triangular mesh): 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 Also algorithms for quadrilateral meshes http://www.gameprogrammer.com/fractal.ht ml http://www.gameprogrammer.com/fractal.ht ml

20 2020 Subdivision Method No 1 Note: Works on any triangular mesh - does not have to be regular or have equal sized triangles.

21 2121 Subdivision Method No 2 Generates a triangle bintree from the top down Generates a triangle bintree from the top down Useful for LOD, Useful for LOD, Ideally, works for right- angled isosceles triangles Ideally, works for right- angled isosceles triangles

22 2222 Subdivision Method No 3 Assume quadrilateral meshes Assume quadrilateral meshes

23 2323 Fractal Terrain Details The original mesh vertices don’t move, so it defines the overall shape of the terrain (mountains, valleys, etc) 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 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 making patterns from pseudo- random numbers making patterns from pseudo- random numbers If desired, boundary vertices can be left unmoved, to maintain the boundary edge If desired, boundary vertices can be left unmoved, to maintain the boundary edge

24 2424 Fractal Terrains Very jagged terrain

25 2525 Populating Terrain Coloring terrain: Coloring terrain: –Paint texture maps –Base color on height (with some randomness) Trees: Trees: –Paint densities, or randomly set density –Then place trees randomly within regions according to density Rivers (and lakes): Rivers (and lakes): –Trace local minima, and estimate catchment areas (more later…)

26 2626 Terrain Generation Trade-Offs Control vs Automation: 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: 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

27 2727 Static LOD Depending on the roughness of the terrain and the application, 5%-50% of the vertices and triangles can be removed Depending on the roughness of the terrain and the application, 5%-50% of the vertices and triangles can be removed –With 536.805.378 triangles still more than 200.000.000 triangles to draw in best case. Frustum culling further reduces number of triangles to draw Frustum culling further reduces number of triangles to draw In most cases we still draw the terrain at full resolution near the far plane In most cases we still draw the terrain at full resolution near the far plane

28 2828 View-Dependent Dynamic LOD Dynamic simplification of visible part of the terrain Dynamic simplification of visible part of the terrain A mountain observed from a distance of 10 km requires a higher tessellation than when observed from a distance of 100 km A mountain observed from a distance of 10 km requires a higher tessellation than when observed from a distance of 100 km The quality of the tessellation can be changed at run time to achieve constant frame rates The quality of the tessellation can be changed at run time to achieve constant frame rates Terrains can be altered at run time Terrains can be altered at run time

29 2929 Terrain LOD Terrain poses problems for static LOD methods Terrain poses problems for static LOD methods –Must have high resolution in the near field, and low resolution in the distance, all in one model Dynamic LOD methods are the answer Dynamic LOD methods are the answer –All based on the idea of cuts through a tree of potential simplifications ROAM algorithm is a good example ROAM algorithm is a good example –Other continuous LOD algorithms are similar in style An alternative is to create fixed LODs for sub- regions and figure out how to join them together An alternative is to create fixed LODs for sub- regions and figure out how to join them together

30 3030 Terrain LOD Algorithms Triangle bintree based Triangle bintree based –‘ROAMing Terrain: Real-time Optimally Adapting Meshes’ – Duchaineau et al. Quad tree based Quad tree based –E.g. ‘Real-Time, Continuous Level of Detail Rendering of Height Fields’ – Lindstrom et al. Progressive mesh based Progressive mesh based –E.g. ‘Smooth View-Dependent Level-of-Detail Control and its Application to Terrain Rendering’ – Hoppe Geo Mipmapping Geo Mipmapping –‘Fast Terrain Rendering Using Geometrical MipMapping’ – de Boer

31 3131 Other Issues Terrain Texturing Terrain Texturing Terrain Lighting Terrain Lighting Camera Animation and Fly-through Camera Animation and Fly-through SkyBox SkyBox Terrain following (a form of collision) Terrain following (a form of collision) –Maintaining characters and objects on top of Terrain


Download ppt "1 Terrain Rendering and Level of Detail Week 7 Advanced Programming for 3D Applications CE00383-3."

Similar presentations


Ads by Google