1 / 33

3D Terrain Generation

3D Terrain Generation. Pablo Saldarriaga CSE4431. Why 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

maili
Download Presentation

3D Terrain Generation

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. 3D Terrain Generation Pablo Saldarriaga CSE4431

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

  3. Background • The defense industry created virtual terrains as early as the 1970’s • 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 1980’s 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 1980’s that fractals and polygonal subdivision techniques started to become more widespread in artificial terrain generation

  4. Military 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. http://www.planetside.co.uk/gallery/f/tg2/Hannes-Another+jungle+flyover.jpg.html

  6. How 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 • TIN’s, tesselation schemes such as ROAM (Realtime optimally adapting mesh) and other LOD(Level of Detail) techniques

  7. ROAM Voxel Terrain ROAM : Inventor Projects 2006, http://merlin.fit.vutbr.cz/wiki/index.php/Inventor_Projects_2006 Voxel Terrain: Generating Complex Procedural Terrains Using the GPU, http://http.developer.nvidia.com/GPUGems3/gpugems3_ch01.html

  8. Topics • 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. Very simple example

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

  13. “Multiplicative Multifractal”

  14. The above multifractal functionis 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

  15. Other kinds of Multifractals • Hybrid multifractals • Called hybrid because they are both additive and multiplicative multifractals • Ridged multifractals • Similar to Perlin’s 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)

  16. Midpoint 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 function’s range Step 2

  17. Keep 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 > 1 d increases faster generates smooth terrain If < 1 d increases slowly generates chaotic terrain Nth step

  18. Diamond- 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 2^n • 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 = (A+B+C+D)/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 = (A+B+E+E)/4 + rand(d) H = (B+D+E+E) /4 + rand(d) I = (D+C+E+E)/4 + rand(d) F = (A+C+E+E)/4 + rand(d) Non-wrapping G = (A+B+E)/3 +rand(d) same for H,I,F

  22. Start the second iteration • Again perform the diamond step B J = (A+G+F+E)/4 + rand(d) K = (G+B+E+H)/4 + rand(d) L = (F+E+D+I)/4 + rand(d) M = (E+H+I+C)/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 = (A+G+J+J)/4 + rand(d) P = (J+G+K+E)/4 + rand(d) Q = (J+E+L+F)/4 + rand(d) N = (A+F+J+J)/4 +rand(d) Non-wrapping O = (A+G+J)/3 + rand(d) N = (A+F+J)/3 + rand(d)

  24. To summarize, • Diamond - Square alg. • While length of square sides > 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

  25. Fault 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/terrain/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

  29. Particle Deposition • Simulates volcanic mountain ranges and island systems • drop random particles in a blank grid • Determine if the particle’s 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

  30. Issues 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. Bibliography • De Carpentier, Giliam J.P.. Interactively synthesizing and editing virtual outdoor terrain.MA thesis. Delft University of Technology, 2007. http://www.decarpentier.nl/downloads/InteractivelySynthesizingAndEditingVirtualOutDoorTerrain_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/fractal.html#midpoint • McAnlis, Colt. “HALO WARS: The Terrain of Next-Gen.” GDC Vault, 2009. <http://www.gdcvault.com/play/1277/HALO-WARS-The-Terrain-of>

  32. Olsen, Jacob. Realtime Procedural Terrain Generation. Department of Mathematics and Computer Science, IMADA, University of Southern Denmark, 2004. <http://web.mit.edu/cesium/Public/terrain.pdf> • “OpenGL”. yaldex.com. http://www.yaldex.com/open-gl/ch20lev1sec2.html • Polack, Trent. Focus on 3D Terrain Programming. Cengage Learning, 2002. • Ramirez F., António. “Terrain Tutorial.” Open GL. Lighthouse 3D., 2012. <http://www.lighthouse3d.com/opengl/terrain/index.php3?introduction> • Tamshi. “RE: Heightmap, Voxel, Polygon (geometry) terrains.” Game Development. StackExchange Inc., 2011. <http://gamedev.stackexchange.com/questions/15573/heightmap-voxel-polygon-geometry-terrains> • “Welcome to the Virtual Terrain Project.” VTERRAIN.org, 2011. <http://vterrain.org>

More Related