49
Lecture 15 Slide 1 6.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with texture mapping Projective mapping Shadow mapping Environment mapping Most slides courtesy of Leonard McMillan and Jovan Popovic

Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Embed Size (px)

Citation preview

Page 1: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 1 6.837 Fall 2002

Texture Mapping

Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

texture mapping Projective

mapping Shadow mapping Environment

mapping

Most slides courtesy of Leonard McMillan and Jovan Popovic

Page 2: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 2 6.837 Fall 2002

AdministrativeOffice hours

Durand & Teller by appointmentNgan Thursday 4-7 in W20-575Yu Friday 2-5 in NE43-256

Deadline for proposal: Friday Nov 1Meeting with faculty & staff about proposal

Next weekWeb page for appointment

Page 3: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 3 6.837 Fall 2002

The Quest for Visual Realism

For more info on the computer artwork of Jeremy Birnsee http://www.3drender.com/jbirn/productions.html

Page 4: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 4 6.837 Fall 2002

Photo-textures

The concept is very simple!

Page 5: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 5 6.837 Fall 2002

Texture Coordinates Specify a texture coordinate at each vertex (s, t) or (u, v)

Canonical coordinates where u and v are between 0 and 1

Simple modifications to triangle rasterizer

Void EdgeRec::init() { … wstart=1./z1; wend=1./z2; dw=wend-wstart; wcurr=wstart; sstart=s1; send=s2; ds=sstart-send; scurr=sstart; tstart=t1; tend=t2; dt=tstart-tend; tcurr=tstart;}Void EdgeRec::update () { ycurr+=1; xcurr+=dx; wcurr+=dw; scurr+=ds; tcurr+=dt;}

static void RenderScanLine ( … ) { … for (e1 = AEL->ToFront(); e1 != NULL; e1 = AEL->Next() ) { e2=AEL->NextPolyEdge(e1->poly); x1=[e1->xcurr]; x2=[e2->xcurr]; dx=x2-x1; w1=e1->wcurr; w2=e2->wcurr; dw=(w2-w1)/dx; s1=e1->scurr; s2=e2->scurr; ds=(s2-s1)/dx; t1=e1->tcurr; t2=e2->tcurr; dt=(t2-t1)/dx; for (int x=x1; x<x2; x++) { w+=dw; s+=ds; t+=dt; if (w<wbuffer[x]) { wbuffer[x]=w; raster.setPixel(x, texturemap[s,t]) } } }raster->write(y); }

(0,0)

(1,0)

(0,1)

//Note: here we use w=1/z

Page 6: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 6 6.837 Fall 2002

The Result

Wait a minute... that doesn't look right.

What's going on here?

Let's try that out ... Texture mapping applet (image)

Notice how the texture seems to bend and warp along the diagonal triangle edges. Let's take a closer look at what is going on.

Let's try again with a simpler texture... Texture mapping applet (simple texture)

Page 7: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 7 6.837 Fall 2002

Looking at One Edge

First, let's consider one edge from a given triangle. This edge and its projection onto our viewport lie in a single common plane. For the moment, let's look only at that plane, which is illustrated below:

Page 8: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 8 6.837 Fall 2002

Visualizing the Problem

Notice that uniform steps on the image plane do not correspond to uniform steps along the edge.

Let's assume that the viewport is located 1 unit away from the center of projection.

Page 9: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 9 6.837 Fall 2002

Linear Interpolation in Screen Space

Compare linear interpolation in screen space

Page 10: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 10 6.837 Fall 2002

Linear Interpolation in 3-Space

to interpolation in 3-space

Page 11: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 11 6.837 Fall 2002

How to Make Them Mesh Still need to scan convert in screen space... so we need a mapping from t values to s values. We know that the all points on the 3-space edge project onto our screen-space line. Thus we can set up the following equality:

and solve for s in terms of t giving:

Unfortunately, at this point in the pipeline (after projection) we no longer have z1 lingering around (Why?). However, we do have w1= 1/z1 and w2 = 1/z2 .

Page 12: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 12 6.837 Fall 2002

Interpolating Parameters We can now use this expression for s to interpolate arbitrary parameters, such as texture indices (u, v), over our 3-space triangle. This is accomplished by substituting our solution for s given t into the parameter interpolation.

Therefore, if we premultiply all parameters that we wish to interpolate in 3-space by their corresponding w value and add a new plane equation to interpolate the w values themselves, we can interpolate the numerators and denominator in screen-space.

We then need to perform a divide a each step to get to map the screen-space interpolants to their corresponding 3-space values.

