Document 7431798

Download Report

Transcript Document 7431798

Level of Detail:

Generating LODs David Luebke University of Virginia

Review: Generating LODs

 Measuring error – Image-based ideas  See Lindstrom & Turk, SIGGRAPH 2000

Review: Generating LODs

 Measuring error – Hausdorff distance   One-sided: Two-sided:   max min

b B

– Common approximations: max   Measure vertex-vertex distance, vertex-plane distance  METRO: Sample H(A,B) by sprinkling points on triangles  Quadrics: a variation of vertex-plane distance 

Quadric Error Metric

  p : Goal: minimize distance to all planes at a vertex – Actually: minimize sum of squared distances to all planes Plane equation for each face:

v

Ax

+

By

+

Cz

+

D

 0  Distance to vertex

v

:

p T

v

 [

A B C D

]    

z

1

x y

  

Squared Distance At a Vertex

D (

v

) 

p

 ( 

planes

(

v p T

)

v

) 2 

p

 ( 

planes

(

v v T

)

p

)(

p T v

) 

p

 

planes

(

v T v

) (

pp T

)

v

v T

 

p

 

planes

(

pp T v

)  

v

Quadric Derivation (cont’d)

pp T

is simply the plane equation squared:

pp T

     

A

2

AB AC AD AB B

2

BC BD AC BC C

2

CD AD BD CD D

2      

The pp T sum at a vertex v is a matrix, Q

: D

( v )

v T

 

v

Using Quadrics

 Construct a quadric Q for every vertex v 1 The

edge quadric

: Q 1 Q Q  Q 1 + Q 2 v 2 Q 2  Sort edges based on edge cost – Suppose we contract to v 1 : – v 1 ’s new quadric is simply: edge cost Q  v 1 T Qv 1

Optimal Vertex Placement

 Each vertex has a quadric error metric Q associated with it – Error is zero for original vertices – Error nonzero for vertices created by merge operation(s)  Minimize Q to calculate optimal coordinates for placing new vertex – Details in paper, involves inverting matrix – Authors claim 40-50% less error

Boundary Preservation

 To preserve important boundaries, label edges as normal or

discontinuity

 For each face with a discontinuity, a plane perpendicular intersecting the discontinuous edge is formed.

 These planes are then converted into quadrics, and can be weighted more heavily with respect to error value.

Preventing Mesh Inversion

 Preventing foldovers:

7 8 2 10 9 3 1 A 6

merge

9 8 3 2 A 6 10 4 5 4 5

 Calculate the adjacent face normals, then test if they would flip after simplification  If foldover, that simplification can be weighted heavier or disallowed.

Quadric Error Metrics

 Pros: – Fast! (70K poly bunny to 100 polygons in seconds) – Good fidelity even for drastic reduction – Robust -- handles non-manifold surfaces – Aggregation -- can merge objects

Quadric Error Metrics

 Cons: – Introduces non-manifold surfaces (

bug or feature?

) – Needs further extension to handle color (e.g., use 7x7 matrices)

View-Dependent LOD: Algorithms  Many good published algorithms: –

Progressive Meshes

by Hoppe [SIGGRAPH 96, SIGGRAPH 97, …] –

Merge Trees

by Xia & Varshney [Visualization 96] –

Hierarchical Dynamic Simplification

Luebke & Erikson [SIGGRAPH 97] by –

Multitriangulation

by DeFloriani et al – Others…

Overview: The VDS Algorithm  I’ll describe (surprise) my own work – Algorithm:

VDS

Implementation:

VDSlib

– Similar in concept to most other algorithms

Overview: The VDS Algorithm  Overview of the VDS algorithm: – A preprocess builds the

vertex hierarchy

, a hierarchical clustering of vertices – At run time, clusters appear to grow and shrink as the viewpoint moves – Clusters that become too small are collapsed, filtering out some triangles

Data Structures  The

vertex hierarchy

– Represents the entire model – Hierarchy of

all

vertices in model – Queried each frame for updated scene  The

active triangle list

– Represents the current simplification – List of triangles to be displayed – Triangles added and deleted by operations on vertex tree

The Vertex Hierarchy  Each node in vertex hierarchy

supports

subset of the model vertices a – Leaf nodes support a single vertex from the original full-resolution model – The root node supports all vertices  For each node we also assign a representative vertex or

