Ray Tracing II - PowerPoint PPT Presentation

About This Presentation
Title:

Ray Tracing II

Description:

Geometric Modeling CS148 Lecture 6 Just use Old and New Notion of approximating and interpolating Also, how do you derive these weights? Special case analytical ... – PowerPoint PPT presentation

Number of Views:64
Avg rating:3.0/5.0
Slides: 58
Provided by: PatHan3
Category:

less

Transcript and Presenter's Notes

Title: Ray Tracing II


1
CS148 Introduction to Computer Graphics and
Imaging Geometric Modeling
CS148 Lecture 6
2
Data Structures for Triangle Mesh
CS148 Lecture 6
3
Data Structure Separate Triangles
  • Treat each triangle separately with its own
    vertices
  • typedef float Point3
  • struct Face
  • Point v3
  • mesh FacenFaces
  • Storage 72 bytes per vertex
  • No notion of neighbor triangles Individual
    triangles might not overlap with their vertices
    or edges

f.v0
f
f
f.v1
f.v2
CS148 Lecture 6
4
Data Structure Indexed Triangle Set
  • Store each vertex only once each face contains
    indices to its three vertices
  • typedef float Point3
  • struct Face
  • int vIndex3
  • mesh.vertsPointnVerts
  • mesh.facesFacenFaces
  • Storage 12 (verts) 24 (faces) 36 bytes per
    vertex (approximate using f 2 v)
  • By removing vertex redundancy we have a notion of
    neighbor. However, finding a specific neighbor
    requires a global search.

v3
v0
f
f
v1
v2
CS148 Lecture 6
5
Comparison
  • Separate Triangles (Vertex Buffer only)
  • Simple
  • Redundant information
  • Indexed Triangle Set (Vertex Buffer Index
    Buffer)
  • Sharing vertices reduces memory usage
  • Ensure integrity of the mesh (moving a vertex
    causes that vertex in all the polygons to
    be moved)
  • Both formats are compact and directly accepted
    by GPUs
  • Both can represent non-manifold meshes
  • Neither is good at neighborhood
    access/modification

CS148 Lecture 6
6
Recall Calculating Normals at Vertices
  • for f in mesh.faces()
  • (v1, v2, v3) f.ccwVertices()
  • f.N cross(v2-v1,v3-v1)
  • if !areaWeighted f.N.normalize()
  • for v in mesh.verts()
  • v.N 0
  • for f in v.faces()
  • v.N f.N
  • v.N.normalize()

For Indexed Triangle Set, this takes O(F) time!
CS148 Lecture 6
7
Triangle Neighbor Representation
  • Starting from the Indexed Triangle Set, for each
    triangle we now store pointers to the three
    adjacent triangles, and for each vertex store a
    pointer to any one of its incident triangles
  • struct Vertex
  • Point pt
  • Face f
  • struct Face
  • Vertex v3
  • Face adjF3
  • mesh.vertsPointnVerts
  • mesh.facesFacenFaces
  • How to find all the faces adjacent to a vertex
    efficiently?

v0
v0.f
f1
f2
F
v2.f
v1
v2
f0
v1.f
CS148 Lecture 6
8
Finding Next Face using Triangle Neighbor
  • Find the next face clockwise around a vertex v
    from a face f
  • Face fcwvf(Vert v, Face f)
  • if( v f-gtv0 )
  • return adjF 1
  • if( v f-gtv1 )
  • return adjF 2
  • if( v f-gtv2 )
  • return adjF 0
  • Storage 36 (indexed triangles) 24 (face.adjF)
    4 (vert.f) 64 bytes per vertex (still less
    than separate triangles)
  • Efficiently iterate through all triangles
    adjacent to a vertex

Edge-based representations are more general and
comprehensive, such as the winged-edge,
half-edge, and quad-edge data structures.
CS148 Lecture 6
9
Subdivision
CS148 Lecture 6
10
Recall Smooth Shading
The faceted silhouette cannot be smoothed by
shading.
CS148 Lecture 6
11
Subdivision Curves
CS148 Lecture 6
12
Subdivision Surfaces
  • There exists smooth limit surfaces associated
    with a given input mesh
  • The exact smooth limit surface depends on the
    subdivision algorithm used
  • We define a refinement operation, that takes a
    coarse input mesh and generates a finer output
    mesh that is closer to the limit surface
  • If we apply this refinement process infinitely,
    we will exactly achieve the target limit surface
  • However, after just a few levels of refinement,
    any additional changes will be visually
    indistinguishable

