Procedural and Fractal Terrains. Gameplay goals for a terrain engine Large enough to travel around...
-
Upload
austen-long -
Category
Documents
-
view
214 -
download
0
Transcript of Procedural and Fractal Terrains. Gameplay goals for a terrain engine Large enough to travel around...
Gameplay goals for a terrain engine
• Large enough to travel around for hours
• Detailed when seen at a human scale
• Dynamic modification of terrain data
• Runs at high, stable frame rates
• Need fast rotation of viewpoint
Technical goals
• Level-of-detail management (static or continuous?)
• A lot of polygons (231 in un-reduced terrain, 70,000+ in a given tessellation)
• Efficient graphics primitives
• Near-field detail (geometric and color)
Terrain Map
• Height Map
z = f(x, y)x and y are sampled on a 2D integer grid
– Real data : Satellite, Elevation maps– Synthetic : Texture map, Noise functions
Terrain Map
• Natural looking– Model high detail– Size
• Storage (Millions of polygons)• Rendering speed
– Zoom-in, zoom-out (does not scale well)
• Use textures to model detail?• Not real geometry (bump mapping at silhouettes)• Not scale independent• Repeated textures do not work well
Fake Terrain
• Generate the heightfield:– Coarse height map + periodic details– Procedural or function-based– Random process
Terrain Coloring
• Using a 2D texture map provides richer detail, but is independent of the terrain.
Random Terrain
• Simple:– Terrain(x,y) = rand( MAX_HEIGHT )– Results in random noise
• Next step:– Smooth the terrain generated above– FIR filter: 1 1 1
1 1 1
1 1 1R
Filtering
• FIR (Finite Impulse Response) filter:– Pass a “window” over the data– Multiply data in window by weights
• Result = d1*w1 + d2*w2+ … + dN*wN
– Window + weights is called “filter kernel”– Larger window grabs more data
Random Fault Lines
• Repeatedly:– Create a line that crosses terrain– Add dHeight offset on one side of
line– dHeighti = dHeight0 + (i/n)(dHeightn -
dHeight0)– Select random endpoints to generate
line
• Compute “side of line” by plugging X,Y into line equation
+dHeight
More Realistic Faults
• Apply FIR filter to faulted heightmap
• Smooth out abrupt fault transitions: “Erosion”
Particle Deposition
• Drop particles in areas where you want volcanic mountains
• Particles flow downhill until they have cause to rest
• Move the drop point to create interesting peak
Particle Deposition
• Flow computation– At given point, find lowest neighbor– If local geometry is not flat enough, move new
particle on top of lowest neighbor• Roll down hill
– “Flat enough” = 27 degrees or so– Check 3x3 pixel window or 5x5 to check
neighbors.
Procedural Modeling With Fractals
• Procedural Modeling– Compute geometry “on-the-fly”
• Fractals– Model Natural Phenomena - Self Similarity
• Mountains, fire, clouds, etc.
– Scales to infinity• Add or “make up” natural looking details with
mathematical tools
Two Fractal Properties
• Fractal Dimension– Euclidean dimensions : 1, 2, 3, 4, …– Fractal : 1.2342, 2.7656– Measure of detail or roughness of a fractal
D = (ln N)/(ln 1/s)
Midpoint Subdivision
• Brownian Motion– Describes random movement of particles in a
gas or fluid
• Fractional Brownian Motion– Brownian Motion + Fractal Dimension– A useful model for natural phenomena
Fractional Brownian Motion
• Fractional Brownian Motion– Equations are compute intensive– Approximate with “A family of 1D Gaussians ”
• Zero mean
• Standard Deviation : S = k2-iH
H = fractal dimension (roughness)
Fractal Mountains
• Recursively subdivide geometry by random number d:–dHeight/2 < d < dHeight/2
• At each recursion:– dHeight *= 2-r
– r=1 : self-similar– r>1 : large features early– r<1 : large features late
A B
A B
A B
Terrain Modeling Criteria
• Input– Initial coarse mesh + stochastic parameters
• Two criteria– Internal Consistency
• Reproducibility : Model is independent of position and orientation
• Associate “random numbers” to point index
– External Consistency• Continuity between adjacent primitives
Mesh Subdivision
• Square-square Subdivision– Addresses “creasing problem” (slope
discontinuities)
• Subdivide parametric patches
Mesh Subdivision
• Displacement is scaled by the recursion level.– | b – a | -rn
• When do you stop the recursion?– Pixel resolution
• Displace upward, or towards the normal to the surface?
Mesh Subdivision
• External Consistency– Avoid tears between neighboring polygons– How do we compute the normals?
• Average polygon normals at each vertex.
• Propagate normals down the recursion
• Cheaper : use the original mesh normals only
Ridged Fractal Terrains
• To create sharp peaks, add an absolute value and flip the surface upside down.
• Or, reflect about a maximum value.
• Provides a volcano-like effect.
More Controls
• To create valleys, create a lower amplitude and rather smooth terrain to use as the max operator.
Ridges
• Quantize a terrain to create ridges– Use directly or as the min function.– Can also be done as a transfer function that
maps f(x)->g(x).
height
New height
Other techniques
• Cracked terrains for dry lakes and riverbeds.
• Throw random points onto the plane.
• Construct the Voronoi diagram and use the graph to etch into the terrain.
Erosion - Higher-level control
• Musgrave, et al. “The Synthesis and Rendering of Eroded Fractal Terrains”, Siggraph 1989.
• Hydraulic Erosion– Water (rain) depositing to settle in height field
• Thermal Weathering– “Any material that knocks material loose, which
then falls down to pile up at the bottom of an incline.”