proxy

The Vertex Tree: Folding And Unfolding

9

Folding

a node collapses its vertices to the proxy 

Unfolding

the node splits the proxy back into vertices

8 7 8

Fold Node A

2 A A 10 6 6 9 3 3 1

Unfold Node A

10 4 5 4 5

Vertex Tree Example

8 7

R

9 2 3 1 6 4 5

Triangles in active list

10 D E 10 A B C 1 2 7 4 5 6 8 9 3

Vertex hierarchy

Vertex Tree Example

9 8 7

R

2 A 3 1 6 4 5

Triangles in active list

10 D E 10 A B C 1 2 7 4 5 6 8 9 3

Vertex hierarchy

Vertex Tree Example

8

R

A 9 3 6 4 5

Triangles in active list

10 D E 10 A B C 1 2 7 4 5 6 8 9 3

Vertex hierarchy

Vertex Tree Example

8

R

A 9 3 6 B 4 5

Triangles in active list

10 D E 10 A B C 1 2 7 4 5 6 8 9 3

Vertex hierarchy

Vertex Tree Example

9 8 3 B A

Triangles in active list

R

10 D E 10 A B C 1 2 7 4 5 6 8 9 3

Vertex hierarchy

Vertex Tree Example

8 9 C 3 A B

Triangles in active list

R

10 D 10 A B C 1 2 7 4 5 6 8 9 E 3

Vertex hierarchy

Vertex Tree Example

C 3 B A

Triangles in active list

R

10 D E 10 A B C 1 2 7 4 5 6 8 9 3

Vertex hierarchy

Vertex Tree Example

C E 3 B A

Triangles in active list

R

10 D E 10 A B C 1 2 7 4 5 6 8 9 3

Vertex hierarchy

Vertex Tree Example

E B A

Triangles in active list

R

10 D E 10 A B C 1 2 7 4 5 6 8 9 3

Vertex hierarchy

Vertex Tree Example

E B A D

R

10 D E 10 A B C 1 2 7 4 5 6 8 9 3

Triangles in active list Vertex hierarchy

Vertex Tree Example

E B D

Triangles in active list

R

D E 10 A B C 1 2 7 4 5 6 8 9 3

Vertex hierarchy

Vertex Tree Example

E B

R

D

Triangles in active list

R

D E 10 A B C 1 2 7 4 5 6 8 9 3

Vertex hierarchy

Vertex Tree Example

R

Triangles in active list

R

D E 10 A B C 1 2 7 4 5 6 8 9 3

Vertex hierarchy

The Vertex Tree  At runtime, folds and unfolds create a cut or

boundary

across the vertex tree: This part of the model is represented at high detail This part in low detail

The Vertex Tree: Livetris and Subtris

9

 Two categories of triangles affected:

8 7 8

Fold Node A

2 A 10 6 9 3 3 1

Unfold Node A

4 5 4 5 6 Node->Subtris

: triangles that disappear upon folding

Node->Livetris

: triangles that just change shape

10

The Vertex Tree: Livetris and Subtris  The

key observation

: – Each node’s subtris can be computed offline to be accessed quickly at run time – Each node’s livetris can be maintained at run time, or lazily evaluated upon rendering

View-Dependent Simplification  Any run-time criterion for folding and unfolding nodes may be used  Examples of view-dependent simplification criteria: – Screenspace error threshold – Silhouette preservation – Triangle budget simplification – Gaze-directed perceptual simplification

Screenspace Error Threshold  Nodes chosen by projected area – User sets screenspace size threshold – Nodes which grow larger than threshold are unfolded

Silhouette Preservation  Retain more detail near silhouettes – A

silhouette node

visual contour supports triangles on the – Use tighter screenspace thresholds when examining silhouette nodes

Triangle Budget Simplification  Minimize error within specified number of triangles – Sort nodes by screenspace error – Unfold node with greatest error, putting children into sorted list Repeat until budget is reached

View-Dependent Criteria: Other Possibilities 

Specular highlights

: Xia describes a fast test to unfold likely nodes 

Surface deviation

: Hoppe uses an elegant surface deviation metric that combines silhouette preservation and screenspace error threshold

View-Dependent Criteria: Other Possibilities 

Sophisticated surface deviation metrics:

