41
Unit 5: Procedural Modeling Part 1: Procedural Texturing Part 2: The Perlin Noise Function Part 3: Procedural Modeling CptS 548 (Advanced Computer Graphics) Unit 5: Procedural Modeling Bob Lewis School of Engineering and Applied Science Washington State University Spring, 2018 Bob Lewis WSU CptS 548 (Spring, 2018)

CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

  • Upload
    others

  • View
    31

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

CptS 548 (Advanced Computer Graphics)Unit 5: Procedural Modeling

Bob Lewis

School of Engineering and Applied ScienceWashington State University

Spring, 2018

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 2: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

References

� Ebert, D. S., et al., Texturing and Modeling (3rd ed.),Academic Press, 2003.

� Hart, J., et al., Procedural Implicit Techniques for Modelingand Rendering, (SIGGRAPH ’99 Course Notes).

� Perlin, K., “Hypertexture”, (SIGGRAPH ’89).

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 3: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

What is Texture?

� a way to vary surface properties to give the appearance ofdetails not actually present in the underlying geometric model

� think: “wallpaper”

� distinguished from illumination (aka “shading”) models, whichmodel the interaction of light with matter

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 4: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Texture in Computer Graphics (esp. Ray Tracing)

image mapping (Catmull 74)map intersection point to texture coordinates used tolook up material and other properties in texture

reflection (aka. environment) mapping (Blinn and Newell 76)look up reflected ray direction in surroundingpanorama

bump mapping (Blinn 78)simulate bumpy or rough surface by perturbingsurface normal (silhouettes are a problem)

displacement mapping (Cook 84)use texture actually displace a surface (silhouettesnot a problem)

solid textures (Peachey 85) and (Perlin 85)functions defined at any point in space determinetexture properties (e.g. wood or marble)

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 5: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Example: Image Mapping

u

v

0

0

1

1

xyz

→ u =

�Su

�atan(y ,x)

2π + 12

��mod 1

v = (Svz) mod 1

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 6: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Alternative: 3D Image Texturing

Some textures are intrinsically 3D:

� stone (esp. marble)

� wood

� clouds

� other?

We could scan multiple slices to produce a sampled 3D texture.

� takes a lot of memory

� supported in OpenGL as far back as version 2.1

But an alternative is offered by procedural texturing.

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 7: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

What is Procedural Texturing?

� Texture generated by a function rather than an image.

� Really a matter of degree, since some kind of procedure –even interpolation – is always used.

� Creating a(n efficient) procedure to produce a desired effect isan example of “designer mathematics”. (People who can dothis for the entertainment industry earn big bucks.)

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 8: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

How Does Procedural Texturing Work?

Start with a shader, such as our old friend EADS:

L = Le + kaLa +�

all luminaires i

�kd(�si · �n) + ks(�si · �h)ns

�Ei

� Take any (material) property and turn it into a function of theintersection point, then shade as usual.

� You may also perturb (slightly modify) the surface normal n.(This is “bump mapping”).

� There may be an inverse mapping to parametric (u, v) space.

� This also goes for reflection (modify �n) and refraction (modify�n and/or η).

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 9: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Example of Procedural Texturing

Let:kd(x , y , z) = �x + y + z� mod 2

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 10: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

A Simple Wood Texture

x

y

z

P

A simple approach produces the effectof tree rings:

� Given p = (x , y , z), computeρ =

�x2 + y2.

� Assign the texture property k (acolor coeffcient, say):

k = k0+k1 − k0

2

�sin

�2πρ

S

�+ 1

where k0 is the “dark” color and k1is the “light” color.

� Compute the shading as usual.

Bob Lewis WSU CptS 548 (Spring, 2018)

rho

Page 11: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Is This Good Enough?

You end up with images that look like this:

It looks too regular for a natural object.

We need to add some “noise”, but not just any noise.

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 12: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Designing a “Noise” Function

Perlin designed a function N(P) to produce noise with thesecharacteristics:

� P can be any point in space (i.e. ∈ R3)

