08+ +Geometric+Models
08+ +Geometric+Models
Christoph Garth
Scientific Visualization Lab
Motivation
Geometric models enable processing (e. g. rendering) of 3-dimensional models
using computers.
In most cases, this allows objects to be rendered (e.g. using ray tracing).
• polygonal meshes
• implicit surfaces
• parametric surfaces
concave
heptagon octagon nonagon decagon
regular polygons
not allowed:
not allowed:
overlapping faces
allowed T-vertex
A planar graph is a graph which vertices can be position on a plane such that no edges
intersect.
• V: set of vertices
• E: set of edges
• For each pair of vertices, there exists a path which connects these two vertices.
• F: set of faces
• Continuous areas of the plane that are bounded by a closed polyline.
V − E + F = 2 − 2g
χ=2 χ=0 χ = −2 χ = −4
V = 3890
E = 11664
F = 7776
genus 0, χ = 2
genus 1, χ = 0
Examples:
• Shortest edge path between two vertices
• Is there a path that visits every node exactly once?
• How many edges can be contained in a triangular mesh with V vertices?
3F ≈ 2E ⇒ E ≈ 3V, F ≈ 2V
2V − 2E + 2F = 2χ ⇒ 2V = F − 2χ ≈ F ⇒ V : F : E ≈ 1 : 2 : 3
• What is the average valence (number of neighbors) of the vertices in a
• triangular mesh? ⇒ < 6
• quad mesh? ⇒ < 4
Construction of such connectivity (determining the edges) from a given set of surface
points is called triangulation (quadrangulation,. . . ).
• For piecewise linear approximations, the maximum distance between the continuous
surface and the approximation with decreasing maximal edge length h is in O(h2 )
3 6 12 24
Some of these algorithms need only very little information about the mesh, while others
can benefit enormously from additional information.
Computer Graphics – Geometric Models – Data Structures for Polygonal Meshes 8–21
At the very least, a mesh data structure describe
Information that is not given can be reconstructed (at some computational cost) from the
given information, for example, mesh topology from polygon topology.
Computer Graphics – Geometric Models – Data Structures for Polygonal Meshes 8–22
Example: Computation of vertex neighborhoods
• The n-ring of a vertex v is the set of vertices that are connected to v via a path of
edges of length n or less.
• The valence of a vertex is the number of incident edges (= neighbors in the the
1-ring)
v v
1-ring 2-ring
Computer Graphics – Geometric Models – Data Structures for Polygonal Meshes 8–23
Explicit representation for triangular meshes (face set)
t vi vj vk
Data format: e. g. 0 ( 1.0, 1.0, 1.0) (-1.0, 1.0,-1.0) ( 1.0, 1.0, 1.0)
STL (STere- 1 ( 1.0, 1.0, 1.0) (-1.0,-1.0, 1.0) ( 1.0,-1.0,-1.0)
oLithography) 2 ( 1.0, 1.0, 1.0) ( 1.0,-1.0, 1.0) (-1.0, 1.0,-1.0)
3 (1.0,-1.0,-1.0) (-1.0,-1.0, 1.0) (-1.0, 1.0,-1.0)
Computer Graphics – Geometric Models – Data Structures for Polygonal Meshes 8–24
Example: STL file
1 solid name
2 facet normal n_i n_j n_k normal vector
3 outer loop
4 vertex v1_x v1_y v1_z
5 vertex v2_x v2_y v2_z
6 vertex v3_x v3_y v3_z
7 end loop
8 end facet
9 ...
Computer Graphics – Geometric Models – Data Structures for Polygonal Meshes 8–25
Shared Vertex Representation / Indexed Face Set
v x y z t i j k
0 1.0 1.0 1.0 0 0 1 2
1 -1.0 1.0 -1.0 1 0 2 3
2 -1.0 -1.0 1.0 2 0 3 1
3 1.0 -1.0 1.0 3 3 2 1
Computer Graphics – Geometric Models – Data Structures for Polygonal Meshes 8–26
Discussion: Shared Vertex Representation/Indexed Face Set
Example: OBJ file format (“object file”, implicit numbering of vertices and faces):
Computer Graphics – Geometric Models – Data Structures for Polygonal Meshes 8–27
Extended Shared Vertex Representation (also Face-Based Connectivity)
• Array of vertices: coordinates for each vertex and an index to one adjacent triangle:
3n floats + n integers
• Array of triangles: references to each three vertices and neighboring faces (adjacent
triangles, boundary neighbor indicated by −1): 6n integers
• 16 bytes/v + 24 bytes/f ≈ 64 bytes/v
v x y z l t i j k n0 n1 n2
0 1.0 1.0 1.0 0 0 0 1 2 3 1 2
1 -1.0 1.0 -1.0 0 1 0 2 3 3 2 0
2 -1.0 -1.0 1.0 0 2 0 3 1 3 0 1
3 1.0 -1.0 1.0 1 3 3 2 1 0 2 1
Note: here n stands for “neighbor” not “normal”
Computer Graphics – Geometric Models – Data Structures for Polygonal Meshes 8–28
Edge-Based Connectivity/Winged Edge Data Structure (Baumgart, 1994)
Computer Graphics – Geometric Models – Data Structures for Polygonal Meshes 8–29
Example: (compute by yourself)
Computer Graphics – Geometric Models – Data Structures for Polygonal Meshes 8–30
More specific data structures for minimal redundancy and memory efficient
representation by implicit topology:
• triangle/quad strips
• triangle fans
Computer Graphics – Geometric Models – Data Structures for Polygonal Meshes 8–31
Example: Triangle Strip Subdivision
Computer Graphics – Geometric Models – Data Structures for Polygonal Meshes 8–32
Rendering Polygonal Meshes
During rendering or other operations, polygon meshes often have to be checked
for intersections with other primitives, e. g. in ray tracing.
Typical problems:
Without further afo, each face has to be tested for intersection. Because of this,
acceleration structures are used (e. g. bounding volumes, cf. chapter 6)
p = p0 + β1 · (p1 − p0 ) + β2 · (p2 − p0 )
= (1 − β1 − β2 ) · p0 + β1 · p1 + β2 · p2
= β0 · p0 + β1 · p1 + β2 · p2
o + t · d = p0 + β1 · (p1 − p0 ) + β2 · (p2 − p0 )
p2
β0 = A 0 / A
β1 = A 1 / A
A0
A1 β2 = A2 / A
A2 p1
β0 + β1 + β2 = 1, βi ≥ 0
p0
• Per-polygon normals or face normal vectors can be directly computed as the plane
normal of the polygons
• Normal vectors at the vertices (per-vertex normals) can be computed, e. g. by
averaging of the face normals of the neighboring faces.
(In practice this is often unexpectedly difficult, since normals are defined only
modulo orientation)
k
P ~i
N
~v = i=1
N
k
P ~v
N
i=1
• Therefore, they are another vertex attribute (i.e. a quantity associated with each
vertex).
• Other vertex attributes include: color, texture coordinates, . . .
v x y z Nx Ny Nz t i j k
0 1.0 1.0 1.0 ... ... ... 0 0 1 2
1 -1.0 1.0 -1.0 ... ... ... 1 0 2 3
2 -1.0 -1.0 1.0 ... ... ... 2 0 3 1
3 1.0 -1.0 -1.0 ... ... ... 3 3 2 1
v x y z Nx Ny Nz Cr Cg Cb t i j k
0 1.0 1.0 1.0 ... ... ... ... ... ... 0 0 1 2
1 -1.0 1.0 -1.0 ... ... ... ... ... ... 1 0 2 3
2 -1.0 -1.0 1.0 ... ... ... ... ... ... 2 0 3 1
3 1.0 -1.0 -1.0 ... ... ... ... ... ... 3 3 2 1
Historical development:
• Flat shading:
Evaluation of illumination model (Phong)
with per-face normals of the triangles
• Gouraud (smooth) shading:
computation of the illumination model
(Phong) at the vertices, interpolation of
the resulting color
(Henri Gouraud, 1971)
Principle: Evaluation of the illumination model (Phong) with the interpolated normal (by
Bui Tong Phong, 1973).
For a long time, this was only practical with specialized hardware, but it has become
ubiquitous since the advent of programmable graphics hardware.
Motivation: In many cases, the ratio between amount of polygons and projected surface
is far too large (e.g., polygons are rendered smaller than a pixel).
We will consider
• implicit surfaces
• parametric surfaces
The surface can not be computed directly, but a “distance” can be computed by
inserting x.
• The direction of the normal at point p is given by the gradient ∇f of the function
f (p). The normalized gradient is the normal.
• Intuition: the gradient of a function points in the direction of steepest ascent in the
function near p, and is thus orthogonal to the surface, on which f is constant.
Definition:
∂f (p) ∂f (p) ∂f (p)
∇f (p) = , ,
∂x ∂y ∂z
Often encountered in medicine, “function” (e. g. density) from imaging procedures (CT,
MRI,. . . ) → lecture “Scientific Visualization”
Cases:
Intersections with t < 0 lie behind the ray origin and should be ignored.
Computer Graphics – Geometric Models – Implicit Surfaces 8–55
The normal direction at a point p of a quadric is given by:
2Ax + Dy + Ez + G
∂f (p)/∂x
n = ∇f (p) = ∂f (p)/∂y = 2By + Dy + Fz + H
∂f (p)/∂z 2Cz + Ex + Fy + I
2(x − cx )
∂f (p)/∂x
n = ∂f (p)/∂y = 2(y − cy ) = 2(p − c)
∂f (p)/∂z 2(z − cz )
f (u, v) : Ω → R3
f (u, v) = (x(u, v), y(u, v), z(u, v))
Illustration:
(u, v) (x(u, v), y(u, v), z(u, v))
f
f : R2 → R3
(u, v) → (u, v, 0)
f : R2 → R3
(u, v) → (cos(2πu), sin(2πu), v)
1 2
sphere
r̂
θ̂
ϕ : [0, π] zenith/elevation ϕ
z
ϕ̂
y
θ
x
y
z(θ, ϕ) = cos(ϕ)
ox + tdx = x(u, v)
oy + tdy = y(u, v)
oz + tdz = z(u, v)
f
v0
u
u0
In the parametric case, these can be the tangents of the u-curve and v-curve through p.
These are given by the partial derivatives:
N
fv
δf δf
fu =
δu
and fv =
δv
fu
fu × fv
N=
||fu × fv ||
Parametric form:
x(u, v) cos(u)
y(u, v) = sin(u)
z(u, v) v
Normal:
0
− sin(u) cos(u)
cos(u) × 0 = sin(u)
0 1 0
• Triangulation/Quadrangulation
• many methods, with/without
adaptivity
230 MB vs. 10 GB
subdivision surfaces
Modern GPUs:
ad-hoc computation of subdivisions (tesselation shader)