Top Banner
Texture Mapping
32

Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

May 11, 2018

Download

Documents

TranAnh
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 - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Texture Mapping

Page 2: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Textures Provide Details

Page 3: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Makes Graphics Pretty

• Details creates immersion• Immersion creates fun

Page 4: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Basic Idea

Paint pictures on all of your polygons• adds color data• adds (fake) geometric

and texture detail

one of the basic graphics techniques• tons of hardware support

Page 5: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Texture Mapping

• Map between region of plane and arbitrary surface

• Ensure “right things” happen as textured polygon is rendered and transformed

Page 6: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Parametric Texture Mapping• Texture size and orientation tied

to polygon• Texture can modulate diffuse

color, specular color, specular exponent, etc

• Separation of “texture space” from “screen space”

• UV coordinates of range [0…1]

Page 7: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Retrieving Texel Color• Compute pixel

(u,v) using barycentric interpolation

• Look up texture pixel (texel)

• Copy color to pixel• Apply shading

Page 8: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

How to Parameterize?Classic problem: How to parameterize the

earth (sphere)?

Very practical, importantproblem in Middle Ages…

Page 9: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Latitude & Longitude

Distorts areas and angles

Page 10: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Planar Projection

Covers only half of the earthDistorts areas and angles

Page 11: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Stereographic Projection

Distorts areas

Page 12: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Albers Projection

Preserves areas, distorts aspect ratio

Page 13: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Fuller Parameterization

Page 14: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

No Free Lunch

Every parameterization of the earth either:• distorts areas• distorts distances• distorts angles

Page 15: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Good Parameterizations

• low area distortion• low angle distortion• no obvious seams• one piece

Page 16: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Planar Parameterization

Project surface onto plane• quite useful in practice• only partial coverage• bad distortion when

normals perpendicular

Page 17: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Planar Parameterization

In practice: combine multiple views

Page 18: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Cube Map/Skybox

Page 19: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Cube Map Textures• 6 2D images arranged like faces of a cube

• +X, -X, +Y, -Y, +Z, -Z• Index by unnormalized vector

Page 20: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Cube Map vs SkyboxCube maps map reflections to

emulate reflective surface (e.g. environment mapping in local illumination)

Skyboxes provide scene information where there is no geometry

Functionally the same — just different use cases!

cubemapped reflection

skybox background

Page 21: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Storing Textures

• texture sizes traditionally powers of 2• textures usually compressed on GPU• textures can be 3D• huge memory hog!

Page 22: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Texture Atlas

Break up surface into easy pieces, parameterize separately

Page 23: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Texture Atlas

Some automatic methods exist…

but often artists hand-paint UV coords

Page 24: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Texture Mapping Flaws

Texture mapping adds fake geometric details but still looks flat

How to fix?

Page 25: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Normal MapKey idea: modify normals of flat face

Rendered surface• is flat• shaded as if it were bumpy

Page 26: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Normal MapHow to represent normals?

Encode as second texture (same size)• (r,g,b) encodes coordinates of normal

Page 27: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Applying Normal Map

Page 28: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Bump Mapping

Older technique: give offset height only

Less flexible than normal map

To use, convert to normal map

Page 29: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Displacement Map

Like normal map, but change normals and geometry

• Fully correct

• Slow

Page 30: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Parallax Map

Take into account shift in texture coordinates

Page 31: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

Parallax Map Example

Page 32: Texture Mapping - University of Texas at Austintheshark/courses/cs354/... ·  · 2017-09-18Texture Mapping • Map between region of plane and arbitrary surface • Ensure “right

In-Class Activity

Create the pseudocode for including cube-mapping in a ray tracer