33
Texture Mapping COMP 575/770 Spring 2013

Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Texture Mapping

COMP 575/770

Spring 2013

Page 2: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Textures

Goal: Add visual detail to 3D objects

Page 3: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Textures

Option 1: Model everything with lots of little triangles

Way too much work (for computers and for people)

Option 2: Paint an image on the model

The image is called a texture

Page 4: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Texture Mapping Overview

(x,y,z) (s,t)

0 1

1

(u,v)

0 1

1

(u,v)

Map each point on the surface to a point in the texture image

Page 5: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Outline

Introduction

Surface Parameterization

Texture Mapping

Texture Filtering

Variations

Page 6: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Surface Parameterization

How to assign (u,v) coordinates to a surface?

Trivial for rectangles

Easy for spheres too (just use longitude, latitude)

[ma

p: P

ete

r H. D

an

a]

Page 7: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Surface Parameterization

Easy for other parametric surfaces

Surfaces defined by functions of two variables

[Wo

lfe

/ S

G9

7 S

lide

se

t]

Page 8: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Surface Parameterization

Not so easy for bunnies

Or other arbitrary triangle meshes

Typically performed by 3D modeling software

Page 9: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Surface Parameterization

Option 1: Project to parametric surfaces

[CS

46

7 s

lide

s]

Page 10: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Surface Parameterization

Option 2: Unwrap the model

[Piponi 2000]

Page 11: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Surface Parameterization

Option 3: Make an atlas

charts atlas surface

[Sander 2001]

Page 12: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Outline

Introduction

Surface Parameterization

Texture Mapping

Texture Filtering

Variations

Page 13: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Texture Mapping

After parameterization, we get (u,v) coordinates for each vertex

Use interpolation for (u,v) values in the interior of triangles

Essentially, (u,v) texture coordinates are another vertex attribute

Page 14: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Texture Mapping

Let’s use this method to apply a checkerboard pattern to a square, viewed at an angle

This is what we want:

Page 15: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Texture Mapping

This is what we get:

Page 16: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Perspective-Correct Mapping

Fundamental problem with interpolation in screen-space

Uniform screen-space steps ≠ uniform world-space steps

Page 17: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Perspective-Correct Mapping

Perspective foreshortening doesn’t get applied to texture coordinates with linear interpolation

Instead of interpolating (u,v), interpolate (u/z,v/z)

Or, since w ∝ 1/z, interpolate (uw, vw)

Perform divisions: u = uw/w, v = vw/w for each fragment

This gives perspective-correct texture mapping

Page 18: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Outline

Introduction

Surface Parameterization

Texture Mapping

Texture Filtering

Variations

Page 19: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Texture Filtering

Texture image is, after all, a set of discrete samples (called texels)

(u,v) coordinates at a surface point rarely land exactly on a sample

Need to use reconstruction filters to figure out the texture values between samples

Page 20: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Texture Filtering

Nearest-neighbor filtering

Page 21: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Texture Filtering

Bilinear filtering

Page 22: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Texture Filtering

What if the area “covered” by a pixel contains multiple texels?

Need a way to combine multiple texels to a single value

Can pre-filter images using

MIP mapping

Summed area tables

Page 23: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

MIP Mapping

MIP = multim im parvo (“many things in one place”)

Keep a bunch of downsampled images at different sizes (called levels)

Page 24: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

MIP Mapping

Choose the level based on depth

Alternately, interpolate between two levels (trilinear filtering)

Without MIP mapping With MIP mapping

Page 25: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Summed Area Tables

For each texel, store the sum of texel values below it and to its right

Sum of values within any rectangle = difference of two texel values

Page 26: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Summed Area Tables

Can compute more accurate averages

MIP mapping is simpler, and supported in GPUs

MIP mapping Summed Area Tables

Page 27: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Outline

Introduction

Surface Parameterization

Texture Mapping

Texture Filtering

Variations

Page 28: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Texture Mapping Variations

So far, we’ve used textures to specify 𝑘𝑎 , 𝑘𝑑 , 𝑘𝑠

But there are many more uses! For example, can store 𝑘𝑠, 𝑝 in a separate specular map

Page 29: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Bump Mapping

Intensity = offset from surface

Used to derive varying surface normals

Page 30: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Normal Mapping

Explicitly specify surface normals

[Paolo Cignoni]

Page 31: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Displacement Mapping

Like bump mapping, but geometry shader used to actually displace the surface

Page 32: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Light Mapping

Texture stores intensity/color of light incident at the surface

Precomputed using global illumination techniques

Without light map With light map

Page 33: Texture Mapping - GAMMAgamma.cs.unc.edu/graphicscourse/15_texture_mapping.pdf · Environment Mapping Texture is an image of a complicated environment, sampled in all directions around

Environment Mapping

Texture is an image of a complicated environment, sampled in all directions around a point

Images from Illumination and Reflection Maps: Simulated Objects in Simulated and Real Environments Gene Miller and C. Robert Hoffman SIGGRAPH 1984 “Advanced Computer Graphics Animation” Course Notes