Docsity

Radiosity, Lecture Notes - Animation, Study notes of Computer Graphics and Animation

Toggle sidebar
bg1
1
Lecture 21 Slide 1 6.837 Fall 2001
Texture-Mapping Tricks
๎š„Combining Textures
๎š„Filtering Textures
๎š„Textures and Shading
๎š„Bump Mapping
๎š„Solid Textures
Lecture 21 Slide 2 6.837 Fall 2001
Texture Mapping Modes
๎š„Label textures
๎š„Projective textures
๎š„Environment maps
๎š„Shadow maps
๎š„โ€ฆ
Lecture 21 Slide 3 6.837 Fall 2001
The Best of All Worlds
All 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.
Lecture 21 Slide 4 6.837 Fall 2001
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
pf3
pf4
pf5
pf8

Partial preview of the text

Download Radiosity, Lecture Notes - Animation and more Study notes Computer Graphics and Animation in PDF only on Docsity!

Lecture 21

Slide 1

6.837 Fall 2001

Texture-Mapping Tricks

ย„^ Combining Textures ย„^ Filtering Textures ย„^ Textures and Shading ย„^ Bump Mapping ย„^ Solid Textures

Lecture 21

Slide 2

6.837 Fall 2001

Texture Mapping Modes

ย„^ Label textures ย„^ Projective textures ย„^ Environment maps ย„^ Shadow maps ย„^ โ€ฆ

Lecture 21

Slide 3

6.837 Fall 2001

The Best of All Worlds

All 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 primitiveduring rasterization.

Lecture 21

Slide 4

6.837 Fall 2001

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 loopand "blend" results.Blending approaches:

ย„^ Texture modulation ย„^ Alpha Attenuation ย„^ Additive textures ย„^ Weird modes

Lecture 21

Slide 5

6.837 Fall 2001

Texture Mapping in Quake

Quake 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-computedillumination.

The two are multiplied together at run-time, and cached for

efficiency.^ Resolution

High

Low

Instanced

Yes^

No

Data

RGB^

Intensity

TextureMaps

Light Maps

Light map imageby Nick Chirkov

Lecture 21

Slide 6

6.837 Fall 2001

When texture mapping it is rare that the screen-space sampling densitymatches the sampling density of the texture. Typically one of two thingscan occur:

Sampling Texture Maps Oversampling of the texture or Undersampling of the texture

In the case of oversampling we already know what to do...Interpolation (review on Antialiasing and Resampling). But, how dowe handle undersampling?

Lecture 21

Slide 7

6.837 Fall 2001

How Bad Does it Look?

Let's take a look at what undersampling looks like:Notice how details in the texture, in particular the mortar betweenthe bricks, tend to pop (disappear and reappear).This popping is most noticeable around details (parts of the texturewith a high-spatial frequency). This is indicative of aliasing (high-frequency details showing up in areas where we expect to see lowfrequencies).

Lecture 21

Slide 8

6.837 Fall 2001

We've Seen this Sort of Thing BeforeRemember...

Aliasing?

This was the phenomenon that occurred when we undersampled asignal. It caused certain high frequency features to appear as lowfrequencies. To eliminate aliasing we had to either band limit (low pass filter) our inputsignal or sample it at a higher rate:

Lecture 21

Slide 13

6.837 Fall 2001

MIP Indices

Actually, you have a choice of ways to translate this

gradient value

into a MIP

level.This also brings up one of the shortcomings of MIP mapping. MIP mapping assumesthat both the

u and v components of the texture index are undergoing a uniform

scaling, while in fact the terms

du/dt and

dv/dt are relatively independent. Thus,

we must make some sort of compromise. Two of the most common approaches aregiven below: The differences between these level selection methods is illustrated by theaccompanying figure.

Lecture 21

Slide 14

6.837 Fall 2001

Summed-Area Tables

There are other approaches to computing this prefiltering integration on the fly. One, which was introduced by Frank Crow is called a

summed-area table. Basically, a summed-

area table is a tabularized two-dimensional cumulative distribution function. Imagine having a2-D table of numbers the cumulative distribution function could be found as shown below.

T (x

, y 1 )^ -^ 1 T (x

, y 0 )^ -^ 1

T (x

, y 1 )^ + 0 T (x

, y 0 ) 0

To find the sum of region contained in a box bounded by

(x^0

, y)^0

and

(x^1 , y^1 ) :

This approach can be used to compute the integration of pixels that lie undera pixel by dividing the resulting sum by the area of the rectangle,

(y^1

- y^0 )(x^1 - x ). 0

With a little more work you can compute the area under any four-sidedpolygon (How?).

Lecture 21

Slide 15

6.837 Fall 2001

Summed-Area Tables

ย„How much storage does a summed-area table require? ย„Does it require more or less work per pixel than a MIP map? ย„What sort of low-pass filter does a summed-area table represent? ย„What do you remember about this sort of filter?

No filtering These nice images were originally grabbed from a link on the http://www.gris.unituebingen.de/ web page.

MIP mapping

Summed-Area Table

Lecture 21

Slide 16

6.837 Fall 2001

Phototextures

To this point we've only used textures as labels over geometry.Their applications are much broader, however.

Simple extensions include: ย„^ Spatially varying surface properties:

