Top Banner
1 Texture Motivation: to model realistic objects need surface detail: wood grain, stone roughness, scratches that affect shininess, grass, wall paper. Use geometry, model surface detail with polygons; good for large scale detail, too expensive otherwise. Improvement: map an image of the details onto simple geometry
35
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Texture mapping

1

Texture

Motivation: to model realistic objects need surface detail: wood grain, stone roughness, scratches that affect shininess, grass, wall paper.

Use geometry, model surface detail with polygons; good for large scale detail, too expensive otherwise.

Improvement: map an image of the details onto simple geometry

Page 2: Texture mapping

2

The wall

Page 3: Texture mapping

3

The wall

Page 4: Texture mapping

4

The Wall: Brick

Page 5: Texture mapping

5

The Wall: Checkers

Page 6: Texture mapping

6

Texture Mapping

s

t

x

y

z

image

geometry screen

Page 7: Texture mapping

7

Texture Mapping

geometry pipelinevertices

pixel pipelineimage

rasterizer

Images and geometry flow through separate pipelines that join at the rasterizer “complex” textures do not affect

geometric complexity

Page 8: Texture mapping

8

Texture mapping Texture mapping: adding surface detail

by mapping texture patterns to the surface

Technique developed by Catmull (1974), Blinn and Newell (1976).

Page 9: Texture mapping

9

Texture mapping methods

2D texture mapping: paint 2D pattern onto the surface

Environmental (reflection) mapping Bump mapping: Disturb surface

normal to fool shading algorithms Procedural texture mapping, 3D

texture

Page 10: Texture mapping

10

More Examples

Page 11: Texture mapping

11

Environment Mapping

Page 12: Texture mapping

12

2D texture mapping overview

Texture array is a 2D image pattern With elements texels Value at a texel affects surface

appearance The “texture map” determines how

the pattern lies on the surface

Page 13: Texture mapping

13

2D texture mapping overview

Rendering uses the texture mapping Find surface that is front most at

current pixel Find the surface patch corresponding to

the pixel Find the part of the texture pattern

corresponding to the surface patch Use that part of the texture pattern in

setting the pixel color

Page 14: Texture mapping

14

Page 15: Texture mapping

15

2D texture mapping

Source: 2D pattern from drawing, photo, procedure

Destination: any surface, easier if surface given in parametric form

The map from 2D texture coord; to 3D object

Texture mapping transformation: 2D screen coord; 3D object coord; 2D texture coord; and back (see previous slide)

Page 16: Texture mapping

16

Mapping the 2D texture to the surface

The map: 2D texture(s,t) 3D object(x,y,z)

Mapping onto triangle is not difficult Mapping onto triangular mesh is more

difficult (have to handle texture discontinuity)

Mapping onto parametric surface is easier Alternative: use an intermediate

parametric surface (cylinder, sphere)

Page 17: Texture mapping

17

Based on parametric texture coordinates

glTexCoord*() specified at each vertex

s

t1, 1

0, 1

0, 0 1, 0

(s, t) = (0.2, 0.8)

(0.4, 0.2)

(0.8, 0.4)

A

B C

a

bc

Texture Space Object Space

Mapping a Texture

Page 18: Texture mapping

18

Mapping texture onto parametric surface Point on the parametric surface

),(),,(),,(: vuzzvuyyvuxxp

Page 19: Texture mapping

19

Mapping texture onto parametric surface using liner map

The map from texture to the parametric coord using invertible linear map between the texture space (s,t) and the domain (u,v)

),(),,(),,(: vuzzvuyyvuxxp

fetdsv

cbtasu

Page 20: Texture mapping

20

Mapping texture onto parametric surface, example

Does not take into account curvature of surfaceEqual size texture patches are stretched to fit various areas

Page 21: Texture mapping

21

Mapping texture to a surface using an intermediate surface

Two-step mapping Map the texture to a simple

intermediate surface (sphere, cylinder, cube)

Map the intermediate surface (with the texture) onto the surface being rendered

Page 22: Texture mapping

22

Two-step mapping example

• parametric form cylinder: x = r cos(2 PI u) y = r sin(2 PI u) z = v h 0<=u,v<=1 first step: u = s, v = t • sphere • cube

Page 23: Texture mapping

23

Two-step mapping example

• Second-step: map intermediate surface to the surface being rendered• Various strategies: a, b, c

Page 24: Texture mapping

24

The texture mapping transformation

Page 25: Texture mapping

25

Texture mapping transformation

Consider surface visible at current pixel.Find the patch on the surface that corresponds to it.

•Map screen coord of pixel corners back to object•Find texels that map to the surface patch•If multiple texels lie on patch combine them: weighted avg; supersampling with postfiltering

Page 26: Texture mapping

26

2DTexture mapping in OpenGL

Pixel pipeline

Texture map done at rasterization stage

Page 27: Texture mapping

27

Environment Mapping

Yoshihiro Mizutani and Yoshihiro Mizutani and Kurt Reindel Kurt Reindel

Page 28: Texture mapping

28

Environment Mapping II

Put texture on a highly reflectivehighly reflective object by picking up texture from the environment in which the object is absorbed/occupied.

Realized as two-step process Project the environment (excluding the

object) onto an intermediate surface. Place object back, and map texture

from intermediate surface to object

Page 29: Texture mapping

29

Environment Mapping III: methods

Sphere mapping Cube mapping

Page 30: Texture mapping

30

Sphere Mapping

Blinn and Newell’s method: for each environment mapped pixel compute the (viewer) reflection vector

Technical Brief: Perfect Technical Brief: Perfect reflections and Specular reflections and Specular ….….

Page 31: Texture mapping

31

Cubic mapping

Introduced by Greene in 1986. Put a camera in the environment center and

then project the environment onto the sides of a cube centered at the camera position.

Page 32: Texture mapping

BUMP Mapping

Bump mapping is a technique in computer graphics for simulating bumps and wrinkles on the surface of an object. This is achieved by perturbing the surface normal of the object and using the perturbed normal during lighting calculations. The result is an apparently bumpy surface rather than a smooth surface although the surface of the underlying object is not actually changed. Bump mapping was introduced by Blinn in 1978.

32

Page 33: Texture mapping

33

Bump mapping

2D Texture map creates odd looking rough surfaces

Bump mapping: texture map that alters surface normals. Use texture array to set a function which

perturbs surface normals Altered normals match a bumpy surface Applying illumination model to the new

normals shades the bumps correctly

Page 34: Texture mapping

34

Bump mapping• Bump map is in texture array: d(s,t) << 1• p point on the surface corresponding to texture coordinates s,t.• N the normal at p • p’ the bump point for p p’ = p + d(s,t)NWe actually do not “bump” the surface, just the normal at p. • N’ the normal at p’ . This normal used by the illumination model at p.

Page 35: Texture mapping

35

Bump mapping How to get N’ :

• given two vectors tangent to the bumpy surface, N’ is their cross product• The two vectors follow from the partial derivatives of the p’ equation wrt u,v p’ = p + d(s,t)N • These partial derivatives expressed in terms of the derivatives of d(s,t) as s,t change