� it ranges between -1 and +1.

� it is zero at integer grid coordinates (i , j , k). (This limits theintroduction of constant components.)

� it is everywhere differentiable (i.e. “smooth”).

� it is band-limited. (Why?)

� it is almost a wavelet.

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 13: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

The Perlin Noise Function (I)

Perlin said: If we want a “controllably” random number at a pointP = (x , y , z), imagine the point in an infinite 3D grid...

(i,j,k)

(i+1,j+1,k+1)

P

� Computei = �x� j = �y� k = �z�u = x − i v = y − j w = z − k

� Add the contribution of all eight grid pointssurrounding P using some function Ωi �j �k �():

N(x , y , z) =i+1�

i �=i

j+1�

j �=j

k+1�

k �=k

Ωi �j �k ��u�, v �,w ��

where u� = u if i � = i and −u if i � = i + 1 and likewise for v �, v ,and j � and for w �, u and k �.

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 14: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

The Perlin Noise Function (II)

ijk

� Choose a unit vector �Γijk in arandom direction. (How? Think:lens points)

� We want this to be ∇Ωijk at(0,0,0). The easiest way to do thatis to let

Ωijk(u, v ,w) = [u v w ]t · �Γijk

� Note that Ωijk(0, 0, 0) = [0 0 0]t .

� This isn’t enough, though. How dowe take care of the dropoff as thesample point moves closer to theedge of the cell (u, v ,w = ±1) ?

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 15: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Aside: The Cubic Weighting Function (I)

ω(t)

t

ω'(0)

ω'(1)

10

0

1

We want a function ω(t) such that

1. ω(0) = 1

2. ω(t) = 0 ∀ t ≥ 1

3. ω�(0) = ω�(1) = 0

4. ω(t) = ω(−t)

