Texture Mapping Motivation: Add interesting and/or realistic detail - - PDF document
Texture Mapping Motivation: Add interesting and/or realistic detail - - PDF document
Texture Mapping Motivation: Add interesting and/or realistic detail to surfaces of objects. Problem: Fine geometric detail is difficult to model and expensive to render. Idea: Modify various shading parameters of the surface by
Motivation: Add interesting and/or realistic detail to
surfaces of objects.
Problem: Fine geometric detail is difficult to model
and expensive to render.
Idea: Modify various shading parameters of the
surface by mapping a function (such as a 2D image)
- nto the surface.
Textures and Shading
http://www.3drender.com/jbirn/hippo/hairyhipponose.html
4
Texture Mapping – Simple Example
Simple parametrization
Mapping is not unique
Bump Mapping
Bump Mapping
Surface Parametrization
Most slides courtesy of Pierre Alliez, Craig Gotsman, and Noam Aigerman
13
Triangle mesh
Discrete surface representation Piecewise linear surface (made of triangles)
14
Triangle mesh
Geometry:
Vertex coordinates
(x1, y1, z1) (x2, y2, z2)
. . .
(xn, yn, zn)
Connectivity (the graph)
List of triangles
(i1, j1, k1) (i2, j2, k2)
. . .
(im, jm, km)
15
What is a parameterization?
S R3 - given surface D R2 - parameter domain s : D S 1-1 and onto
) , ( ) , ( ) , ( ) , ( v u z v u y v u x v u s
16
Example – flattening the earth
Mesh Parameterization
World Atlas
18
Parameterizations are atlases
World Atlas
20
World Atlas
21
World Atlas
22
The true size of Africa
23
Another view of the same idea
24
There are many possible maps
Is one of them “correct”?
Can’t flatten without distorting
27
- 1
1
h
Another example:
Parameters: , h D = [0,][–1,1]
x(, h) = cos() y(, h) = h z(, h) = sin()
28
Triangular Mesh
29
Triangular Mesh
30
Mesh Parameterization
Uniquely defined by mapping mesh vertices
to the parameter domain:
U : {v1, …, vn} D R2 U(vi) = (ui, vi)
No two edges cross in the plane (in D)
Mesh parameterization mesh embedding
31
Mesh parameterization
Parameter domain
D R2
Mesh surface
S R3
Embedding U Parameterization s
s = U -1
32
2D parameterization
3D space (x,y,z) 2D parameter domain (u,v) boundary boundary
33
Application - Texture mapping
34
Requirements
Bijective (1-1 and onto): No triangles fold over. Minimal “distortion”
Preserve 3D angles Preserve 3D distances Preserve 3D areas No “stretch”
35
Distortion minimization
Kent et al ‘92 Floater 97 Sander et al ‘01
Texture map
36
More texture mapping
37
Resampling problems
Cat mesh Distorting embedding Resampling
- n regular grid
Remeshing
39
Remeshing examples
40
Remeshing
41
Remeshing
42
More remeshing examples
43
Conformal parametrization
Texture map Tutte Shape-preserving Conformal
44
Non-simple domains
45
Cutting
46
Parameterization of closed genus-0 triangle meshes
Non-Constrained Planar Spherical
47
Introducing seams (cuts)
48
Partition
50
Introducing seams (cuts)
51
Introducing seams (cuts)
52
Bad parameterization
53
Better…(free boundary)
54
Partition – problems
Discontinuity of parameterization Visible artifacts in texture mapping Require special treatment
Vertices along seams have several (u,v)
coordinates
Problems in mip-mapping
Make seams short and hide them
55
Summary
“Good” parameterization = non-distorting
Angles and area preservation Continuous param. of complex surfaces cannot avoid distortion.
“Good” partition/cut:
Large patches, minimize seam length Align seams with features (=hide them)
56
Mesh parameterization
s and U are piecewise-linear Linear inside each mesh triangle
In 2D In 3D
U s
A mapping between two triangles is a unique affine mapping
57
A B C P
Barycentric coordinates
, , , , , , , , , , , , , , denotes the (signed) area of the triangle P B C P C A P A B P A B C A B C A B C A B C
58
Mapping triangle to triangle
s
p1 p2 p3 q1 q2 q3
3 3 2 1 2 1 2 3 2 1 1 3 1 3 2 1 3 2
, , , , , , , , , , , , ) ( q p p p p p q p p p p p q p p p p p p p p p s
Some techniques
60
Convex mapping (Tutte, Floater)
Works for meshes equivalent to a disk First, we map the boundary to a convex polygon Then we find the inner vertices positions v1, v2, …, vn – inner vertices; vn, vn+1, …, vN – boundary vertices
61
Inner vertices
We constrain each inner vertex to be a weighted
average of its neighbors:
n i ,
i N j j j i i
, , 2 , 1
) ( ,
v v
1 ) neighbours ( ) , ( neighbors not are ,
) ( , ,
i N j j i j i
E j i j i
i,j
i j
62
Linear system of equations
n i , n i 0,
B i N k k k i B i N j j j i i i N j j j i i
, , 2 , 1 , , 2 , 1
) ( , \ ) ( , ) ( ,
v v v v v
n n j n j j j
d
2 1 2 1 , , 4 , 1 , 1
1 1 1 1
5 1 1 1
v v v
63
Shape preserving weights
To compute 1, …, 5, a local embedding of the patch is found:
1) || pi – p || = || xi – x || 2) angle(pi, p, pi+1) = (2 /i ) angle(vi, v, vi+1)
p4 p3 p5 p1 p p2 2D 3D
p = i pi
i > 0 i = 1 use these as edge weights. i , v3 v2 v1 v4 v5 v 1
64
Linear system of equations
A unique solution always exists Important: the solution is legal (bijective) The system is sparse, thus fast numerical
solution is possible
Numerical problems (because the vertices in the
middle might get very dense…)
65
2D parameterization
3D space (x,y,z) 2D parameter domain (u,v) boundary boundary
66
Harmonic mapping
Another way to find inner vertices Strives to preserve angles (conformal) We treat the mesh as a system of springs. Define spring energy:
where vi are the flat position (remember that the boundary vertices vn, vn+1, …, vN are constrained).
E j i j i j i harm
k E
) , ( 2 ,
2 1 v v
67
Energy minimization – least squares
We want to find such flat positions that the
energy is as small as possible.
Solve the linear least squares problem!
.
) ( ) ( 2 1 2 1 ) , , , , , ( ) , (
) , ( 2 2 , ) , ( 2 , 1 1
E j i j i j i j i E j i j i j i n n harm i i i
y y x x k k y y x x E y x v v v
Eharm is function of 2n variables
68
Energy minimization – least squares
To find minimum: Eharm= 0 Again, xn+1,…., xN and yn+1, …, yN are constrained.
) ( 2 2 1 ) ( 2 2 1
) ( , ) ( ,
i N j j i j i harm i i N j j i j i harm i
y y k E y x x k E x
69
Energy minimization – least squares
To find minimum: Eharm= 0 Again, xn+1,…., xN and yn+1, …, yN are constrained.
n i y y k n i x x k
i N j j i j i i N j j i j i
, , 2 , 1 , ) ( , , 2 , 1 , ) (
) ( , ) ( ,
70
The spring constants ki,j
The weights ki,j are chosen to minimize angles
distortion:
Look at the edge (i, j) in the 3D mesh Set the weight ki,j = cot + cot
i j
3D
71
Discussion
The results of harmonic mapping are better than those of
convex mapping (local area and angles preservation).
But: the mapping is not always legal (the weights can be
negative for badly-shaped triangles…)
Both mappings have the problem of fixed boundary –
it constrains the minimization and causes distortion.
There are more advanced methods that do not require
boundary conditions.
72
Convex weights for inner vertices
( , ) ( ) ( , ) ( )
s.t. 1 and
i ij j ij ij i j N i i j N i
w w w
v v
If the weights are convex, the solution is always valid (no self-
intersections) [Floater 97]
The cotangent weight in Harmonic Mapping can be negative
sometimes there are triangle flips
In [Floater 2003] new convex weights are proposed that
approximate harmonic mapping
73
Angle-based Flattening (ABF)
[Sheffer and de Sturler 2001]
Angle-preserving parameterization The energy functional is formulated using the flat
mesh angles only!
Allows free boundary
74
Angle-based Flattening (ABF)
[Sheffer and de Sturler 2001]
The goal: minimize the difference
where i are angles of original (3D) mesh and i are the unknowns (the flat mesh)
N i i i 1 2
75
The angles equations (constraints) All angles are positive: Angles around an inner vertex in 2D sum up to 2 Angles in a triangle sum up to
) 1 (
i
) 2 ( 2
around
i j j
) 3 (
3 2 1
i i i
a a a
76
The angles equations (constraints)
Finally, something like the sine theorem must
hold:
1 ~ sin sin ) 4 (
) ( 1 ) ( 1
j i N j j i N j
77
The angles equations (constraints)
Finally, something like the sine theorem must
hold:
78
The final optimization:
We minimize
under the 4 constraints
It’s enough to fix one triangle in the plane to
define the whole flat mesh
N i i i 1 2
79
Results
80
Results
81
Results
82
Results
83
Discussion
Pros:
Angle preserving Always valid (at least internally) No rigid boundary constraints
Cons:
Non-linear optimization
Expensive (but now a multi-grid method exists)
Building the mesh from angles can be unstable
Solid Textures
(Peachey 1985, Perlin 1985)
Problem: mapping a 2D image/function onto the
surface of a general 3D object is a difficult problem:
Distortion Discontinuities
Idea: use a texture function defined over a 3D
domain - the 3D space containing the object
Texture function can be digitized or procedural