07.11.2014 Views

Texturing - CS Course Webpages

Texturing - CS Course Webpages

Texturing - CS Course Webpages

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Texturing</strong>


Texture Mapping<br />

• Geometry and lighting alone do not provide<br />

sufficient visible detail<br />

• Going from 3‐D to 2‐D<br />

“Paste” 2D image onto 3D surface<br />

• Surface appears much more complex than<br />

reality<br />

2/107


Texture Mapping


Texture Mapping<br />

4/107


Texture Mapping<br />

5/107


Texture Mapping<br />

6/107


Texture Mapping<br />

• Assume texture parameterized by u, v<br />

v<br />

1<br />

0<br />

0<br />

u<br />

1<br />

7/107


Texture Mapping<br />

• Any u, v coordinate maps to a point on the<br />

image<br />

v<br />

1<br />

0<br />

0<br />

u<br />

1<br />

8/107


Texture Mapping<br />

• Associate texture coordinates with each<br />

vertex on the surface<br />

v<br />

1<br />

0<br />

0<br />

u<br />

1<br />

9/107


Texture Mapping<br />

• During polygon drawing, lookup color from<br />

texture using interpolated texture coordinates<br />

v<br />

1<br />

0<br />

0<br />

u<br />

1<br />

10/107


<strong>Texturing</strong>: Geometry<br />

1. Compute object space location (x, y, z) from screen<br />

space location (i, j)<br />

2. Use projector function to obtain object surface coordinates<br />

(s, t ) from (x,y,z)<br />

(Usually we don’t care about the interior of the object)<br />

3. Corresponder function to find texel<br />

coordinates (u, v)<br />

11/107


Cylindrical Projector<br />

• Convert rectangular coordinates (x, y, z) to<br />

cylindrical (r, theta, phi), use only<br />

(theta, phi) to index texture image


Spherical projector<br />

• Convert rectangular coordinates (x, y, z) to<br />

spherical (theta, phi)<br />

Spherical projector


Sampling Textures<br />

1. Nearest neighbor<br />

Blocky results<br />

2.Bilinear Interpolation<br />

Smooth<br />

u,v


Nearest neighbor<br />

• Assume we can compose the previous steps<br />

(projector, corresponder, etc.) to define a<br />

transformation function M from integer screen<br />

coordinates (i, j) to real‐valued texture coordinates<br />

(s, t) such that M (i, j) = (s, t)<br />

• Now we just copy the texel at (round(s),<br />

round(t)) to the pixel at (i, j) and we’re done,<br />

right?


• Problem is that it can cause aliasing effects<br />

• Why? Because the round() function causes<br />

discontinuous switches in which texel is<br />

nearest and hence is the color drawn


Nearest Neighbor<br />

Blocky results


Bilinear Interpolation (BLI)<br />

Idea: Blend four texel values surrounding<br />

source, weighted by nearness<br />

Vertical blend<br />

Horizontal blend


Deal with Range<br />

• repeat: Start entire texture over<br />

• mirror: Flip copy of texture in each direction<br />

– Get continuity of pattern<br />

• clamp to border: Surround with border color


Other Uses of Texture Mapping<br />

• Environment Mapping<br />

• Bump/Normal Mapping<br />

• Displacement Mapping<br />

• ….<br />

• Any attribute of the surface position, normal,<br />

color, etc… can be placed in a texture<br />

20/107


Environment Mapping<br />

• Problem: To render pixel on mirrored surface<br />

correctly, we need to follow reflection of eye<br />

vector back to first intersection with another<br />

surface and get its color(especially for glass<br />

surface, metal surface...)<br />

• This is an expensive procedure with ray<br />

tracing<br />

• Idea: Approximate with texture mapping


Environment Mapping<br />

• Key idea: Render 360 degree view of<br />

environment from center of object with<br />

sphere or box as intermediate surface<br />

• Intersection of eye reflection vector with<br />

intermediate surface provides texture<br />

coordinates for reflection/environment<br />

mapping<br />

22/107


Environment Mapping<br />

23/107


Environment Mapping(Cube mapping)<br />

24/107


Environment Mapping<br />

25/107


Environment Mapping<br />

N<br />

26/107


Environment Mapping<br />

N<br />

27/107


Bump/Normal Mapping<br />

• Specify perturbation of normals by texture<br />

• Height map: store scalar “altitude”<br />

• Normal map: store nomals in RGB<br />

28/107


Bump/Normal Mapping Example<br />

30/107


Bump/Normal Mapping Example<br />

31/107


Displacement Mapping<br />

• Offset geometry in direction of normal<br />

• Encode offset inside texture<br />

• Used to actually change the geometry and<br />

provide more detail<br />

• Difficult/expensive to perform with current<br />

hardware<br />

32/107


Displacement Mapping Example<br />

33/107


Problems with Texture Mapping<br />

• Textures composed of separate pieces called<br />

“charts”<br />

• Boundaries don’t match<br />

• Sampling issues<br />

• ……<br />

34/107

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!