CSL 859: Advanced Computer Graphics
description
Transcript of CSL 859: Advanced Computer Graphics
CSL 859: CSL 859: Advanced Advanced Computer Computer GraphicsGraphicsDept of Computer Sc. & Engg.Dept of Computer Sc. & Engg.
IIT DelhiIIT Delhi
MeshMesh List of trianglesList of triangles
Each is a triplet of VerticesEach is a triplet of Vertices Each is an array of attributesEach is an array of attributes
Euler’s relation:Euler’s relation: V + F -2 = EV + F -2 = E
Adjacency listAdjacency list List of verticesList of vertices List of “pointers”List of “pointers” A vertex referred ~6 times (closed model)A vertex referred ~6 times (closed model)
Vertex & TopologyVertex & Topology
A
G
F
B
CD
E
..A..
..B..
..C..
..D..
..E..
..F..
Vertex AttributesVertex Attributes
TopologyTopology0 1 51 3 51 2 35 3 46 5 40 5 6What order What order
should we should we choose?choose?Post vertex shader cachePost vertex shader cache
Triangle StripTriangle Strip
A
G
F
B
CD
E
..A..
..B..
..C..
..D..
..E..
..F..
Vertex AttributesVertex Attributes
TopologyTopology
ABFDEAFGEBCD
Can we turn any Can we turn any given model into a given model into a single strip?single strip?
Would that eliminate Would that eliminate the need for storing the need for storing topology?topology?
Post Shader CachePost Shader Cache Perfect Triangle Strip of n triangles =>Perfect Triangle Strip of n triangles =>
1 new vertex per triangle1 new vertex per triangle n-2 cache missesn-2 cache misses
Can we do better?Can we do better? Euler’s law: V + F = E + 2Euler’s law: V + F = E + 2 V ~ 0.5F (E = 1.5F for closed model)V ~ 0.5F (E = 1.5F for closed model)
Yes (Ideal: 0.5verts/triangle)Yes (Ideal: 0.5verts/triangle) [Chhugani & Kumar, I3D 2007][Chhugani & Kumar, I3D 2007]
Vertex ArraysVertex Arrays Array of structuresArray of structures
Better triangle localityBetter triangle locality
Structure of arraysStructure of arrays Better shader localityBetter shader locality
V0x y z u v a b c
x0 x1 x2 x3
V1x y z u v a b c
y0 y1 y2 y3
Half-Edge Data StructureHalf-Edge Data StructureVertex ListVertex List Face ListFace List Edge ListEdge List
..V0..
..V1..
..V2..
..V3....
E0 E2 E1E5 E4 E3
.
.
V0 V1, F0, E1 E2, E5 ..
V1 V0, F1, E3 E4, E0 ..
E0
E3
E4
E2
E1 V0
V1
F0F1
E5
Winged-Edge Data Winged-Edge Data StructureStructure
Vertex ListVertex List Face ListFace List Edge ListEdge List..V0.., E0..V1.., E0..V2.., E1..V3.., E4
.
.
E0E4..
V0 V1, F0 F1, E1 E2, E3 E4 ..
E0
E3
E4E2
E1V0
V1
F0
F1Edge is oriented based on one of its faces: left or right
Mesh SimplificationMesh Simplification
courtesy H. HoppeIdeally, the change is incremental
Nominal FrameworkNominal Framework Pre-processingPre-processing
Create and store levels in a data-Create and store levels in a data-structurestructure
Rendering timeRendering time Decide the appropriate detailDecide the appropriate detail
Coarse or fine-grainedCoarse or fine-grained Output count or approximation errorOutput count or approximation error
Traverse DS to generate that detailTraverse DS to generate that detail RenderRender
Competing GoalsCompeting Goals Computational EfficiencyComputational Efficiency
Some pre-processingSome pre-processing Storage EfficiencyStorage Efficiency QualityQuality
Error metricsError metrics screen space screen space vsvs object space object space Geometry, attributes, appearanceGeometry, attributes, appearance
Global Global vsvs local optimization local optimization local may be fasterlocal may be faster global may generate closer approximationsglobal may generate closer approximations
AttributesAttributes ColorColor Normal VectorsNormal Vectors Texture CoordinatesTexture Coordinates CurvatureCurvature Material PropertiesMaterial Properties
Topology ConsiderationsTopology Considerations Manifold Manifold vsvs non-manifold non-manifold Topology preservationTopology preservation
important in some areasimportant in some areas if topology is changed, then we can:if topology is changed, then we can:
close holes in objectsclose holes in objects join disconnected componentsjoin disconnected components
Shape and attribute Shape and attribute appearanceappearance more more important than topologyimportant than topology
Possible Algorithm?Possible Algorithm? Subdivide space into cellsSubdivide space into cells Choose a vertex to represent each Choose a vertex to represent each
cellcell For each pair of cellsFor each pair of cells
If two vertices in two cells have an edgeIf two vertices in two cells have an edge Connect the representative vertices Connect the representative vertices
Borel, Rossignac [1993]Borel, Rossignac [1993]
Reduce Geometry CountReduce Geometry Count Remove a vertexRemove a vertex
That leave a holeThat leave a hole Retriangulate the holeRetriangulate the hole
Schroeder et al., 1992Schroeder et al., 1992
Simple OperationSimple Operation Collapse edges, one at a timeCollapse edges, one at a time
vvll vvrr
vvtt
vvss
ecol(vecol(vs s ,v,vt t , , vvss ))’’
vvssvvll vvrr’’
SimplificationSimplification
13,54613,546 500500 152152 150150
MM00MM11MM175175
ecolecol00ecolecoliiecolecoln-1n-1
M=MM=Mnn^̂
courtesy H. Hoppe
Inverse?Inverse?
vvll vvrr
v’v’tt
v’v’ssvvss
vvll vvrr
vspl(vvspl(vs s ,v,vl l ,v,vr r , , vvss ,,vvtt ,…),…)’’ ’’parametersparameters
ReconstructionReconstruction
150150
MM00 MM11
vsplvspl00
152152
MM175175
500500
… … vsplvsplii … …
13,54613,546
vsplvspln-1n-1
MMnn=M=M̂̂
Progressive Mesh (PM)Progressive Mesh (PM) representation representation
MMnn=M=M̂̂
courtesy H. Hoppe
Continuous LODContinuous LODFrom PM, extract From PM, extract MMii of any size of any size
MM00 vsplvspl00 vsplvspl11 vsplvspli-1i-1 vsplvspln-1n-1
MMii
3,478 faces?3,478 faces?3,4783,478
MM00 MMnn=M=M̂̂MMii
courtesy H. Hoppe
Vertex CorrespondenceVertex CorrespondenceMMnn MM00
MMccMMff
vv11vv22vv33vv44vv55vv66vv77vv88
vv11vv22vv33
MMf-1f-1
vv11vv22vv33vv44vv55vv66vv77
ecolecol
MMf-2f-2
vv11vv22vv33vv44vv55vv66
ecolecol ecolecol
courtesy H. Hoppe
Space OverheadSpace Overhead
Attrib deltas:Attrib deltas:vvtt - v - vss
vvs s - v- vss
……
’’’’vvll vvrr
v’v’tt
v’v’ss
vspl(vvspl(vs s ,v,vl l ,v,vr r , , vvss ,,vvtt ,…),…)’’ ’’
vvssvvll vvrr
Topology:Topology: Index of vIndex of vss Pair of index offsetsPair of index offsets
Selective RefinementSelective Refinement
MM00 vsplvspl00 vsplvspl11 vsplvspli-1i-1 vsplvspln-1n-1
courtesy H. HoppeWhat’s the problem?What’s the problem?
Parent-Child Parent-Child CorrespondenceCorrespondence
vvss
vvttvvuu
vsplitvsplit
vv22
Vertex HierarchyVertex Hierarchyvsplvspl00MM00 vsplvspl11 vsplvspl22 vsplvspl33 vsplvspl44 vsplvspl55
vv11 vv33MM00
vv1010 vv1111
vsplvspl33
vv11 vv22
vv44 vv55
vsplvspl00
vv88 vv99
vsplvspl22
vv33
vv66 vv77
vsplvspl11
vv55
vv1212 vv1313
vsplvspl44
vv1010
vsplvspl55
vv1414 vv1515
vv66
PM:PM:
MMnn
[Xia & Varshney 96]
MM00
vsplvspl22
vv1111
vv11 vv22
vv44 vv88 vv99
vv33
vv77
vv55
vv1212 vv1313
vv1010
vv1414 vv1515
vv66
vv22
Selective RefinementSelective Refinementvsplvspl00MM00 vsplvspl11 vsplvspl33 vsplvspl44 vsplvspl55
vv11 vv33MM00
vv1010 vv1111
vsplvspl33
vv11 vv22
vv44 vv55
vsplvspl00
vv66 vv77
vsplvspl11
vv55
vv1212 vv1313
vsplvspl44
vv1010
selectively refined meshselectively refined mesh
vv88 vv99
vsplvspl22
vv33
vv88 vv99
vsplvspl22
vv33
Restrictions?Restrictions?
DependenciesDependencies
vsplitvsplit
ecolecol vsplitvsplit legal if legal if vvss, , vvll , and , and vvrr present present ecolecol legal if local neighbors present legal if local neighbors present
vvll vvrr
v’v’tt
v’v’ss
vvssvvll vvrr
[Xia & Varshney 96]
ConsistencyConsistencyvsplitvsplit
ecolecol
ffn1n1
ffn0n0
vvss
ffn3n3
ffn2n2
vsplitvsplit legal if: legal if:vvss is active is activeffn0n0,f,fn1n1,f,fn2n2,f,fn3n3 are active are active
ecolecol legal if: legal if:v’v’ss,v’,v’tt are active are activeffn0n0,f,fn1n1,f,fn2n2,f,fn3n3 are adjacent are adjacent
ffn1n1
ffn0n0v’v’tt
ffn3n3
ffn2n2
v’v’uu
[Hoppe 97]
Rendering AlgorithmRendering Algorithm Start with the active Start with the active frontfront in previous in previous
frame.frame. Exploits frame coherenceExploits frame coherence
For each vertex, decided For each vertex, decided refinerefine or or coarsencoarsen If legal, perform operation, otherwise:If legal, perform operation, otherwise:
Make vertex split legal by generating necessary Make vertex split legal by generating necessary verticesvertices
Leave Edge collapses aloneLeave Edge collapses alone Amortize?Amortize?
At each frame apply only a fraction of the At each frame apply only a fraction of the eligible opseligible ops
previous meshprevious mesh
vv55vv1010 vv1111 vv44 vv88 vv99
vv77vv1212 vv1313
vv11 vv22 vv33
Rendering AlgorithmRendering Algorithm
MM00
vv66
vv1414 vv1515
vv1212 vv1313vv1212
vv1010 vv1111vv1010 vv1111 vv44vv44
vv66
vv1414 vv1515
vv66
vv1414 vv1515
vv88 vv99
vv33
vv1515
vv77vv77
vv88vv88 vv99vv99
new meshnew mesh
dependencydependency
vv1111vv1010 vv44
vv1414 vv1515
vv77
vv88 vv99
LOD AlgorithmsLOD Algorithms Simplification operatorSimplification operator Where should it be appliedWhere should it be applied
No optimizationNo optimization e.g., uniform grid cellse.g., uniform grid cells
Greedy optimizationGreedy optimization Sort edge collapses by errorSort edge collapses by error
Re-insert modified edges after each stepRe-insert modified edges after each step Lazy optimizationLazy optimization
Re-insert a modified edge only when in frontRe-insert a modified edge only when in front Local Local vsvs Global optimization Global optimization
Error MetricError Metric Preserve Preserve appearanceappearance::
Geometric shapeGeometric shape Scalar fieldsScalar fields (e.g. color) (e.g. color) Discontinuity curvesDiscontinuity curves
E e e dA e dLshape scalars disc ( ) ( )face areas disc. edges
pointspoints pointspoints
courtesy H. Hoppe
Measuring ErrorMeasuring Error Geometric errorGeometric error
DistanceDistance between the original and between the original and simplified surface?simplified surface?
Volume Volume between the surfaces?between the surfaces? Visual errorVisual error
Color, normal, & texture distortionColor, normal, & texture distortion Silhouettes, background illuminationSilhouettes, background illumination SemanticsSemantics Many othersMany others
Measuring Geometric Measuring Geometric ErrorError
Surface-surfaceSurface-surface Hausdorff distanceHausdorff distance
Vertex-surface vs Vertex-surface vs Vertex-planeVertex-plane Vertex-vertexVertex-vertex Average distance or Max distanceAverage distance or Max distance
Quadric ErrorQuadric Error [Garland & Heckbert] 1998[Garland & Heckbert] 1998 Measure error by deviation from shapeMeasure error by deviation from shape
Vertices are at intersection of planesVertices are at intersection of planes
Do not collapse edgesDo not collapse edges Merge verticesMerge vertices
v’v’tt
v’v’ss
Quadric Error MetricQuadric Error Metric Plane equation for a face:Plane equation for a face:
0 :p DCzByAx
1zyx
DCBAT vp
Distance to vertex Distance to vertex vv : :
Distance to vertex Distance to vertex vv : :
)(
2 )()(vplanesp
T vpv
)(
))((vplanesp
TT vppv
)(
)(vplanesp
TT vppv vppvvplanesp
TT
)(
Quadric Error (cont’d)Quadric Error (cont’d)
Sum over all planes intersecting at vSum over all planes intersecting at v Call it Call it Q, the quadric errorQ, the quadric error
vvQQvvvv TT ))((
2
2
2
2
DCDBDADCDCBCACBDBCBABADACABA
ppT
Maintain quadric Q for every vertexMaintain quadric Q for every vertex Assign Edge QuadricsAssign Edge Quadrics
Q1 Q2
v2v1
Sort edges based on quadric errorSort edges based on quadric error Need position of resulting vertexNeed position of resulting vertex
One of original vertices or mid-point?One of original vertices or mid-point?
21 QQQ
Quadrics Based Quadrics Based SimplificationSimplification
vvQQvvvv TT ))((
Optimal Vertex Optimal Vertex PlacementPlacement
Minimize Q to calculate optimal Minimize Q to calculate optimal coordinates for placing new vertexcoordinates for placing new vertex
1000
1000
1
34332313
24232212
14131211
qqqq
qqqq
qqqq
V
Boundary PreservationBoundary Preservation Label boundariesLabel boundaries Form boundary plane perpendicular Form boundary plane perpendicular
to faceto face Convert planes into quadricsConvert planes into quadrics Weighted sum of quadricsWeighted sum of quadrics
Scale border plane quadric higherScale border plane quadric higher
Preventing Mesh Preventing Mesh InversionInversion
Preventing foldovers:Preventing foldovers:
Adjacent face normals should not flipAdjacent face normals should not flip Disallow foldover, or simply weight Disallow foldover, or simply weight
heavilyheavily
10
54
6
13
2
9 A
78
10
54
63
28
9 A
merge
Quadric Error MetricQuadric Error Metric Pros:Pros:
Reasonably fastReasonably fast Good fidelity even for drastic reductionGood fidelity even for drastic reduction Robust -- handles non-manifold surfacesRobust -- handles non-manifold surfaces Aggregation -- can merge objectsAggregation -- can merge objects
Cons:Cons: Introduces non-manifold surfacesIntroduces non-manifold surfaces User controls virtual-edge collapse thresholdUser controls virtual-edge collapse threshold
Increased running time due to search for potential pairsIncreased running time due to search for potential pairs Correct value varies with model densityCorrect value varies with model density
Needs extension to handle color (7x7 matrices)Needs extension to handle color (7x7 matrices)
Result – Bunny ModelResult – Bunny Model
69,451 triangles
1,000 triangles
100 triangles1.4% of original
size0.14% of original size
courtesy Garland, Heckbert
Result – Terrain ModelResult – Terrain Model
199,114 faces
999 faces (46 secs)
courtesy Garland, Heckbert
Method ComparisonMethod Comparison
Original model
Uniform Vertex Clustering
Edge Contractions
Pair Contractions
(4,204 faces)
(262 faces)
(250 faces)
(250 faces)courtesy Garland, Heckbert
Image-Driven Image-Driven SimplificationSimplification
[Lindstrom & Turk 2000][Lindstrom & Turk 2000] Compare simplifications Compare simplifications
to original to original via imagesvia images Collapse edgeCollapse edge Render from many viewsRender from many views Evaluate difference (Evaluate difference (need need
image metricimage metric)) ““Unrender” and retryUnrender” and retry Pick cheapest and applyPick cheapest and apply
Image-Driven Image-Driven SimplificationSimplification
Pros: Pros: Preserves appearancePreserves appearance Does not need to trade off geometric Does not need to trade off geometric
error against attribute errorerror against attribute error Shading artifacts accounted forShading artifacts accounted for Side effects:Side effects:
Drastically simplifies invisible regions!Drastically simplifies invisible regions!
Image-Driven Image-Driven SimplificationSimplification
Cons:Cons: VeryVery slow slow Still many examples that breaks it:Still many examples that breaks it:
Hard to know how many images is enoughHard to know how many images is enough Hard to know how to evaluate images (RMS Hard to know how to evaluate images (RMS
vs vs Bolin-Meyer)Bolin-Meyer)
Screen Space ErrorScreen Space Error Depends on location and orientation Depends on location and orientation
of error vectorof error vector We don’t even store error vectorsWe don’t even store error vectors
Screen Space ErrorScreen Space Error
θ
y/z
y,zy+ε sin θz+ε cos θ ε
εs
y+ε sin θz+ε cos θ y/zεs =
Eye
ImagePlane
Screen Space ErrorScreen Space Error
)2
tan(2 22
z
drzdp
r
LOD
eye
viewingplane
p
d
Appearance PreservationAppearance Preservation
Preserve three appearance Preserve three appearance attributes:attributes: Surface PositionSurface Position Surface CurvatureSurface Curvature Material ColorMaterial Color
Each may require different samplingEach may require different sampling
Normals Normals UndersampledUndersampled
13,433 triangles 1,749 triangles10 pixels of surface deviation
Normals Properly Normals Properly SampledSampled
13,433 triangles 1,749 triangles, 10 pixels of deviation
v1, c1, n1
v = vertex coordinate = (x,y,z)c = color = (r,g,b)n = normal = (nx,ny,nz)
v2, c2, n2
v3, c3, n3
RecallRecall
Filters surface Filters surface position, colors, position, colors, and normalsand normals
Must filter all Must filter all three three equallyequally
texture map
normal map
v1, t1
v2, t2
v3, t3
v = vertex coordinate = (x,y,z)t = texture coordinate = (u,v)c = color = (r,g,b)n = normal vector = (nx,ny,nz)
c1
c2c3
n1
n2n3
Decoupled Decoupled RepresentationRepresentation
Decoupled ApproachDecoupled Approach
Simplification filters surface Simplification filters surface position and texture coordinatesposition and texture coordinates
Color and normal attributes filtered Color and normal attributes filtered per-pixel (mip-mapping, etc.)per-pixel (mip-mapping, etc.)
Sample Normal MapSample Normal Map
polygonal surface patch normal map
xx
Texture Deviation MetricTexture Deviation Metricmesh Mmesh Mii mesh Mmesh Mi+1i+1
2D texture domain2D texture domain
(i+1)(i+1)stst edge collapse edge collapse
XXii XXi+1i+1
ei,i+1(x) = || xi+1 - xi ||
Ei,i+1 = max ei,i+1(x) xP
P
New Texture CoordinatesNew Texture Coordinates
Invalid texnew Valid choices lie in convex kernel
Texture Deviation ErrorTexture Deviation Error
X
||))((||)( 10 XTTXXE ii
Texture Space
APS Levels-of-detailAPS Levels-of-detail
courtesy J. Cohen
7,809 tris
3,905 tris
1,951 tris
975 tris
488 tris
TerrainsTerrains Uniform array of height valuesUniform array of height values
May encode in raster formats (DEM, May encode in raster formats (DEM, GeoTIFF)GeoTIFF)
Store Z instead of colorStore Z instead of color Easy to interpolate to find elevationsEasy to interpolate to find elevations Easy view cullingEasy view culling There also are TINsThere also are TINs
Triangulated Irregular NetworksTriangulated Irregular Networks
TINsTINs
Fewer polygons neededFewer polygons needed Adaptively sampledAdaptively sampled Precisely model maxima, minima, Precisely model maxima, minima,
ridges, valleys, overhangs, cavesridges, valleys, overhangs, caves
LOD Hierarchy LOD Hierarchy StructuresStructures
QuadTree Hierarchy
BinTree Hierarchy
QuadtreesQuadtrees Each quad is actually two trianglesEach quad is actually two triangles Produces cracks and T-junctionsProduces cracks and T-junctions But simpleBut simple
BintreesBintrees
Binary Triangle tree Binary Triangle tree Right triangular irregular networks Right triangular irregular networks
(RTIN)(RTIN) longest edge bisectionlongest edge bisection
Easier to avoid cracks and T-Easier to avoid cracks and T-junctionsjunctions
Neighbor must be at adjacent levelsNeighbor must be at adjacent levels
Cracks and T-JunctionsCracks and T-Junctions
Avoid cracks:Avoid cracks: Convert cracks into T-junctionsConvert cracks into T-junctions Fill cracks with extra trianglesFill cracks with extra triangles
Avoid T-junctions:Avoid T-junctions: Continue to simplify ...Continue to simplify ...
Bin-tree and T-junctionBin-tree and T-junction
Terrain as a PyramidTerrain as a Pyramid
Coarsest Level
Finest Level
•Terrain as mipmap pyramid
•LOD using nested grids
[Losasso & Hoppe 2005]
Geometry Clip MapsGeometry Clip Maps Transition regionTransition region
Insert “0 area” trianglesInsert “0 area” triangles Damp refined vertices as they get close Damp refined vertices as they get close
to the coarser levelto the coarser level
Geometry Clip MapsGeometry Clip Maps Transition regionTransition region
Insert 0 area trianglesInsert 0 area triangles Damp refined vertices as they get close Damp refined vertices as they get close
to the coarser levelto the coarser level
Texture Mapping PMTexture Mapping PM [Sander et al, 2001][Sander et al, 2001]