Transcript ppt
Terrain Level of Detail
John Tran
Computer Science Department
University of Virginia
<[email protected]>
Why Terrain LOD?
• “It seems you can’t shake a stick in
the world of terrain visualization
without hitting a reference to LOD
Terrain Algorithms”
–Bryan Turner (gamasutra.com)
2
The Data
• Regular Grid
Height Field
• Triangulated Irregular
Networks (TIN)
• Tradeoffs?
3
Terrain LOD vs Traditional LOD
• Easier
– Constrained geometry (generally)
– More specialized and simpler algorithms
• Harder
–
–
–
–
Continuous and large models
Simultaneously very close and far away
Necessitates view-dependent LOD
Out-of-core
From Martin Reddy’s 2002 SIGGRAPH course
4
A Discrete LOD approach
• View-Independent, camera locationdependent
• Still involves subdividing terrain
– Render closer subdivisions at higher
resolution
• Popping
• Will get cracks and T-junctions
5
Terrain LOD Basics
• Cracks, T-junctions
• How do we solve this?
6
Terrain LOD Basics 2
• Can’t use edge/vertex collapse
techniques from last lecture – Why not?
• What can you do?
– Ensure common vertices on edge of
subdivision
• Looks awkward
– Draw a triangle to fill that spot
– Force a crack into a T-junction
• There must be an easier way…
– Subdivide the terrain such that this is easier
or done for free
7
Terrain LOD Basics 3
• Quadtrees and BinTrees
8
Quadtrees
• Each quad is
actually two
triangles
• Still have cracks
and T-junctions
• Easy to implement
9
BinTrees
(Binary Triangle Trees)
• Cracks and
T-junctions are
solved!
• Any two triangles
differ by no more
than one
resolution level
• A little harder to
implement
• Forced Splitting
10
Several Algorithms
• Lindstrom’s Continuous LOD
• ROAM (Duchaineau)
– 3D Bounding Isosurfaces (Blow)
– Caching geometry (Vis2002)
• Visualization of Large Terrains
Made Easy
– SOAR
11
Continuous LOD for Height
Fields
• Peter Lindstrom et al., 1996
• Used a binary vertex tree
• Frame-to-frame coherence
• Introduced usercontrollable
screen space error
threshold
12
ROAM
• Real-Time Optimally Adapting Meshes
• Mark Duchaineau, 1997 (LLNL)
• Binary Triangle Tree Structure
– No need to worry about cracks, etc
• Can specify the desired number of
triangles
• Probably the most popular
algorithm today
13
ROAM – Main Concepts
• Split and Merge
• Two priority queues
– One for splits and one for merge
– Allows for frame-to-frame coherence
• Error Metrics for Splits and Merges
• Geomorphing – introduced, but rarely
needed
• Incremental triangle stripping introduced
14
ROAM – Splitting and
Merging diamonds
15
ROAM – Priority Queues
• One priority queue for splits, one for
merges, and use a greedy algorithm to
triangulate
• Priority = error metric
– Nested world space bounds
– Geometric screen distortion
– Line of site
– How do we calculate these error metrics?
16
ROAM – Wedgies!
• Wedgie –
basically a
bounding
volume
– Covers the (x,y)
extent of a
triangle and
extends over the
height range z-eT
through z+eT
17
ROAM – Splitting
Algorithm
Let T = the base triangulation
For all t in T, insert t into Q
While T is too small or inaccurate
Identify highest priority t in Q
Force-split t
Update split queue as follows:
Remove t and other split triangles
from Q
Add any new triangles to Q
Adapted from Duchaineau’s original ROAMing Terrain paper (96)
18
ROAM – Merging AND
Splitting
• Splitting is straightforward, but so is merging
• Make two priority queues, Qs and Qm
• Add another check:
if T is too large or too accurate
identify lowest priority elements T and TB
in Qm
Merge (T, TB)
Update queues:
Remove all merged children from Qs
Add merge parents T, TB to Qs
Remove T, TB from Qm
Add all newly-mergeable diamonds to Qm
19
ROAM – Notes
• Also need to check if the previous
frame is finished rendering and
update priorities for all elements if
not
• For more details on algorithm, read
the ROAMing Terrain paper
20
ROAM – Demo
• Bryan Turner, gamasutra.com
• “Split-Only ROAM”
• No frame to frame coherence, but
still performs very well
• Seamus McNally, SMTerrain uses
this same approach
21
Bounding ROAM with
3D Isosurfaces
• Jonathon Blow (2000)
• ROAM doesn’t work well for densely
sampled data – large number of
unnecessary wedgie calculations
• Screen-space error metrics compress 3D
geometric data into a 1D scalar value
• Instead, use all 3 dimensions, and have
bounding volumes (spheres) determine
visibility
• 65% less triangles than ROAM
22
Caching Geometry
• Josh Levenberg, Vis2002
– “Fast View-Dependent Level-of-Detail
Rendering Using Cached Geometry”
– Not yet published
• Uses ROAM, but also caches
geometry of “aggregate triangles”
on the video card (VAR)
• Claim 4x faster with caching
23
Visualization of Large
Terrains Made Easy
• P. Lindstrom and V. Pascucci
(Vis2001)
• Few dozen lines of C-code
• Uses regular grid bintree
• Now implemented as SOAR
(Stateless, One-pass adaptive
Refinement)
24
Visualization of Large
Terrains Made Easy (2)
• Focus on “the manner in which the data is
laid out to achieve good memory
coherency”
– Using mmap system call
– Let the OS take care of paging
25
Visualization of Large
Terrains Made Easy (3)
• “Longest edge bisection”
– Monotonic!
– Implicit parent-child relationships – no need for priority
queues
• Represent this mesh using a DAG of the vertices
• They used a nested sphere hierarchy for object
space and screen space testing (similar to Blow)
26
Visualization of Large
Terrains Made Easy (4)
• Separate threads for rendering and
geometry updates
• Mesh refinement, view frustum
culling, and FULL triangle stripping
• All done in one pass over the mesh
– No Frame-to-frame coherence needed!
27
Visualization of Large
Terrains Made Easy
τ = 2 pixels
τ = 4 pixels
79,382 triangles
25,100 triangles
τ = screen space error threshold
28
Implementing a terrain in
your Scene Graph
• Anyone have tips?
• Most games use a modified ROAM
algorithm
– Although a static approach may be easy, it will
be inaccurate and it will show
• Keep the terrain fairly small if possible
– i.e. Don’t have a 10k x 10k grid if you only
want to show a single mountain
29
Implementing a terrain in
your Scene Graph
• Where to go for more info?
– LODbook.com
– Virtual Terrain Project (www.vterrain.org)
– Duchaineau’s ROAM homepage
(www.cognigraph.com/ROAM_homepage/)
– SOAR
(www.cc.gatech.edu/~lindstro/software/soar/)
• There are other basic algorithms
– ie TIN-based algorithms
30
More Problems with
Terrain LOD
• QuadTIN (VIS2002)
• Large Textures
• Paging/Streaming and Out-of-core
Techniques
31
Summary
• Any questions?
32