See Jon’s talk!

Sophisticated perceptual criteria

: See Martin’s talk!

Sophisticated temporal criteria

: See Ben’s talk!

Implementing VDS: Optimizations  Asynchronous simplification – Parallelize the algorithm  Exploiting temporal coherence – Scene changes slowly over time  Maintain memory coherent geometry – Optimize for rendering – Support for out-of-core rendering

Asynchronous Simplification  Algorithm partitions into two tasks: Simplify Task Vertex Tree  Run them in parallel Active Triangle List Render Task

Asynchronous Simplification  If

S

= time to simplify,

R

= time to render: – Single process – Pipelined – Asynchronous = (

S

+

R

) =

max

(

S

,

R

) =

R

 The goal: efficient utilization of GPU/CPU – e.g., NV_FENCE extension for asynchronous rendering

Temporal Coherence  Exploit the fact that frame-to-frame changes are small  Three examples: – Active triangle list – Vertex tree – Budget-based simplification

Exploiting Temporal Coherence  Active triangle list – Could calculate active triangles every frame – But…few triangles are added or deleted each frame – Idea: make only incremental changes to an

active triangle list

 Simple approach: doubly-linked list of triangles  Better: maintain coherent arrays with swapping

Exploiting Temporal Coherence  Vertex Tree – Few nodes change per frame – Don’t traverse whole tree – Do local updates only at

boundary nodes

Unfolded Nodes Boundary Nodes

Temporal Coherence: Triangle Budget Simplification  Exploiting temporal coherence in budget based simplification – Introduced by ROAM [Duchaineau 97] – Start with tree from last frame, recalculate error for relevant nodes – Sort into two priority queues  One for potential unfolds, sorted on max error  One for potential folds, sorted on min error

Temporal Coherence: Triangle Budget Simplification  Then simplify: – While budget is met, unfold max node  This is the node whose folding has created the most error in the model – While budget is exceeded, fold min node  This is the node that introduces the least error when folded – Insert parents and children into queues Repeat until error max < error min

Optimizing For Rendering  Idea: maintain geometry in coherent arrays Active triangles Inactive triangles Unfolded nodes Boundary nodes Inactive nodes

Optimizing For Rendering  Idea: use swaps to maintain coherence Unfolded nodes Boundary nodes A B C D E F G H I Inactive nodes J K L M N O P Q

Fold node D:

Optimizing For Rendering  Idea: use swaps to maintain coherence Unfolded nodes Boundary nodes A B C D E F G H I Inactive nodes J K L M N O P Q

Fold node D:

Swap D with F

Optimizing For Rendering  Idea: use swaps to maintain coherence Unfolded nodes Boundary nodes A B C D E F G H I Inactive nodes J K L M N O P Q

Fold node D:

Swap D with F

Optimizing For Rendering  Idea: use swaps to maintain coherence Unfolded nodes Boundary nodes A B C F E D G H I Inactive nodes J K L M N O P Q

Fold node D:

Swap D with F

Optimizing For Rendering  Idea: use swaps to maintain coherence Unfolded nodes Boundary nodes A B C F E D G H I Inactive nodes J K L M N O P Q

Fold node D:

Move Unfolded/Boundary Marker

Optimizing For Rendering  Idea: use swaps to maintain coherence Unfolded nodes Boundary nodes A B C F E D G H I Inactive nodes J K L M N O P Q

Fold node D:

Deactivate D’s children (swap w/ last boundary node)

Optimizing For Rendering  Idea: use swaps to maintain coherence Unfolded nodes Boundary nodes A B C F E D G H L J K I Inactive nodes M N O P Q

Fold node D:

Deactivate D’s children (swap w/ last boundary node)

Optimizing For Rendering  Idea: use swaps to maintain coherence Unfolded nodes Boundary nodes A B C F E D G H L J K I Inactive nodes M N O P Q

Fold node D:

Deactivate D’s children (swap w/ last boundary node)

Optimizing For Rendering  Idea: use swaps to maintain coherence Unfolded nodes Boundary nodes A B C F E D G H L J K I Inactive nodes M N O P Q

Fold node D:

Deactivate D’s children (swap w/ last boundary node)

Optimizing For Rendering  Idea: use swaps to maintain coherence Unfolded nodes Boundary nodes A B C F E D G K L J H I Inactive nodes M N O P Q

