13
Bump Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of New Mexico 1 Angel: Interactive Computer Graphics 5E © Addison- Wesley 2009

Bump Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of

Embed Size (px)

DESCRIPTION

3 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Examples

Citation preview

Page 1: Bump Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of

Bump Mapping

Ed AngelProfessor of Computer Science,

Electrical and Computer Engineering, and Media Arts

Director, Arts Technology CenterUniversity of New Mexico

1Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Page 2: Bump Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of

2Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Introduction

•Let’s consider an example for which a fragment program might make sense

•Mapping methods Texture mapping Environmental (reflection) mapping

• Variant of texture mapping Bump mapping

• Solves flatness problem of texture mapping

Page 3: Bump Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of

3Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Examples

Page 4: Bump Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of

4Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Modeling an Orange•Consider modeling an orange•Texture map a photo of an orange onto a surface

Captures dimples Will not be correct if we move viewer or light We have shades of dimples rather than their

correct orientation• Ideally we need to perturb normal across surface of object and compute a new color at each interior point

Page 5: Bump Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of

5Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Bump Mapping (Blinn)

•Consider a smooth surfacen

p

Page 6: Bump Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of

6Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Rougher Version

n’

p

p’

Page 7: Bump Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of

7Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Equations

pu=[ ∂x/ ∂u, ∂y/ ∂u, ∂z/ ∂u]T

p(u,v) = [x(u,v), y(u,v), z(u,v)]T

pv=[ ∂x/ ∂v, ∂y/ ∂v, ∂z/ ∂v]T

n = (pu pv ) / | pu pv |

Page 8: Bump Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of

8Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Tangent Plane

pu

pv

n

Page 9: Bump Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of

9Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Displacement Function

p’ = p + d(u,v) n

d(u,v) is the bump or displacement function

|d(u,v)| << 1

Page 10: Bump Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of

10Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Perturbed Normal

n’ = p’u p’v

p’u = pu + (∂d/∂u)n + d(u,v)nu

p’v = pv + (∂d/∂v)n + d(u,v)nv

If d is small, we can neglect last term

Page 11: Bump Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of

11Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Approximating the Normal

n’ = p’u p’v

≈ n + (∂d/∂u)n pv + (∂d/∂v)n pu

The vectors n pv and n pu lie in the tangent plane Hence the normal is displaced in the tangent planeMust precompute the arrays ∂d/ ∂u and ∂d/ ∂v Finally,we perturb the normal during shading

Page 12: Bump Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of

12Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

Image Processing

•Suppose that we start with a function d(u,v)

•We can sample it to form an array D=[dij]

•Then ∂d/ ∂u ≈ dij – di-1,j

and ∂d/ ∂v ≈ dij – di,j-1 •Embossing: multipass approach using accumulation buffer

Page 13: Bump Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University of

13Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009

How to do this?

•The problem is that we want to apply the perturbation at all points on the surface

•Cannot solve by vertex lighting (unless polygons are very small)

•Really want to apply to every fragment•Can’t do that in fixed function pipeline•But can do with a fragment program!!