Computer Graphics Course 2006 Texture Mapping Part of the slides - - PowerPoint PPT Presentation

computer graphics course 2006
SMART_READER_LITE
LIVE PREVIEW

Computer Graphics Course 2006 Texture Mapping Part of the slides - - PowerPoint PPT Presentation

Computer Graphics Course 2006 Texture Mapping Part of the slides are by: Raanan Fattal David Akers Durand and Cutler Texture Mapping Motivation Definition of 2D texture mapping Coordinate generation, interpolation Different


slide-1
SLIDE 1

Computer Graphics Course 2006

Texture Mapping

Part of the slides are by: Raanan Fattal David Akers Durand and Cutler

slide-2
SLIDE 2

Texture Mapping

Motivation Definition of 2D texture mapping Coordinate generation, interpolation Different uses of 2D textures Beyond 2D textures

slide-3
SLIDE 3

The Problem:

Motivation: Add interesting and/ or realistic

detail to surfaces of objects.

Problem: Fine geometric detail is difficult

to model and expensive to render.

slide-4
SLIDE 4

The Problem:

We don't want to represent all this detail

with geometry

slide-5
SLIDE 5

Texture Mapping

Idea: Modify various shading parameters of the surface by

mapping a function (such as a 2D image) onto the surface.

Given an image, think of it as a 2D function from [ 0,1] 2

(texture coordinates) to the RGB color space:

For each geometric primitive, define a mapping M that

maps points on the surface to texture coordinates:

To shade a pixel corresponding to a point (x,y,z) on the

surface, use the color:

) , , ( ) , ( b g r v u T → ) , , ( ) , ( b g r v u T →

M x y z u v ( , , ) ( , ) = M x y z u v ( , , ) ( , ) =

( , , ) ( ( , , )) r g b T M x y z = ( , , ) ( ( , , )) r g b T M x y z =

slide-6
SLIDE 6

Texture Mapping Example

Texture: Result:

slide-7
SLIDE 7

The Quest for Visual Realism

slide-8
SLIDE 8

Texture Mapping

So, what do we have to do in order to

make this idea work?

Coordinates generation/ assignment Interpolation

The basic idea is simple, but…

Large number of details Still an active research area

We will make an overview of some of the

issues today.

Next time you will learn how to use/ implement

part of the ideas here with OpenGL

slide-9
SLIDE 9

Texture Coordinates

To render a textured triangle, we must

start by assigning a texture coordinate to each vertex

A texture coordinate is a 2D point [ t x t y] in

texture space that is the coordinate of the image that will get mapped to a particular vertex

slide-10
SLIDE 10

Texture Mapping

v0 v1 v2 t2 t0 t1

(1,1) (0,0) x y Texture Space Triangle (in any space)

slide-11
SLIDE 11

Texture Interpolation

The actual texture mapping computations take

place at the scan conversion and pixel rendering stages of the graphics pipeline

During scan conversion, as we are looping

through the pixels of a triangle, we must interpolate the t xt y texture coordinates in a similar way to how we interpolate the rgb color and z depth values

As with all other interpolated values, we must

precompute the slopes of each coordinate as they vary across the image pixels in x and y

Once we have the interpolated texture

coordinate, we look up that pixel in the texture map and use it to color the pixel

slide-12
SLIDE 12

Interpolation for triangles

C B A λ1 λ2 λ3 D E

C A D ) 1 (

1 1

λ λ − + = C B E ) 1 (

2 2

λ λ − + = E D F ) 1 (

3 3

λ λ − + =

F

) ) 1 ( )( 1 ( ) ) 1 ( (

2 2 3 1 1 3

C B C A F λ λ λ λ λ λ − + − + − + =

C B A F

c b a

λ λ λ + + =

Linear Interpolation: Bilinear Interpolation

slide-13
SLIDE 13

Let’s start with the details

Where are a lot of issues with both texture

coordinates generation/ assignment and interpolation

Let’s start with the former Any ideas?

slide-14
SLIDE 14

Photo-textures

slide-15
SLIDE 15

Texture Mapping Difficulties

Tedious to specify

texture coordinates

Acquiring textures is

surprisingly difficult

Photographs have

projective distortions

Variations in

reflectance and illumination

Tiling problems

slide-16
SLIDE 16

Painting on textures

slide-17
SLIDE 17

Texture Chart

Pack triangles into

a single image

slide-18
SLIDE 18

What does a texture map for a complex model “look like”?

slide-19
SLIDE 19

Texture coordinate generation

planar cylindrical spherical shrink-wrap cube face

slide-20
SLIDE 20

Parametrizing Objects

Certain objects have a natural parametrization

(e.g., Bezier patches)

Polygons (triangles): each vertex is assigned a

pair of texture coordinates (u,v). Inside, linear interpolation is used.

How do we handle a more complex object?

slide-21
SLIDE 21

Two-Step Texture Mapping

(Bier and Sloan 1986)

Step I: define a mapping between the

texture and some intermediate surface:

plane cylinder sphere cube

Step II: Project intermediate surface onto

  • bject surface
slide-22
SLIDE 22

Intermediate Surface Projections

slide-23
SLIDE 23

Projective Textures

Use the texture

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)

slide-24
SLIDE 24

That’s what we get when we just interpolate the coordinates

slide-25
SLIDE 25

Magnification and minification

texture polygon texture polygon

m agnification m inification

slide-26
SLIDE 26

Better magnification

slide-27
SLIDE 27

Better minification

slide-28
SLIDE 28

Another Solution: Mipmapping

slide-29
SLIDE 29

Mip-mapping

Mip-mapping

MIP = Multim in Parvo (many things in a small

place)

Idea: store texture as a pyramid of

progressively lower-resolution images, filtered down from original

slide-30
SLIDE 30

Mip-Mapping Depth of Mip-Map

slide-31
SLIDE 31

Mip Mapping

R G B

R G B

B G R

slide-32
SLIDE 32

Mip Mapping

Which level of mip-map to use?

Think of mip-map as 3-D pyramid Index into mip-map with 3 coordinates: u, v, d

(depth)

The size of the filter (i.e., d in the mip-

map) depends on the pixel coverage area in the texture map

In general, treat d as a continuous value Blend between nearest mip-map level using

linear interpolation

slide-33
SLIDE 33
slide-34
SLIDE 34

Common Artifacts

BTW: do you recognize this head? Better results can be achieved with trilinear filtering

slide-35
SLIDE 35

Fun stuff

As we already saw in this course, hacks

and ad-hoc solutions are part of the CG

Especially in the real-time rendering

Let’s see some really nice and unintended

use of mip-maps.

From the Kevin Bjorke(NVIDIA) talk in the

GDC.

slide-36
SLIDE 36

Color & Depth

I want to create a long

tunnel with a haze…

slide-37
SLIDE 37

Color & Depth

slide-38
SLIDE 38
slide-39
SLIDE 39

Color & Depth

  • The “correct”/ analytical way to

achieve the same result is to compute “Facing Ratio”: (N·V)

C = lerp(mossColor, texColor, pow(dot(N,V)),expon))