ยบ^ The diffuse shading coefficient,

k^ , could be stored as a texture.d

ยบ^ Likewise for the intrinsic color,

k^ ,a k^ , ands^

nshiny

.

ย„^ Textures can also be used in a lot of other ways

Lecture 21

Slide 17

6.837 Fall 2001

Adding Texture Mapping to IlluminationTexture mapping can be used to alter some or all of the constants in theillumination 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

Lecture 21

Slide 18

6.837 Fall 2001

Bump Mapping

Textures can be used to alter the surface normal of an object. This does not change the actualshape of the surface -- we are only shading it as if it were a different shape! This technique iscalled

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 tellhow to alter the true surface normal at each point on the surface to make the object appearas if it were deformed by the height function.Since the actual shape of the object does not change, the silhouette edge of the object willnot 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

Lecture 21

Slide 19

6.837 Fall 2001

Bump mapping

T v uz v u y v u x

P^

)]

[=

v

v u^

P

P

N^

v v v^

ร—

N

N

v u B P P^

v

v

v v^

(^

)^

(^

v

v v v v v v

v D

u

v v

u

N

P N B P N B N

N^

ร—

ร—

v N

v P^ v v P u P^ v N^

v v^ ร—

P^ u N^

v v^ ร—โˆ’

v N โ€ฒ^ v^ D

โˆ†

โˆ†+ โˆ’ โˆ†โˆ’ =^

2

), ( ), (^

t s B t sB Bu

โˆ†

โˆ†+

โˆ’ โˆ†โˆ’

=^

2

) ,( ) ,(

ts B ts B Bv^ Compute bump map partialsby numerical differentiation

Lecture 21

Slide 20

6.837 Fall 2001

NB N

NB N

P

P^

u

u u u^

v v v v

v v^

NB N

NB N

P

P^

v

v v v^

v v

v v

v v^

Bump mapping derivation

N

N

v u B P P^

v

v

v v^

v u^

P

P

N^

โ€ฒร—

โ€ฒ^ =

v v v

2

N

N

N

B

B

N

N

P

B

N

P

N

B

P

P

N^

v u u v v u v

u^

v

v v

v

v v

v

v v

v v v^

ร— + ร— + ร— + ร—

small... very is

Assume

B

so 0

and

N

But

= ร— ร— โˆ’ = ร— =

ร—^

N N P N P N P

P^

u

u

v u

v v v v v v v v v N

P

N

B

N

P

N

B

N

N^

u

v v

u^

v

v v

v

v v

v v^

(^

ร—

ร—

Lecture 21

Slide 25

6.837 Fall 2001

Another Displacement Mapping Example

Image from Ken Musgrave

Lecture 21

Slide 26

6.837 Fall 2001

Three Dimensional or Solid TexturesThe textures that we have discussed to thispoint are two-dimensional functions mappedonto two-dimensional surfaces. Anotherapproach is to consider a texture as afunction defined over a three-dimensionalsurface. Textures of this type are called

solid

textures.Solid textures are very effective atrepresenting some types of materials such asmarble and wood. Generally, solid texturesare defined procedural functionsrather thantabularized or sampled functions as used in2-D (Any guesses why?)The approach that we will explore is basedon An Image Synthesizer, by Ken Perlin, SIGGRAPH '85.The vase to the right is from this paper.

Lecture 21

Slide 27

6.837 Fall 2001

Noise and Turbulence

When we say we want to create an "interesting" texture, we usually don'tcare exactly what it looks like -- we're only concerned with the overallappearance. We want to add random variations to our texture, but in acontrolled way. Noise and turbulence are very useful tools for doing justthat.A noise function is a continuous function that varies throughout space at a uniform frequency. To create a simple noise function, consider a 3Dlattice, with a random value assigned to each triple of integercoordinates:

Lecture 21

Slide 28

6.837 Fall 2001

Interpolating Noise

To calculate the noise value of any point in space, we first determinewhich cube of the lattice the point is in. Next, we interpolate the desiredvalue using the 8 corners of the cube: Trilinear interpolation is illustrated above. Higher-order interpolation canalso be used.

Lecture 21

Slide 29

6.837 Fall 2001

Evaluating Noise

Since noise is a 3D function, we can evaluate it at any point we want.We don't have to worry about about mapping the noise to the object,we just use (x, y, z) at each point as our 3D texture coordinates! It is asif we are carving our object out of a big block of noise.

Original Object

Trilinear Noise

Triquadratic Noise

Lecture 21

Slide 30

6.837 Fall 2001

Turbulence

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

One Frequency

Two Frequencies

Three Frequencies

Four Frequencies

Now we're getting somewhere. But even turbulence is rarely used allby itself. We can use turbulence to build even more fancy 3Dtextures...

Lecture 21

Slide 31

6.837 Fall 2001

Marble Example

We can use turbulence to generate beautiful 3Dmarble textures, such as the marble vase created byKen Perlin. The idea is simple. We fill space withblack and white stripes, using a sine wave function.Then we use turbulence at each point to distort thoseplanes.

By varying the frequency of the sin function,

you get a few thick veins, or many thin veins. Varyingthe amplitude of the turbulence function controls howdistorted the veins will be.

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

Lecture 21

Slide 32

6.837 Fall 2001

Next Time - Radiosity