CS148 Lecture 6
13
Refine a triangular mesh
Loop Subdivision Surface
CS148 Lecture 6
14
Loop Subdivision
  • Properties
  • Modifies existing vertices
  • Applied to all triangulated surfaces
  • Maintains higher order of continuity

CS148 Lecture 6
15
Subdivide Each Triangle into 4 Triangles
CS148 Lecture 6
16
Subdivide Each Triangle into 4 Triangles
CS148 Lecture 6
17
Second step Modify the vertices
  • Where should the additional vertices be located?
  • How should the original vertices be moved?

Additional/Odd (Black)
Original/Even (Gray)
CS148 Lecture 6
18
New Vertex Locations
  • Compute positions of added vertices from
  • the adjacent four original vertices using mask
  • Without overwriting,
  • update the original vertex positions from
  • the six adjacent original vertices using mask
  • Repeat until converged

CS148 Lecture 6
19
Semi-Regular Meshes
  • Most of the mesh has vertices with degree 6
    (Regular point). If the mesh is topologically
    equivalent to a sphere, then not all the vertices
    can have degree 6
  • Must have a few extraordinary points (degree ! 6)

Extraordinary point
CS148 Lecture 6
20
Weights at an Extraordinary Point
  • Challenge find weights that generate a smooth
    surface (tangent plane continuous)
  • Want the surface normal to be continuous
  • This is a hard math problem!

Warren weights
CS148 Lecture 6
21
Example
  • Example mesh

CS148 Lecture 6
22
Example
  • Add vertices

CS148 Lecture 6
23
Example
Odd vertex refinement
CS148 Lecture 6
24
Example
  • Odd vertex refinement

CS148 Lecture 6
25
Example
  • Even vertex refinement

CS148 Lecture 6
26
Example
  • Even vertex refinement

CS148 Lecture 6
27
Example
  • Extraordinary vertex

CS148 Lecture 6
28
Example
  • Extraordinary vertex

CS148 Lecture 6
29
Example
  • Subdivided Surface

CS148 Lecture 6
30
Example
  • Level 2

CS148 Lecture 6
31
Example
  • Level 3

CS148 Lecture 6
32
Example
  • Level 4

CS148 Lecture 6
33
Example
  • Limit Surface

CS148 Lecture 6
34
Mesh Generation
CS148 Lecture 6
35
Marching Cubes
  • Polygonization
  • Convert implicit surface to polygonal mesh
  • Render the polygons as before
  • Two steps
  • Partition space into cells
  • Fit a polygon to the surface in each cell
  • Gives a piecewise linear approximation of the
    surface in each cell

CS148 Lecture 6
36
Cell polygonization
  • Need to find the cells that actually intersect
    the surface
  • A simple method is exhaustive enumeration
  • Divide all of space into a regular grid
  • Traverse all cells, and polygonize the cells that
    contain the surface

CS148 Lecture 6
37
Surface vertices
  • Determine where the surface intersects the cell
    edges
  • 1st option Linearly interpolate function value
    from cell vertices to approximate (function might
    not be linear)
  • 2nd option Numerically find the zero
  • Either will work, but option 2 can be
    significantly more expensive

CS148 Lecture 6
38
Surface vertices
  • Linearly interpolate function value from cell
    vertices to approximate the surface

CS148 Lecture 6
39
Surface polygons
  • Given the vertices of our final polygonal
    surface, find the polygon faces of the surface
  • Solution There are only a finite number of
    options, defined by the configurations of
    inside/outside of the cells vertices

CS148 Lecture 6
40
Surface polygons
  • Consider 2D first
  • 16 different possible configurations
  • Using cell vertex inside/outside configuration to
    index into this table
  • Note some of them are duplicates of others

CS148 Lecture 6
41
Surface polygons
Result
CS148 Lecture 6
42
Surface polygons
  • In 3D, there are 256 configurations, which can be
    reduced to 15 cases.

CS148 Lecture 6
43
Ambiguity in Marching Cubes
  • Some configurations are ambiguous
  • Solution?
  • Sample more
  • Refine the cell
  • Simple solution just sample once more in the
    middle of the cell