Once more, this is a simple modification to our existing triangle rasterizer.

Page 13: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 13 6.837 Fall 2002

Modified Rasterizer Void EdgeRec::init() { … wstart=1./z1; wend=1./z2; dw=wend-wstart; wcurr=wstart; swstart=s1*w1; swend=s2*w2; dsw=swstart-swend; swcurr=swstart; twstart=t1*w1; twend=t2*w2; dtw=twstart-twend; twcurr=twstart;}Void EdgeRec::update () { ycurr+=1; xcurr+=dx; wcurr+=dw; swcurr+=dsw; twcurr+=dtw;}static void RenderScanLine ( … ) { … for (e1 = AEL->ToFront(); e1 != NULL; e1 = AEL->Next() ) { e2=AEL->NextPolyEdge(e1->poly); x1=[e1->xcurr]; x2=[e2->xcurr]; dx=x2-x1; w1=e1->wcurr; w2=e2->wcurr; dw=(w2-w1)/dx; sw1=e1->swcurr; sw2=e2->swcurr; dsw=(sw2-sw1)/dx; tw1=e1->twcurr; tw2=e2->twcurr; dtw=(tw2-tw1)/dx; for (int x=x1; x<x2; x++) { w+=dw; float denom = 1.0f / w; sw+=dsw; tw+=dtw; correct_s=sw*denom; correct_t=tw*denom; if (w<wbuffer[x]) { wbuffer[x]=w; raster.setPixel(x, texturemap[correct_s, correct_t]) } } }raster->write(y); }

Page 14: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 14 6.837 Fall 2002

Demonstration For obvious reasons this method of interpolation is called perspective-correct interpolation. The fact is, the name could be shortened to simply correct interpolation. You should be aware that not all 3-D graphics APIs implement perspective-correct interpolation. Applet with

correct interpolation

You can reduce the perceived artifacts of non-perspective correct interpolation by subdividing the texture-mapped triangles into smaller triangles (why does this work?). But, fundamentally the screen-space interpolation of projected parameters is inherently flawed.

Applet with subdivided triangles

Page 15: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 15 6.837 Fall 2002

Reminds you something?When we did Gouraud shading didn't we interpolate illumination values, that we found at each vertex using screen-space interpolation?

Didn't I just say that screen-space interpolation is wrong (I believe "inherently flawed" were my exact words)?

Does that mean that Gouraud shading is wrong?

Page 16: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 16 6.837 Fall 2002

Gouraud is a big simplification