slide-40
SLIDE 40

Wrapping up some concepts together…

Is that a good idea to

use this chart “as is” with a mip mapping?

slide-41
SLIDE 41

Hackish, but…

The evil you see versus the evil you don’t

see

slide-42
SLIDE 42

What's Missing?

What's the difference between a

real brick wall and a photograph of the wall texture-mapped onto a plane?

What happens

if we change the lighting or the camera position?

slide-43
SLIDE 43

Bump Mapping

Use textures to alter the surface normal

Does not change the actual shape of the surface Just shaded as if it were a different shape

Sphere w/Diffuse Texture Swirly Bump Map Sphere w/Diffuse Texture & Bump Map

slide-44
SLIDE 44

Bump Mapping

Treat the texture as a single-valued height function Compute the normal from the partial derivatives in the

texture

slide-45
SLIDE 45

Another Bump Map Example

Cylinder w/Diffuse Texture Map Bump Map Cylinder w/Texture Map & Bump Map

slide-46
SLIDE 46

What's Missing?

There are no bumps on

the silhouette of a bump-mapped object

Bump maps

don’t allow self-occlusion

  • r self-shadowing
slide-47
SLIDE 47

Generalization: Normal Mapping

slide-48
SLIDE 48

Displacement Mapping

Use the texture map to actually move the surface point The geometry must be displaced before visibility is

determined

slide-49
SLIDE 49

Displacement Mapping

Image from: Geometry Caching for Ray-Tracing Displacement Maps by Matt Pharr and Pat Hanrahan.

note the detailed shadows cast by the stones

slide-50
SLIDE 50

Ken Musgrave

Displacement Mapping

slide-51
SLIDE 51

Environment Maps

We can simulate reflections by using the direction of the

reflected ray to index a spherical texture map at "infinity".

Assumes that all reflected rays

begin from the same point.

slide-52
SLIDE 52

What's the Best Choice?

slide-53
SLIDE 53

Environment Mapping Example

Terminator II. Do you remember a movie that used it before that? Hint: same director…

slide-54
SLIDE 54

Texture Maps for Illumination (“Static Light Maps“)

slide-55
SLIDE 55

Combining textures

One of the basic and prevalent techniques

in a (real-time) CG

We will talk more about generalization of

those ideas in GPU lesson

slide-56
SLIDE 56

Billboarding

slide-57
SLIDE 57

Billboarding

slide-58
SLIDE 58

Billboarding examples

slide-59
SLIDE 59

Billboarding

slide-60
SLIDE 60

Solid Textures

(Peachey 1985, Perlin 1985)

Problem: mapping a 2D image/ function

  • nto the surface of a general 3D object is

a difficult problem:

Distortion Discontinuities

Idea: use a texture function defined over

a 3D domain - the 3D space containing the object

Texture function can be digitized or procedural

slide-61
SLIDE 61
slide-62
SLIDE 62
slide-63
SLIDE 63
slide-64
SLIDE 64

Procedural Textures

Advantages:

compact representation (code vs. data) unlimited resolution unlimited extent controllable via parameters

Disadvantages:

Can be difficult to program and debug Can be difficult to predict and control Typically slower to evaluate Can be difficult to pre-filter

slide-65
SLIDE 65

.kkrieger

Download and play with it in your spare time.

slide-66
SLIDE 66
slide-67
SLIDE 67

Questions?

Image by Henrik Wann Jensen Environment map by Paul Debevec