advanced texture mapping may 10, 2007. today’s topics mip mapping projective texture shadow map

15
Advanced Texture Mapping May 10, 2007

Post on 21-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Advanced Texture Mapping May 10, 2007. Today’s Topics Mip Mapping Projective Texture Shadow Map

Advanced Texture Mapping

May 10, 2007

Page 2: Advanced Texture Mapping May 10, 2007. Today’s Topics Mip Mapping Projective Texture Shadow Map

Today’s Topics

• Mip Mapping

• Projective Texture

• Shadow Map

Page 3: Advanced Texture Mapping May 10, 2007. Today’s Topics Mip Mapping Projective Texture Shadow Map

Texture Resolution

• One size does not fit all:– For example: an NxN texture may be OK

for a polygon about the same size on screen, but not for a much smaller or much larger polygon.

– Polygon too large blurry texture– Polygon too small wasted texture

memory.

Page 4: Advanced Texture Mapping May 10, 2007. Today’s Topics Mip Mapping Projective Texture Shadow Map

Mip Map

• For an NxN texture, also build textures of N/2 x N/2, N/4 x N/4, … etc.

• Total memory required: 4/3 NxN– 1+1/4+1/16+… = 4/3

Page 5: Advanced Texture Mapping May 10, 2007. Today’s Topics Mip Mapping Projective Texture Shadow Map

Which Level to Use?

• Naïve answer: pick the closest size.

• Note that we don’t pick a fixed mip-map level for the whole polygon. We will pick a different level for each drawn pixel.

• Also, the level does not need to be an integer In-between levels.

Page 6: Advanced Texture Mapping May 10, 2007. Today’s Topics Mip Mapping Projective Texture Shadow Map

Filtering

• Here, we only consider individual pixels of a scan-converted polygon (on the screen)

• Texture coords=(u, v); u, v: real number.• Bi-linear: Find the closest mip-map level,

fetch (u, v ), (u, v ), (u ,v ), (u , v ).

• Tri-linear: Also interpolated between two mip-map levels.

Page 7: Advanced Texture Mapping May 10, 2007. Today’s Topics Mip Mapping Projective Texture Shadow Map

Anisotropic Filtering

• Bilinear (and tri-linear) filtering assumes that a screen picture is mapped to a circle on the texture, which is actually incorrect.

• An ellipse (not necessary axis aligned) should be used instead.

• Next slide: EWA = Ellipse Weighted Average.

Page 8: Advanced Texture Mapping May 10, 2007. Today’s Topics Mip Mapping Projective Texture Shadow Map

EWA for Texture Mapping

• Paul Heckbert, “Survey of Texture Mapping” IEEE CG&A, Nov. 1986. (Figures)

• Green & Heckbert, “Creating Raster Omnimax Images from Multiple Perspective Views Using The Elliptical Weighted Average Filter” IEEE CG&A, 6(6), pp. 21-27, June 1986.

Page 9: Advanced Texture Mapping May 10, 2007. Today’s Topics Mip Mapping Projective Texture Shadow Map

Projective Texture• Mark Segal, et al., “

Fast shadows and lighting effects using texture mapping”. SIGGRAPH 92

• Cass Everitt, “Projective Texture Mapping” NVIDIA SDK White Paper.

Figure 1. Two different views of a smiley face texture projected onto the scene.

Page 10: Advanced Texture Mapping May 10, 2007. Today’s Topics Mip Mapping Projective Texture Shadow Map

Assigning Texture Coordinates to Vertices

• The basic idea:1. Move the camera to the projector location.

2. Overlay the produced photo on top of the texture.

(i.e. the pixel location becomes the texture coordinates)

• “Projective Texture Mapping” by Cass Everitt describes how to use OpenGL texgen to achieve that.

Page 11: Advanced Texture Mapping May 10, 2007. Today’s Topics Mip Mapping Projective Texture Shadow Map

In a Nutshell• Tools available for generating texture

coordinates: glTexGen() and texture transformation matrix. (See today’s handout.)

• Use glTexGen() to get:

• Then set texture matrix to:

objectw

z

y

x

o

v

v

v

v

q

r

t

s

T

MVPT ppo

10002

1

2

100

2

10

2

10

2

100

2

1

Page 12: Advanced Texture Mapping May 10, 2007. Today’s Topics Mip Mapping Projective Texture Shadow Map

Shadow Map

• Similar to projective texture:– But this time, we will project the depth,

instead of the slide image.

With Shadows Without Shadows

Page 13: Advanced Texture Mapping May 10, 2007. Today’s Topics Mip Mapping Projective Texture Shadow Map

Basic Steps of Shadow Maps

• Render the scene from the light’s point of view,

• Use the light’s depth buffer as a texture (shadow map),

• Projectively texture the shadow map onto the scene,

• Use “texture color” (comparison result) in fragment shading.

Page 14: Advanced Texture Mapping May 10, 2007. Today’s Topics Mip Mapping Projective Texture Shadow Map

Image Source: Cass Everitt et al., “Hardware Shadow Mapping” NVIDIA SDK White Paper

Eye’s View Light’s View Depth/Shadow Map

Page 15: Advanced Texture Mapping May 10, 2007. Today’s Topics Mip Mapping Projective Texture Shadow Map

Food for Thought

• Why is texture mapping so powerful, useful, magical, …etc.?

(Hint: a lot of hardware design effort)

• Why are global illumination effects possible now, even though we still process one primitive at a time?