Gourand shading is wrong. However, you usually will not notice because the transition in colors is very smooth (And we don't know what the right color should be anyway, all we care about is a pretty picture).

There are some cases where the errors in Gouraud shadingbecome obvious.

When switching between different levels-of-detail representations At "T" joints.

Applet showing errors in Gouraud shading

Page 17: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 17 6.837 Fall 2002

Texture Tiling Often it is useful to repeat or tile a texture over the surface of a polygon.

if (w<wbuffer[x]) { wbuffer[x]=w; raster.setPixel(x, texturemap[tile(correct_s, max), tile(correct_t, max)]) }

int tile(int val, int size) {

if (val >= size) {

do { val -= size; } while (val >= size);

} else {

while (val < 0) { val += size; }

}

return val;

} Tiling applet

Can also use symmetries…

Page 18: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 18 6.837 Fall 2002

Texture TransparencyThere was also a little code snippet to handle texture transparency.

if (w<wbuffer[x]) { Color4=raster.setPixel(x, oldColor=raster.getPixel(x); textureColor= texturemap[tile(correct_s, max), tile(correct_t, max)]; float t= textureColor.transparency() newColor = t*textureColor+ (1-t)*oldColor; raster.setPixel(x, newColor)

wbuffer[x]=w; //NOT SO SIMPLE.. BEYOND THE SCOPE OF THIS LECTURE

}

Applet showing texture transparency

Page 19: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 19 6.837 Fall 2002

Summary of Label Textures Increases the apparent complexity of simple geometry

Must specify texture coordinates for each vertex

Projective correction (can't linearly interpolate in screen space)

Specify variations in shading within a primitive

Two aspects of shading

Illumination

Surface Reflectace

Label textures can handle both kinds of shading effects but it gets tedious

Acquiring label textures is surprisingly tough

Page 20: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 20 6.837 Fall 2002

Difficulties with Label Textures

Tedious to specfiy texture coordinates for every triangle

Textures are attached to the geometry

Easier to model variations in reflectance than illumination

Can't use just any image as a label texture

The "texture" can't have projective distortions

Reminder: linear interploation in image space is not equivalent to linear interpolation in 3-space (This is why we need "perspective-correct" texturing). The converse is also true.

Textures are attached to the geometry

Easier to model variations in reflectance than illumination

Makes it hard to use pictures as textures

Page 21: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 21 6.837 Fall 2002

Projective Textures

Treat the texture as a light source (like a slide projector)

No need to specify texture coordinates explicitly

A good model for shading variations due to illumination

A fair model for reflectance (can use pictures)

Page 22: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 22 6.837 Fall 2002

Projective Textures

[Segal et al. 1992]

texture Projected onto the interior of a cube

Page 23: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 23 6.837 Fall 2002

The Mapping ProcessDuring the Illumination process:

For each vertex of triangle(in world or lighting space)

Compute ray from the projective texture's origin to point

Compute homogeneous texture coordinate, [ti, tj, t] (use projective matrix)

During scan conversion (in projected screen space)

Interpolate all three texture coordinates in 3-space(premultiply by w of vertex)

Do normalization at each rendered pixel i = t i / t j = t j / t

Access projected texture

Page 24: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 24 6.837 Fall 2002

Projective Texture ExamplesModeling from photographUsing input photos as textures[Debevec et al. 1996]

Page 25: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 25 6.837 Fall 2002

Adding Texture Mapping to IlluminationTexture mapping can be used to alter some or all of the constants in the illumination equation. We can simply use the texture as the final color for the pixel, or we can just use it as diffuse color, or we can use the texture to alter the normal, or... the possibilities are endless!

Phong's Illumination Model

Constant Diffuse Color Diffuse Texture Color Texture used as Label Texture used as Diffuse Color

Page 26: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 26 6.837 Fall 2002

Texture-Mapping Tricks

Textures and Shading

Combining Textures

Bump Mapping

Solid Textures

Page 27: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 27 6.837 Fall 2002

Shadow MapsProjective Textures with Depth

Textures can also be used to generate shadows. Will be discussed in a later lecture

Page 28: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 28 6.837 Fall 2002

Environment Maps If, instead of using the ray from the surface point to the projected texture's center, we used the direction of the reflected ray to index a texture map. We can simulate reflections. This approach is not completely accurate. It assumes that all reflected rays begin from the same point.

Page 29: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 29 6.837 Fall 2002

What's the Best Chart?

Page 30: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 30 6.837 Fall 2002

Reflection Mapping

Page 31: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 31 6.837 Fall 2002

Questions?Image computed using the Dali ray tracer by Henrik Wann jensenEnvironment map by Paul Debevec

Page 32: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 32 6.837 Fall 2002

Page 33: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 33 6.837 Fall 2002

Texture Mapping Modes Label textures Projective textures Environment maps Shadow maps …

Page 34: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 34 6.837 Fall 2002

The Best of All WorldsAll these texture mapping modes are great!

The problem is, no one of them does everything well.

Suppose we allowed several textures to be applied to each primitive during rasterization.

Page 35: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 35 6.837 Fall 2002

Multipass vs. Multitexture

Multipass (the old way) - Render the image in multiple passes, and "add" the results.

Multitexture - Make multiple texture accesses within the rasterizing loop and "blend" results.

Blending approaches:

Texture modulation

Alpha Attenuation

Additive textures

Weird modes

Page 36: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 36 6.837 Fall 2002

Texture Mapping in QuakeQuake uses light maps in addition to texture maps. Texture maps are used to add detail to surfaces, and light maps are used to store pre-computed illumination. The two are multiplied together at run-time, and cached for efficiency.

Texture Maps

Light Maps

Data RGB Intensity

Instanced Yes No

Resolution High Low

Light map imageby Nick Chirkov

Page 37: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 37 6.837 Fall 2002

Bump MappingTextures can be used to alter the surface normal of an object. This does not change the actual shape of the surface -- we are only shading it as if it were a different shape! This technique is called bump mapping. The texture map is treated as a single-valued height function. The value of the function is not actually used, just its partial derivatives. The partial derivatives tell how to alter the true surface normal at each point on the surface to make the object appear as if it were deformed by the height function.

Since the actual shape of the object does not change, the silhouette edge of the object will not change. Bump Mapping also assumes that the Illumination model is applied at every pixel (as in Phong Shading or ray tracing).

Sphere w/Diffuse Texture

Swirly Bump Map

Sphere w/Diffuse Texture & Bump Map

Page 38: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 38 6.837 Fall 2002

Bump mapping

TvuzvuyvuxP )],(),,(),,([

vu PPN

NvuBPP

),(

2

),(),( tsBtsBBu

2

),(),( tsBtsBBv

Compute bump map partials by numerical differentiation

Initial point

Normal

Simulated elevated point after bump

Variation of normal in u direction

Variation of normal in v direction

D

vvuu PBPBNN

If Pu and Pv are orthogonal and N is normalized: N

vP

uP

N

D

D'P

P

Page 39: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 39 6.837 Fall 2002

Bump mapping

TvuzvuyvuxP )],(),,(),,([

vu PPN

N

NvuBPP

),(

D

uvvu

N

PNBPNBNN

N

vP

uP

vPN

uPN

N

D

2

),(),( tsBtsBBu

2

),(),( tsBtsBBv

Compute bump map partials by numerical differentiation

Initial point

Normal

Simulated elevated point after bump

Variation of normal in u direction

Variation of normal in v direction

General case

Page 40: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 40 6.837 Fall 2002

N

NB

N

NBPP uuuu

N

NB

N

NBPP vvvv

Bump mapping derivation

N

NvuBPP

),(

vu PPN

2

)()()(

N

NNBB

N

NPB

N

PNBPPN vuuvvuvu

0

0small... very is Assume B

so 0 and N ,But NNPNPNPP uuvu

N

PNB

N

PNBNN uvvu

)()(

Page 41: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 41 6.837 Fall 2002

More Bump Map Examples

Cylinder w/Diffuse Texture Map

Bump Map

Cylinder w/Texture Map & Bump Map

Page 42: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 42 6.837 Fall 2002

One More Bump Map Example

Notice that the shadow boundaries remain unchanged.

Page 43: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 43 6.837 Fall 2002

Displacement MappingWe use the texture map to actually move the surface point. This is called displacement mapping. How is this fundamentally different than bump mapping?

The geometry must be displaced before visibility is determined. Is this easily done in the graphics pipeline? In a ray-tracer?

Page 44: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 44 6.837 Fall 2002

Displacement Mapping Example

It is possible to use displacement maps when ray tracing.

Image from

Geometry Caching for Ray-Tracing Displacement

Maps

by Matt Pharr and Pat Hanrahan.

Page 45: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 45 6.837 Fall 2002

Another Displacement Mapping Example

Image from Ken Musgrave

Page 46: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 46 6.837 Fall 2002

Three Dimensional or Solid Textures

The textures that we have discussed to this point are two-dimensional functions mapped onto two-dimensional surfaces. Another approach is to consider a texture as a function defined over a three-dimensional surface. Textures of this type are called solid textures.

Solid textures are very effective at representing some types of materials such as marble and wood. Generally, solid textures are defined procedural functionsrather than tabularized or sampled functions as used in 2-D (Any guesses why?)

The approach that we will explore is based on An Image Synthesizer, by Ken Perlin, SIGGRAPH '85.

The vase to the right is from this paper.

Page 47: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 47 6.837 Fall 2002

Noise and TurbulenceWhen we say we want to create an "interesting" texture, we usually don't care exactly what it looks like -- we're only concerned with the overall appearance. We want to add random variations to our texture, but in a controlled way. Noise and turbulence are very useful tools for doing just that.

A noise function is a continuous function that varies throughout space at a uniform frequency. To create a simple noise function, consider a 3D lattice, with a random value assigned to each triple of integer coordinates:

Page 48: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 48 6.837 Fall 2002

Turbulence Noise is a good start, but it looks pretty ugly all by itself. We can use noise to make a more interesting function called turbulence. A simple turbulence function can be computed by summing many different frequencies of noise functions:

One Frequency Two Frequencies Three Frequencies Four Frequencies

Now we're getting somewhere. But even turbulence is rarely used all by itself. We can use turbulence to build even more fancy 3D textures...

Page 49: Lecture 15Slide 16.837 Fall 2002 Texture Mapping Why texture map? How to do it How to do it right Spilling the beans A couple tricks Difficulties with

Lecture 15 Slide 49 6.837 Fall 2002

Marble Example

We can use turbulence to generate beautiful 3D marble textures, such as the marble vase created by Ken Perlin. The idea is simple. We fill space with black and white stripes, using a sine wave function. Then we use turbulence at each point to distort those planes.

By varying the frequency of the sin function, you get a few thick veins, or many thin veins. Varying the amplitude of the turbulence function controls how distorted the veins will be.

Marble = sin(f * (x + A*Turb(x,y,z)))