Top Banner
Texture Mapping
45

Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Mar 07, 2018

Download

Documents

dinhcong
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 - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Texture Mapping

Page 2: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

There are limits to geometric modeling

Although modern GPUs can render millions of triangles/sec, that’s not enough sometimes...

National Geographic

http://www.beinteriordecorator.com

Page 3: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Use texture mapping to increase realism through detail

Rosalee Wolfe

This image is just 8 polygons!

Page 4: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

No texture With texture

[Ang

el a

nd S

hrei

ner]

Page 5: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Pixar - Toy Story

Page 6: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Store 2D images in buffers and lookup pixel reflectances

procedural photo

Page 7: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

[Dong et al., 2008]

3D solid textures

Page 8: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Other uses of textures...

Light mapsShadow mapsEnvironment mapsBump mapsOpacity mapsAnimation

[Angel and Shreiner]

[Stam 99]

Page 9: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Texture mapping in the OpenGL pipeline

• Geometry and pixels have separate paths through pipeline

• meet in fragment processing - where textures are applied

• texture mapping applied at end of pipeline - efficient since relatively few polygons get past clipper

Page 10: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

uv Mapping

• 2D texture is parameterized by (u,v)

• Assign polygon vertices texture coordinates

• Interpolate within polygon

Tschmits Wikimedia Commons

Page 11: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps
Page 12: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Texture Calibration

Page 13: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

The major issues in texture mapping...

• What should the actual mapping be?

easy: rectangular surface harder: parametric surface

[Rosalee W

olfe]

Page 14: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Given a point on the object (x,y,z), what point (u,v) in the texture we use?

[Ros

alee

Wol

fe]

Page 15: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Example: planar mapping[R

osal

ee W

olfe

]

Page 16: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Intermediate surfacesFirst map the texture to a simpler, intermediate surface

[Ros

alee

Wol

fe]

Page 17: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Cylindrical mapping

(x,y,z) -> (theta, h) -> (u,v)

[Ros

alee

Wol

fe]

Page 18: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Spherical Mapping

(x,y,z) -> (latitude,longitude)-> (u,v)

[Ros

alee

Wol

fe]

Page 19: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Box Mapping[R

osal

ee W

olfe

]

Page 20: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

How do we map between intermediate and actual objects?

[Ros

alee

Wol

fe]

Page 21: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

How do we map between intermediate and actual objects?

What intermediate shape was used here?

[Ros

alee

Wol

fe]

Page 22: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Cylindrical Spherical

Page 23: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Parametric Surfaces

32 parametric patches

Page 24: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

[Dong et al., 2008]

3D solid textures

can map object (x,y,z) directly to texture (u,v,w)

Page 25: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Procedural textures

e.g., Perlin noise

Rosalee Wolfe

Page 26: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Triangles

Page 27: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Texturing triangles

• Store (u,v) at each vertex• interpolate inside triangles using barycentric coordinates

u

v 1, 10, 1

0, 0 1, 0

(0.4, 0.2)

(0.8, 0.4)

A

B C

a

bc

Texture Space Object Space

(u,v) = (0.2, 0.8) [A

ngel and Shreiner]

Page 28: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Texturing triangles

• Store (u,v) at each vertex• interpolate inside triangles using barycentric coordinates

Page 29: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Texturing triangles

Choice of (u,v) makes big difference

Page 30: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Texturing triangles

Choice of (u,v) makes big difference

texture extended through “tiling”

Page 31: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Texturing triangles

Choice of (u,v) makes big difference

Page 32: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

glTexCoord*()

Textures in OpenGL

• Assign (u,v) to vertices

• OpenGL then uses interpolation for triangle interior

good selection of tex coordinates

poor selection of tex coordinates

texture stretched over trapezoid

showing effects of bilinear interpolation

Page 33: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Multitexturing

Rosalee Wolfe

Page 34: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Texture Sampling

Page 35: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

texture coordinatesobject coordinates

window coordinates

parametric coordinates

[Angel and Shreiner]

Texels Pixels

Texture Mapping

Page 36: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

[Angel and Shreiner]

Point SamplingMap back to texture image and use the nearest texel

pixelpreimage

Page 37: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Aliasing

point samples in (or x,y,z) space

point samples in texture space

miss blue stripes

Point sampling of the texture can lead to aliasing artifacts

[Angel and Shreiner]

Page 38: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Magnification and Minification

Magnification

Minification

Page 39: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Magnification and Minification

Texture Pixels

Magnification MinificationPixelsTexture

More than one texel can cover a pixel (minification) or more than one pixel can cover a texel (magnification)

Can use point sampling (nearest texel) or linear filtering ( 2 x 2 filter) to obtain texture values

Page 40: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Aliasing artifacts

Paul Heckbert

We apply filtering to reduce aliasing

artifacts

Page 41: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Area AveragingA better but slower option is to use area averaging

pixelpreimage

[Angel and Shreiner]

Page 42: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Use bilinear filtering

nearest neighbor bilinear bicubic

Wikipedia

p0 p1

p2p3

p

p = ?

mitigate magnification artifacts

Page 43: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

Mipmapping

Reduce minification artifacts

Prefilter the texture to obtain reduced resolutions

Requires 1/3 more space

Get a texture hierarchy indexed by level

Togikun, Wikimedia Commons

128×128, 64×64, 32×32, 16×16, 8×8, 4×4, 2×2, 1×1

Page 44: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

[Angel and Shreiner]

Page 45: Texture Mapping - UCRshinar/courses/cs230-winter-2016/Lecture17.pdf · 3D solid textures. Other uses of textures... Light maps Shadow maps Environment maps Bump maps Opacity maps

17

mipmapped point

sampling

mipmapped linear filtering

linear filtering

point sampling [A

ngel and Shreiner]