CSCI 420: Computer Graphics
Hao Li
http://cs420.hao-li.com
Fall 2018
6.2 Bump Mapping & Clipping
1
6.2 Bump Mapping & Clipping Hao Li http://cs420.hao-li.com 1 - - PowerPoint PPT Presentation
Fall 2018 CSCI 420: Computer Graphics 6.2 Bump Mapping & Clipping Hao Li http://cs420.hao-li.com 1 Bump Mapping 2 A long time ago, in 1978 3 bump mapping was born courtesy by ZBrush 4 For Meshes vertex normal interpolation
CSCI 420: Computer Graphics
Hao Li
http://cs420.hao-li.com
Fall 2018
1
2
3
courtesy by ZBrush
4
vertex normal interpolation smooth shading What about accessing textures to modify surface normals...
5
Use bump map normals given a parametrized mesh
u =
v ⇥
∈ R2
6
Bump map normals
are defined in a local coordinate frame inside a triangle
7
We have positions, normals and parameters
8
9
p(u) ∈ R3 u =
v ⇥
∈ R2
2-Manifold Surface Parameter Domain
10
p(u) ∈ R3 u =
v ⇥
∈ R2
Surface Parameter Domain n(p)
11
p(u) ∈ R3 n(p) ∂p ∂u ∂p ∂v
12
p1 p2 p3 p0
p
13
we are not interested in
p0
p2 − p1 = (u2 − u1)∂p ∂u + (v2 − v1)∂p ∂v p3 − p1 = (u3 − u1)∂p ∂u + (v3 − v1)∂p ∂v
14
p3 − p1 ⇥ = ⇧
∂p ∂u ∂p ∂v
⌃ ⇤ (u2 − u1)
(u3 − u1) (v2 − v1) (v3 − v1)
⌅
p2 − p1 = (u2 − u1)∂p ∂u + (v2 − v1)∂p ∂v p3 − p1 = (u3 − u1)∂p ∂u + (v3 − v1)∂p ∂v
correct if mesh is planar
15
n
n1 n2 n3
n = α1n1 + α2n2 + α3n3
p = α1p1 + α2p2 + α3p3
from
16
∂p ∂v
∂pnew ∂v
∂pnew ∂u
17
We now have an inexpensive way to add geometric details Other bump mapping techniques exist
18
19
20
21
22
23
x y
image plane near far Z clipped line
normalization and orthographic projection
24
near far z clipped line image plane x y near clipped line z y x 1 1 1 far
requires more general algorithms and is more expensive
25
1. Camera: From object coordinates to eye coords
gluPerspective
26
square or rectangle
27
1 y x z 1 1 clipped line
within clipping rectangle
28
29
clipping rectangle
and divisions
and divisions
30
y = y1 y = y0 y = kx + n x = x0 x = x1
Avoid expensive line-rectangle intersections (which require floating point divisions)
(but many only work in 2D)
31
32
y < ymax y > ymin x > xmin x < xmax
interior
xmin xmax ymin ymax
interior
33
b0 : y > ymax b1 : y < ymin b2 : x > xmax b3 : x < xmin O1 = outcode(x1, y1) O1 = outcode(x2, y2)
1001 1000 1010 0010 0000 0001 0101 0100 0110 ymax ymin
(x1, y1) (x2, y2)
xmin xmax
34
1001 1000 1010 0010 0000 0001 0101 0100 0110 ymax ymin xmin xmax O1 = O2 = 0000: accept entire segment O1 & O2 ≠ 0000: reject entire segment O1 = 0000, O2 ≠ 0000: subdivide O1 ≠ 0000, O2 = 0000: subdivide O1 & O2 = 0000: subdivide bitwise AND
35
36
p1 p2
clipping rectangle
37
p1 p2 1 2 3 4 extended clipping rectangle
38
the order of the four intersection points !
39
40
41
42
(OpenGL supported)
43
44
45
46
lines and polygons
47
48
49
as before
50
51
z(α) = (1 − α)z1 + αz2
52
53
http://cs420.hao-li.com
54