Let’s solve requirements 1-3 for 0 ≤ t ≤ 1. Four constraints (#3 isactually two constraints) require four degrees of freedom to solvefor, so if we want a polynomial, it must be (at least) a cubic.Its derivative must have roots at 0 and 1, so...

ω�(t) = Bt(t − 1) ⇒ ω(t) = A+ B

�t3

3− t2

2

for some constants A and B, which we can determine..

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 16: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Aside: The Cubic Weighting Function (II)

ω(t)

t

ω'(0)

ω'(1)

10

0

1

� ω(0) = 1 ⇒ A = 1.

� ω(1) = 0 ⇒

0 = 1 + B

�1

3− 1

2

�⇒ B = 6

To force symmetry (requirement #4), we use an absolute valuefunction:

ω(t) =

�1 + 6

�|t|33 − |t|2

2

�|t| ≤ 1

0 |t| > 1

We’ll use this to force the noise function to zero at the limit of acell (i , j , k)’s influence.

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 17: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

The Perlin Noise Function (III)

So now we have

Ωijk(u, v ,w) = ω(u)ω(v)ω(w) [u v w ]t · �Γijk

All we have left to do is pick out �Γijk for any i , j , and k ∈ Z. Wecan’t just let it be randomly chosen every time we need it, so wehave to make sure that the same (i , j , k) always gives back thesame �Γijk .

How? By hashing i , j , and k into an index that goes into a fixedtable G[] of random unit vectors, using another table P[], being arandom permutation of n (usually 256) integers from 0 to n − 1:

�Γijk = G [hash(i , j , k)]

= G [P [(P [(P [i mod n] + j) mod n] + k) mod n]]

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 18: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Perlin Noise Function Examples (I)

We can use it to produce more realistic 3D textures:

The noise function is so important, there’s a noise()

implementation built into GLSL. In 1997, Perlin got an AcademyAward for this work.

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 19: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Perlin Noise Function Examples (II)

Images can get quite complex:

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 20: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Advantages and Disadvantages of Procedural Textures

advantages:

� compact

� variable resolution

� cover a wide area (or volume)

� can be parameterized

disadvantages:

� can be non-intuitive to predict or control

� slower to evaluate than non-procedural texture

� if aliasing happens, can be hard to get rid of

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 21: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Using the Perlin Noise Function

A common way to apply the noise function is to use it tointerpolate between two values (a la our checkerboard example) s0and s1:

s(P) = s0�1−

���N(P)����+ s1

���N(P)���

= s0 + (s1 − s0)���N(P)

���

Note that the noise function is a scalar, but we can use it tointerpolate any quantity: scalar, vector, point, rgb, etc. We willsee this in PA03.

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 22: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Perlin Noise Function Examples (III)

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 23: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

A 1D Noise Function

Perlin noise texturing can be done in any number of dimensions.For simplicity, let’s consider a 1D version, N(x):

Even though it’s a random function, it’s “quasi-periodic” withperiod 1. What would N(x/2) or N(2x) look like? ...

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 24: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Scaling a Noise (Indeed, Any) Function

N(x)

N(2x)

N(x/2)

So we can control the “bandwidth” of the noise by scaling theargument(s) to the noise function. This will work in any number ofdimensions, too.

For animations, we can also add a time-dependent factor to thearguments and watch the noise pattern “move” to get, say, oceanwaves.

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 25: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Aside: The Fourier Viewpoint

Recall the formula for the Fourier transform:

F [f ] =

� ∞

−∞f (t)e−i2πνtdt

If we scale the argument by a factor of α, we find:

F [f (αt)] =

� ∞

−∞f (αt)e−i2πνtdt

=

� ∞

−∞f (τ)e−i2π ντ

α d� τ

α

=1

|α|F� να

So α > 1 stretches the frequency spectrum and α < 1 scrunches it.Our intution is justified.

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 26: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Turbulence

Many natural phenomena show “turbulence”. Perlin introduced a(pseudo-)tubulence:

Nt(P, L) =L−1�

i=0

N(2i P)

2i

Summing scaled noise functions over L “octaves” (What does thatterm mean in music?) produces a more turbulent noise function forthose phenomena that need it.

� Larger values of L introduce higher frequencies.

� The 2i in the denominator determines their relativecontribution. Other weighting formulae are possible (seebelow).

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 27: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Vector Noise (I)

For the next example, bump mapping, we need a vector noisefunction �Nv (P). Recall that we used vectors �Γijk to construct thescalar noise function N(P):

N(x , y , z) =i+1�

i �=i

j+1�

j �=j

k+1�

k �=k

Ωi �j �k ��u�, v �,w ��

whereΩijk(u, v ,w) = [u v w ]t · �Γijk

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 28: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Vector Noise (II)

Let’s produce vector noise by taking the normalized gradient of N:

�Nv (P) =∇N(P)���∇N(P)

���

where, assuming P = [x y z ]t ,

∇N(P) =i+1�

i �=i

j+1�

j �=j

k+1�

k �=k

∇Ωi �j �k ��u�, v �,w ��

and (note the matrix product notation)

∇Ωijk(u, v ,w) = ∇

ω(u)ω(v)ω(w)uω(u)ω(v)ω(w)vω(u)ω(v)ω(w)w

t

�Γijk

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 29: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Vector Noise (III)

So (excuse the tiny font):

∇Ωijk(u, v ,w) =

�ω(u) + uω�(u)

�ω(v)ω(w) uω(u)ω�(v)ω(w) uω(u)ω(v)ω�(w)

vω�(u)ω(v)ω(w) ω(u)�ω(v) + vω�(v)

�ω(w) vω(u)ω(v)ω�(w)

wω�(u)ω(v)ω(w) wω(u)ω�(v)ω(w) ω(u)ω(v)�ω(w) + wω�(w)

�Γijk

I think this is the correct formula, but it’s untested, so check it yourself before you use it!

It’s then easy to construct a turbulent vector noise function�Ntv (P) using Nv (P) in place of N(P).

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 30: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Noisy Bump Mapping

So given an intrinsic normal �n and a vector noise function �Nv (P),we can compute a perturbed normal �np:

�np�P, �n, k1, k2

�=

�n+ k1�Nv

�k2P

����n+ k1�Nv

�k2P

����

Note:

� k1 and k2 are user-defined constants. |k1| is usually less than1. (Problems arise if it’s not.)

� We can use �Ntv () instead of �Nv () to get turbulent bumpmapping.

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 31: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Examples of Bump Mapping Normals

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 32: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

What is Procedural Modeling?

So far, we’ve been using procedures (mostly variations of N()) todetermine textures. Procedural modeling includes textures, butgoes further, using procedures to define the model *geometry* aswell.

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 33: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Hypertexture

Perlin defines a “hypertexture” H(P) as a 3D solid texture builtout of

� an object density function D(P), where� D(P) = 0 outside the object.� D(P) = 1 inside the object.� 0 < D(P) < 1 in the “soft” region around the object.

� one or more density modulation functions fi (x)

� these modulate the object’s density in the soft region

The hypertexture is then

H(P) = fn−1

�fn−2

�fn−3

�· · · f0

�D(P)

����

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 34: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Examples of Hypertexture (I)

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 35: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Examples of Hypertexture (II)

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 36: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Rendering Hypertexture: Raymarching

Hypertexture intersection calculations are more complicated thanwhat we’ve seen so far.

dPdP

dPdP

dP

D = 0

D = 1

soft region

We use raymarching: Intersect the ray with the D = 0 shell andthen step along it in fixed increments dP, adding the D-valuesuntil we reach a threshold (1, say).

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 37: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Fractals

Definition (from Musgrave in Ebert, et al.):

fractal: a geometrically complex object, the complexity ofwhich arises from the repetition of form over somerange of scale.

Fractals have

� amplitude

� a “(spatial) frequency” distribution� a “fractal dimension” (the Hausdorff dimension), which has

� an integer part (what we normally think of as dimension)� a real part called the “fractal increment” H, where 0 < H < 1.

� a limited scale range of form repetition (Example: Earth)

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 38: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Fractal Brownian Motion

Start with the Perlin turbulence function: Nt(P, L) =�L−1

i=0N(2i P)

2i

We generalize it to:

fBm�P,λ,H, L

�=

�L�−1�

i=0

N(λi P)

λiH+ (L− �L�) N(λLP)

λLH

where

� λ is the “lacunarity”: the gap between successive frequencies.

� H is the fractal increment.

� L is the number of octaves.

Q: How can we recover Nt(P, L) from fBm(P,λ,H, L)?

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 39: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Examples of fBm()

(Caption: Traces of fBm for H varying (downward) from 1.0 to 0.0in increments of 0.2.)

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 40: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Notes on fBm()

Recall:

fBm�P,λ,H, L

�=

�L�−1�

i=0

N(λi P)

λiH+ (L− �L�) N(λLP)

λLH

� L can be a real value, unlike for Nt(P, L).

� This is only one way to produce a fractal.

� λ is almost always 2.

Bob Lewis WSU CptS 548 (Spring, 2018)

Page 41: CptS 548 (Advanced Computer Graphics) Unit 5: Procedural ...bobl/cpts548/u05_procmodel/notes.pdf · Ebert, D. S., et al., Texturing and Modeling (3rd ed.), Academic Press, 2003. Hart,

Unit 5: Procedural ModelingPart 1: Procedural TexturingPart 2: The Perlin Noise FunctionPart 3: Procedural Modeling

Controlling Aliasing with fBm()

1 p

ixel

Suppose N(x) is defined with a gridspacing that is a whole screen of wpixels. What is L such that N(2Lx)(frequency scaled by 1

2L) isband-limited?

� A pixel spacing of 1w implies a

Nyquist frequency of fc = 12w .

� A noise function N(x) in fBm()with maximum frequencyfmax =

12L

has harmonics in itup to ≈ 2fmax.

So we can choose L to avoid aliasing:

2fmax ≈ fc ⇒ 2

�1

2L

�≈ 1

2w⇒ 2L ≈ 4w ⇒ L � 2 + log2 w

Bob Lewis WSU CptS 548 (Spring, 2018)