cpsc 695 mesh optimization -...

48
CPSC 695 Mesh Optimization Marina L. Gavrilova

Upload: others

Post on 24-Oct-2019

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

CPSC 695

Mesh OptimizationMarina L. Gavrilova

Page 2: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Brief Outline

Mesh Generation ApplicationsMesh OptimizationDynamic MeshesApplications

Page 3: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Terminology

DEM: Digital Elevation ModelViewer Dependent RefinementROAM: Realtime Optimally Adapting MeshCLOD: Continuous Level of Detail

Page 4: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

What is mesh?It is often required to convert geometric objects in any other form to polygonal meshes of geometric simplexes (i.e. triangles) before renderingMeshes are used for computer modeling, biometric, GIS, cartographic, and animation applicationsMesh optimization techniques are used to reduce the mesh to an acceptable size (user defined), minimizing the loss of quality (subject to some form of error analysis).

Page 5: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Mesh definition

A mesh is defined as a pair (V,K) where V is the set of vertices and K is a simplicialcomplex specifying the connectivity of the mesh simplices (the adjacency of the vertices, edges and faces) [Hoppe].The 0-simplices are called vertices, the 1-simpices are called edges, and the 2-simplices are called faces. Triangulation is an example of mesh.

Page 6: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Example: 3D Terrain Rendering

• Uses DEM as input of the application

•Generates dynamic mesh to achieve frame coherent animated view in real-time

Page 7: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Mesh Optimization GoalsFor an arbitrary point (u,v) in the surface each goal contributes an

energy component to the energy function. The energy function E is defined as the weighted sum of all energy components where each corresponding weight pi is the priority of the energy component Ei:

In most optimization problems, the shape preservation is a majorgoal. Therefore, surface curvature index plays a significant role in the optimization process due to the fact that a curved surface requires greater number of simplexes compared to a planar (or less curved) surface to accommodate the same level of visual detail.

( , ) ( , )i iE u v p E u v= ∑

Page 8: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Mesh optimization problemsThere are three major categories for mesh optimization

problems:A fully detailed geometric mesh exists and the task is to

find an optimized mesh under the specified energy function and satisfying a user-defined level of detail (i.e. specified number of vertices).

A fully detailed geometric mesh exists and one has to find a hierarchical representation for rendering in dynamic multiple levels of detail (MLOD).

A surface is defined as a parametric function. One has to find an approximate mesh representation of that surface under specified goals and constraints in a framework for dynamic real-time continuous level of detail (CLOD).

Page 9: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Mesh optimization

Mesh optimization is the process of reducing a mesh M to a mesh M0, where M0contains less number of vertices and geometric primitives (i.e. triangles) than M. The goal is to find such mesh M0 that the no other mesh exists, which represent a better approximation of the mesh M0.

Page 10: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Methods for mesh optimization

Mesh optimization can be considered as is a compression method for geometric models with large details. In computer graphics, various processes are utilized such as:

regular tessellations,polygonized spline surfaces, polygonized parametric surfaces, polygonized implicit surfaces,range scanned surfaces and subdivision surfaces.

Page 11: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Basic ApproachThe entire optimization process can be viewed as an optimal spatial subdivision problem. There exist only two legal moves to achieve optimality: subdivide and merge. Models that are based on this concept do not require computationally extensive optimization process. Instead, the mesh progressively adapts to an optimal solution. These models usually define a multi-criteria based error metric to assess the energy of the mesh. Error metrics are more flexible than energy functions in a sense that they are capable of assessing an intermediate mesh both at a local and a global level.

Page 12: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Dynamic mesh conceptAt any given stage, one of the two following courses of action is chosen: subdivide or merge. If the number of vertices reaches the upper limit, details are reduced on the regions assessed with the lowest error contribution. At the same time, whenever the vertex count becomes lower than the upper limit, details are expanded on the region assessed with the highest error contribution. This greedy approach allows the intermediate mesh to optimally adapt to the minimal energy configuration, satisfying the specified set of constraints. This is the fundamental basis for a dynamic mesh algorithm.

Page 13: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Real-time terrain renderingUses a graphics Engine/LibraryCentral focus on efficient mesh representationView coherence and frame rate constancyLimited/Variable Level of DetailSpeed optimizationRepresenting layer data as textures or particles

Page 14: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Advantages of static modelsThere are various static mesh models used in GIS applications and computer games. They are regular tessellation, DelaunayTriangulation (DT) [ref], Triangulated Irregular Network (TIN). They provide the following advantages:

Well-known and well understood modelsEasy to implementOptimization is performed only once, so rendering application is simple to designEfficient for small scale objects

Page 15: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Disadvantages of static modelsDuring rendering of massive terrain or other GIS data:

Most of the geometry of a terrain is outside the view frustum due to its massive size. Static methods waste a lot of CPU cycles trying render the entire object. Although the enormous amount of detail is stored in memory for the entire object the visible area might constitute a tiny fraction of that detail. Consequently, static models are highly inefficient for terrain modeling.Viewpoint dependent refinement is not possible with static meshes. Have a bad triangle to screen pixel ration.Unable to obtain a steady performance.

Page 16: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Understanding Height FieldsDEM: Digital Elevation Model

• Contains only relative Height

• Regular interval

• Pixel color determine height

•Discrete resolution

Page 17: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Dynamic meshDynamic mesh generation is based on real-time adaptive models that allow local transformation of a given mesh to different levels of details and adapt progressively to the changes in the rendering environment. Dynamic models use some form of hierarchical data structure to store a mesh in multiple LOD.There are many different versions of dynamic mesh currently under research and development. Several patented technologies have been released in the industry (i.e. Intels MRM). The two most prominent approaches are Progressive Meshes (PM) and Real-time Optimally Adapting Mesh (ROAM).