or
CS148 Lecture 6
44
Another Solution
Split a cube into six tetrahedra, and find
surface vertices and polygons in each tetrahedron
CS148 Lecture 6
45
Marching tetrahedra
Unambiguous Less cases More elements (more
edges)
CS148 Lecture 6
46
Voronoi Diagram
  • Split the space into regions consisting of the
    set of points closest to a particular seed point
  • Every edge is a part of the perpendicular
    bisector of two points

CS148 Lecture 6
47
Voronoi Diagram Generation
  • A simple way to generate the Voronoi diagram
  • Incrementally add points
  • Calculate all the perpendicular bisectors between
    the existing points and the newly added point
  • Remove each section of the perpendicular bisector
    lines that trespasses other Voronoi regions

CS148 Lecture 6
48
Voronoi Diagram Delaunay Mesh
  • For every Voronoi edge (red), there exists a
    Delaunay edge (black) between the two
    corresponding points
  • They are the dual graph to each other
  • In 2D, the Delaunay mesh is a triangle mesh

CS148 Lecture 6
49
Delaunay Mesh
  • In a 2D Delaunay triangulation, the circumcircle
    of every triangle contains no other points
  • This property leads to high-quality elements
    (long, thin elements are avoided as much as
    possible)
  • This is also a good property for a surface mesh
    in 3D

CS148 Lecture 6
50
Improving and Existing Mesh
  • Edge-Flipping
  • In-Circle Test - for a pair of adjacent
    triangles, test whether the circumcircle of one
    triangle contains the fourth point
  • Flip the edge to make it locally-Delaunay

CS148 Lecture 6
51
Incremental Algorithm Sampling
  • Sampling the boundary
  • sampling density inversely proportional to the
    distance to the medial axis
  • more samples for higher curvature regions
  • Sampling the interior
  • sampling density as continuous as possible,
    including the boundary and the interior

CS148 Lecture 6
52
Incremental Algorithm
  • Consider adding sample points one at a time
  • Find the triangle which the newly added point is
    inside (a giant bounding triangle can be used to
    guarantee that you can always find a triangle
    that contains the point)
  • Split that triangle into three triangles
  • For each of the three new triangles. do In-Circle
    test for it and its outer edge adjacent triangle
    flip the edge if the test fails
  • For every flipped edge, its neighbors should also
    be tested recursively
  • Delete triangles outside the object

CS148 Lecture 6
53
Generating a surface mesh
In 2d, we can extract the outer edges to form a
polygon
In 3d, we can extract the surface faces to form
an objects surface
The 3D volume needs sampling points on the
interior, and meshing in 3D is generally
significantly harder than in 2D. E.g. Delaunay
gives poor quality elements in 3D (unlike 2D)!
CS148 Lecture 6
54
3D object surface is technically 2D
  • Meshing on the surface directly requires geodesic
    distances
  • Instead, flatten a 3D mesh to 2D, use 2D Delaunay
  • Hard to flatten exactly -- but could
    approximately flatten, then the result is
    approximately Delaunay
  • Need to sew up boundary regions to make a
    continuous mesh leads to poor quality elements

CS148 Lecture 6
55
3D object surface is technically 2D
  • Cut the object to flatten it, and add new sample
    points (blue) along the cut
  • Generate the Delaunay with incremental algorithm
    connecting both original (black) and new (blue)
    sampling points
  • sew up the boundary edges (reconnect blue points)
  • Retest/remesh to improve the mesh, especially
    near the boundary edges

CS148 Lecture 6
56
3D Sampling
  • Evenly sampling is not efficient and cannot
    capture details
  • Usually need more points to represent higher
    curvature regions
  • Similar to 2D

CS148 Lecture 6
57
3D In-Circle Test
  • Once we get a 3D mesh, the In-Circle test can be
    used to improve it, especially near the
    boundaries where it was sewn together
  • Need 3D version of the In-Circle test
  • Use an ellipse to approximate the mapped circle
    in 2D plane
  • Given three vertices on a curved surface,
    consider the infinite set of spheres through the
    three vertices. The centers of all the spheres
    lie on a single line. Choose the sphere whose
    center is on the surface and define In-Circle
    test as inside that sphere.

CS148 Lecture 6
Write a Comment
User Comments (0)
About PowerShow.com