CS4620/5620: Lecture 24
Total Page:16
File Type:pdf, Size:1020Kb
CS4620/5620: Lecture 24 Texture Mapping Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 1 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) Announcements • PA2B out today – Material will be covered today and Wed • Plan for next few lectures – Texturing – Wed: Perlin noise, Sampling and anti-aliasing – Friday onwards: Splines Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 2 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) Other uses of texture mapping • Reflection maps • Environment maps • Normal maps • Bump maps • Displacement maps • Shadow maps • Irradiance maps • ... Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 3 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) Normal mapping • Stores normals as texture map over coarse geometry [Paolo Cignoni] Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 4 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) Displacement mapping base subdivision surface hand-painted displacement map (detail) Paweł Filip tolas.wordpress.com displaced surface Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 5 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) Displacement mapping Geometryno map normalBump map displacementDisplacement map mapping mapping Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 6 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) Altogether: Gloss Maps/Normal Maps n.l d + (n.h)^m g ATI Technologies, Inc. • Normal maps, diffuse map, gloss map, shininess maps Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 7 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) Reflection mapping • Early (earliest?) non-decal use of textures • Appearance of shiny objects – Phong highlights produce blurry highlights for glossy surfaces. – A polished (shiny) object reflects a sharp image of its environment. Journal of Vision (2004) 4, 821-837 Dror, Willsky, & Adelson 822 • The whole key to a shiny-looking material is providing something for it to reflect. [Dror, Willsky, & Adelson 2004] & Adelson Willsky, [Dror, (a) (b) (a) (b) Figure 2. (a). A shiny sphere rendered under photographically Figure 3. (a). A photograph of a metal sphere. (b). The negative acquired real-world illumination. (b). The same sphere rendered of the same photograph. under illumination by a point light source. Cornell CS4620/5620 Fall 2012 • Lecture 24 realistic illumination provides a much stronger© 2012 sens Kavitae of tBalahe • l8ooks like a realistic photograph of any ordinary sphere. (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) glossy reflectance than the image rendered under a point These demonstrations show that some illumination source. patterns lead to significant errors in human material per- Figure 3 compares a photograph of a metal sphere to a ception. In ordinary life, however, we rarely encounter such negative of the same photograph. The original photograph phenomena. Figure 4 shows four spheres, each photo- has the characteristic appearance of a metal sphere viewed graphed in two locations. The images of different spheres in an everyday scene. The sphere simply produces a dis- in the same setting are more similar in a pixelwise sense torted and slightly blurred image of the world around it. than images of the same sphere in different settings. Yet, The negative image could, in principle, also be a photo- we easily recognize the various spheres under different eve- graph of the same sphere, if it happened to be placed in a ryday illumination conditions. In an experiment where sub- world with the appropriate distribution of light and dark. jects were asked to match reflectance properties under dif- There is no physical reason why this scene could not exist, ferent illumination conditions, they consistently performed and a determined photographer could build it on purpose, better when given two complex real-world illuminations but it would never occur in ordinary life. This negative im- than when given one real-world illumination and one sim- age does not look like a metal sphere; in fact, it hardly ple synthetic illumination (Fleming, Dror, & Adelson, Figure 4. The two images in each column are photographs of the same sphere. The four images in each row were photographed in the same location, under the same illumination. Environment map • A function from the sphere to colors, stored as a texture. [Blinn & Newell 1976] [Blinn & Newell Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 9 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) Spherical environment map Hand with Re!ecting Sphere. M. C. Escher, 1935. lithograph Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 10 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) Spherical environment maps [Paul Debevec] Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 11 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) Types of Mappings: Cube Mapping Cube mapping Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 12 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) Sphere Mapping Example Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 13 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) Other uses of texture mapping • Reflection maps • Environment maps • Normal maps • Bump maps • Displacement maps • Shadow maps • Irradiance maps • ... Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 14 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) Another definition Texture mapping: a general technique for storing and evaluating functions. • They’re not just for shading parameters any more! Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 15 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) Texture mapping from 0 to infinity • When you go close... Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 16 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) When viewed from a distance • Aliasing! • Also, minification Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 17 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) What is going on? • Image-based texture mapping is resolution dependent Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 18 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) What is texture lookup doing? ! Sampling a single point Pixel Texture • From far away • Scintillating artifacts over multiple frames Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 19 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) When viewed closer… • Nearby pixels all lie in same texel • Blocky artifacts Pixel Texture Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 20 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) What is really the issue? • A pixel is not a point • It is an area! • Each pixel maps to some region of texture space • Ideally, we want to integrate over mapped area Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 21 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) How does area map over distance? • At optimal viewing distance: • One-to-one mapping between pixel area and texel area • When closer • Each pixel is a small part of the texel • When farther • Each pixel could include many texels Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 22 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) Solution: Antialiasing in textures • Problem: Perspective produces very high image frequencies • Solution – Would like to render textures with one (few) samples/pixel – Need to filter first! Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 23 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) Theoretical Solution • Find the area of pixel in texture space • “Filter” the area to compute “average” texture color • Filtering eliminates high frequency artifacts Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 24 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) Theoretical Solution • Find the area of pixel in texture space • “Filter” the area to compute “average” texture color • Filtering eliminates high frequency artifacts • How to filter? • Analytically compute area • But too expensive Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 25 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) Solutions for Minification • Need some way to access pre-filtered (precomputed) regions of the texture • MIP Maps • RIP Maps • Summed Area Tables • Clip Maps Cornell CS4620/5620 Fall 2012 • Lecture 24 © 2012 Kavita Bala • 26 (with previous instructors James/Marschner, and some slides courtesy Leonard McMillan) MIP Maps • MIP Maps • Multum in Parvo: Much in little, many in small