Page 18: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

PM vs. ROAM

PM can be seen as a bottom up approach where as ROAM is a top-down approach. PM starts with an arbitrary mesh in maximum detail. It requires a massive amount of computation for the generation of the multi resolution hierarchical data structure representing the mesh at different LOD.ROAM starts with a simple mesh and refines detail in real-time during the rendering cycle.

Page 19: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Converting Height field data into 3D topological mesh

200 255 150 100

100 255 255 200

200 150 200 100

• Pixel value (z) is used as Height Map

• Vertices are generated as points in 3D

• A Mesh is triangulated

Page 20: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Mesh Representation

Goals:

Speed

Quality

Constancy

Representations:

Progressive Meshes

ROAM: Real-time Optimally Adapting Mesh

Page 21: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Progressive MeshesDeveloped by Hugues Hoppe, Microsoft Research Inc. Published first in SIGGRAPH 1996.

Page 22: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

How PM works…

Page 23: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

ROAM :•Can Subdivide when more details necessary

•Merge & Split Queue

•Tree Structured

Page 24: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

ROAM advantagesReal-time Optimally Adapting Mesh is an efficient top-down dynamic mesh model. In this model, real-time display of complex surfaces can be provided by dynamically computing a multi-resolution triangular mesh for each view.One can minimize geometric distortions on the screen while maintaining a fixed triangle count. Visual discontinuities could be minimized in several ways, and efficient mesh corrections can ensure selected lines of site, or object proximity are correctly represented.An incremental priority-queue based approach in ROAM allows exploiting frame-to-frame coherence for fast efficient computation of the adapting mesh.

Page 25: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Geometric subdivision

Problems with Geometric Subdivisions

Page 26: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

ROAM principle

The basic operating principle of ROAM

Page 27: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Quadtree and Bintree for ROAM

Comparison between Quadtree (top) and Bintree (bottom)

Page 28: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

ROAM Implementation and Improvements

Pre-process DEMReduce overhead for maintaining Split queueUse degenerated split queueReplace priority merge queue (HEAP) with a simple FIFO queue.Merge arbitrary obscured regions (outside visible frustum) only

Page 29: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Preprocessing of DEM input

Convolute the surface (2nd Difference)Efficient LOD distributionUsed in Advanced Shading (feature preservation)

Page 30: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Differentiating the Surface: Convolution

Original DEM of Kluane Park First differentiation. Blue area Shows steep mountains.

Final LOD distribution image Shows rocky areas require more details

Second Differentiation. Blue areas indicate steep mountain peaks.

Page 31: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Differentiating the Surface (cont’d)…

Take Weighted Average of neighboring pixel Gradients

2 passes gives us the rate of gradient changes

Page 32: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Statistical Analysis of ROAM

Bottleneck: Split and Merge Operation and visibility testOnly 2.7% triangles are merged within the visible frustum75% of split operations occurs on closest 5% region of the visible frustum

Page 33: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Proposed Priority Function for Split QueueDetermines RefinementDistribute LOD to preferred areaCan be changed

f=face, C=Camera U=Uniformity F=Frustum priorityD=Curvature priorityP=Distance priorityDET=Curvature (preprocessed)Lev(f)=Subdivision level of face f

( )UfLevCfCenterPfCenterDETDCfAngularityF

Cfiority)(1

)())((),(),(Pr

+

−×+×+×=

Page 34: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Speeding up the processAmortizing refinement

Updating the Split queue over multiple framesAllow split queue (heap) to degenerateRefine integrity using error threshold testRe-generate queue after constant number of framesDramatic gain in speed

Page 35: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Maintaining Degenerated S-Queue

Page 36: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Understanding Geo-MorphSmooth interpolation of vertex over subdivision

Requires maintenance of one additional queue (G-queue)

Page 37: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

SmoothingCompute face normal Compute vertex normalLocal computation of normal during refinement (Geo-Morph)Apply vertex normal when renderingAdvanced shading: Linear combination of face and vertex normal (Hybrid)

Page 38: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Example of smoothing

Page 39: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Texturing

Compute uv coordinate during creation of each vertex (planar transform)

Load texture bitmap in the pipeline

Apply texture handle

Page 40: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Result with Texturing

Page 41: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Results (Output obtained)

Page 42: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Results (Runtime)Rendered Frame VS Time

020406080

100120140160180200

1 18 35 52 69 86 103

120

137

154

171

188

205

222

239

256

273

Frame

Tim

e of

Sim

ulat

ion

Page 43: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Results (Runtime) (Cont’d)Frames Per Second

0102030405060708090

100

0 50 100 150 200

Time of Simulation

FPS

Page 44: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Results (Runtime) (Cont’d)Mesh Face Counts

0

5000

10000

15000

20000

25000

0 50 100 150 200

Time of Simulation

Num

ber o

Fac

es

ROAM Face Rendered Faces

Page 45: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Results (Runtime) (Cont’d)

Geo Morph Load

0

100

200

300

400

500

0 50 100 150 200

Time of Simulation

# of

Ver

tices

in G

eo-m

oprh

Page 46: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Summary of Results

High Speed (45 FPS average)Continuity is achieved (Geo-Morph) Visual appeal (smoothing & Texture)Less variant Frame rateEfficient Understructure (amortized update)

Page 47: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Other Applications

Motion PlanningSpatial-Temporal AnalysisMassive Terrain RenderingComputer Games

Page 48: CPSC 695 Mesh Optimization - pages.cpsc.ucalgary.capages.cpsc.ucalgary.ca/~marina/601/Lecture_terrain.pdf · Mesh Optimization ... Example: 3D Terrain Rendering • Uses DEM as input

Next: Photo Realistic 3D Terrain