Fold node D:

Deactivate D’s children (swap w/ last boundary node)

Optimizing For Rendering  Idea: use swaps to maintain coherence Unfolded nodes Boundary nodes A B C F E D G K L J H I Inactive nodes M N O P Q

Fold node D:

Deactivate D’s children (swap w/ last boundary node)

Optimizing For Rendering: Vertex Arrays  Biggest win: vertex arrays Unfolded nodes Boundary nodes Inactive nodes Vertex array!

– Actually, keep separate parallel arrays for rendering data (coords, colors, etc)

Optimizing For Rendering: Vertex Arrays on GeForce2 12 Plain old triangles

~64,000 Vertex Torus

vertex arrays Vertex arrays in fast memory 6 4 10 8 2 0 Immediate Mode Display List Vertex Arrays Per-rendering Compiled Vertex Arrays Alw ays Locked Compiled Vertex Arrays VAR Video Memory (no rew rite) Triangles Trianlge Strips Quads VAR AGP Memory (no rew rite) VAR Regular Memory (no rew rite) Quad Strips VAR Video Memory (rew ritten) VAR AGP Memory (rew ritten) VAR Regular Memory (rew ritten)

Out-of-core Rendering  Coherent arrays lend themselves to out of-core simplification and rendering: … These need to be in memory… These do not

Out-of-core Rendering  Coherent arrays lend themselves to out of-core simplification and rendering: – Only need active portions of triangle and node arrays – Implement arrays as memory-mapped files  Let virtual memory system manage paging  A prefetch thread walks boundary nodes, bringing their children into memory to avoid glitches

Summary: VDS Pros 

Supports drastic simplification!

– View-dependent; handles the Problem With Large Objects – Hierarchical; handles the Problem With Small Objects – Robust; does not require (or preserve) mesh topology

Summary: VDS Pros  Rendering can be implemented efficiently using vertex arrays  Supports rendering of models much larger than main memory

Summary: VDS Cons  Increases CPU, memory overhead  Hard to map efficiently onto GPU for efficient utilization

Summary: VDS Cons  Be aware of

mesh foldovers:

7 8 2 6 10 9 3 1 4 5

Summary: VDS Cons  Be aware of

mesh foldovers:

7 8 2 9 3 1 A 6 10 4 5

Summary: VDS Cons  Be aware of

mesh foldovers:

8 2 A 6 10 9 3 4 5

Summary: VDS Cons  Be aware of

mesh foldovers:

– These can be very distracting artifacts – Can prevent them at run-time  Add a normal-flipping test to fold criterion  Use a clever numbering scheme proposed by El Sana and Varshney

View-Dependent Versus Discrete LOD  View-dependent LOD is superior to traditional discrete LOD when: – Models contain very large individual objects (e.g., terrains) – Simplification must be completely automatic (e.g., complex CAD models) – Experimenting with view-dependent simplification criteria

View-Dependent Versus Discrete LOD  Discrete LOD is often the better choice: – Simplest programming model – Reduced run-time CPU load – Easier to leverage hardware:  Compile LODs into vertex arrays/display lists  Stripe LODs into triangle strips  Optimize vertex cache utilization and such

View-Dependent Versus Discrete LOD  Applications that may want to use: – Discrete LOD  Video games (but much more on this later…)  Simulators  Many walkthrough-style demos – Dynamic and view-dependent LOD  CAD design review tools  Medical & scientific visualization toolkits  Terrain flyovers (much more later…)

Continuous LOD: The Sweet Spot?

 Continuous LOD may be the right compromise on modern PC hardware – Benefits of fine granularity without the cost of view-dependent evaluation – Can be implemented efficiently with regard to  Memory  CPU  GPU

VDSlib  Implementation:

VDSlib

– A public-domain view-dependent simplification and rendering package – Flexible C++ interface lets users:  Construct vertex trees for objects or scenes  Specify with callbacks how to simplify, cull, and render them – Available at

http://vdslib.virginia.edu

VDSlib: Ongoing Work  Ongoing research projects using view dependent simplification: – Out-of-core LOD for interactive rendering of

truly

massive models – Perceptually-guided view-dependent LOD, including gaze-directed techniques – Non-photorealistic rendering using VDSlib as a framework