University of Texas at Austin CS384G - Computer Graphics Spring 2010 Don FussellTexture MappingUniversity of Texas at Austin CS384G - Computer Graphics Spring 2010 Don Fussell 2ReadingRequiredWatt, intro to Chapter 8 and intros to 8.1, 8.4, 8.6, 8.8.RecommendedPaul S. Heckbert. Survey of texture mapping. IEEE ComputerGraphics and Applications 6(11): 56--67, November 1986.OptionalWatt, the rest of Chapter 8Woo, Neider, & Davis, Chapter 9James F. Blinn and Martin E. Newell. Texture and reflection incomputer generated images. Communications of the ACM 19(10):542--547, October 1976.University of Texas at Austin CS384G - Computer Graphics Spring 2010 Don Fussell 3What adds visual realism?Geometry onlyPhong shadingPhong shading +Texture mapsUniversity of Texas at Austin CS384G - Computer Graphics Spring 2010 Don Fussell 4Texture mappingTexture mapping (Woo et al., fig. 9-1)Texture mapping allows you to take a simple polygon andgive it the appearance of something much more complex.Due to Ed Catmull, PhD thesis, 1974Refined by Blinn & Newell, 1976Texture mapping ensures that “all the right things” happenas a textured polygon is transformed and rendered.University of Texas at Austin CS384G - Computer Graphics Spring 2010 Don Fussell 5Non-parametric texture mappingWith “non-parametric texture mapping”:Texture size and orientation are fixedThey are unrelated to size and orientation of polygonGives cookie-cutter effectUniversity of Texas at Austin CS384G - Computer Graphics Spring 2010 Don Fussell 6With “parametric texture mapping,” texture size andorientation are tied to the polygon.Idea:Separate “texture space” and “screen space”Texture the polygon as before, but in texture spaceDeform (render) the textured polygon into screen spaceA texture can modulate just about any parameter – diffusecolor, specular color, specular exponent, …Parametric texture mappingUniversity of Texas at Austin CS384G - Computer Graphics Spring 2010 Don Fussell 7Implementing texture mappingA texture lives in it own abstract image coordinates parameterized by(u,v) in the range ([0..1], [0..1]): It can be wrapped around many different surfaces:Computing (u,v) texture coordinates in a ray tracer is fairlystraightforward.Note: if the surface moves/deforms, the texture goes with it.University of Texas at Austin CS384G - Computer Graphics Spring 2010 Don Fussell 8Mapping to texture image coordsThe texture is usually stored as an image. Thus, we need toconvert from abstract texture coordinate:(u,v) in the range ([0..1], [0..1])to texture image coordinates:(utex,vtex) in the range ([0.. wtex], [0.. htex])Q: What do you do when the texture sample you need landsbetween texture pixels?University of Texas at Austin CS384G - Computer Graphics Spring 2010 Don Fussell 9Texture resamplingWe need to resample the texture:A common choice is bilinear interpolation:! T(a,b) = T[i + "x, j + "y]= (1# "x)(1# "y)T[i, j] + "x(1# "y)T[i + 1, j]+(1# "x)"yT[i, j + 1] + "x"yT[i + 1, j + 1]University of Texas at Austin CS384G - Computer Graphics Spring 2010 Don Fussell 10Solid texturesQ: What kinds of artifacts might you see from using amarble veneer instead of real marble?One solution is to use solid textures:Use model-space coordinates to index into a 3D textureLike “carving” the object from the materialOne difficulty of solid texturing is coming up with thetextures.University of Texas at Austin CS384G - Computer Graphics Spring 2010 Don Fussell 11Solid textures (cont'd)Here's an example for a vase cut from a solid marbletexture:Solid marble texture by Ken Perlin, (Foley, IV-21)University of Texas at Austin CS384G - Computer Graphics Spring 2010 Don Fussell 12Displacement mappingTextures can be used for more than just color.In displacement mapping, a texture is used to perturb thesurface geometry itself:These displacements “animate” with the surfaceQ: Do you have to do hidden surface calculations on Q?~University of Texas at Austin CS384G - Computer Graphics Spring 2010 Don Fussell 13In bump mapping, a texture is used to perturb the normal:Use the original, simpler geometry, Q(u), for hidden surfacesUse the normal from the displacement map for shading:N = normal[Q(u)] Q: What artifacts in the images would reveal that bumpmapping is a fake?Bump mapping~~University of Texas at Austin CS384G - Computer Graphics Spring 2010 Don Fussell 14Bump mapping exampleTexture #1(diffuse color)Texture #2(bump map)Rendered ImageUniversity of Texas at Austin CS384G - Computer Graphics Spring 2010 Don Fussell 15Displacement vs. bump mappingInput textureRendered as displacement map over a rectangular surfaceUniversity of Texas at Austin CS384G - Computer Graphics Spring 2010 Don Fussell 16Displacement vs. bump mapping (cont'd) Original rendering Rendering with bump map wrapped around a cylinderBump map and rendering by Wyvern AldingerUniversity of Texas at Austin CS384G - Computer Graphics Spring 2010 Don Fussell 17Environment mappingIn environment mapping (also known as reflection mapping), atexture is used to model an object's environment:Rays are bounced off objects into environmentColor of the environment used to determine color of the illuminationReally, a simplified form of ray tracingEnvironment mapping works well when there is just a single object – or inconjunction with ray tracingUnder simplifying assumptions, environment mapping can beimplemented in hardware.With a ray tracer, the concept is easily extended to handle refraction aswell as reflection.University of Texas at Austin CS384G - Computer Graphics Spring 2010 Don Fussell 18Combining texture mapsUsing texture maps in combination gives even better effects.DiffusecolorEnvironment map(not necessaryin ray tracer)SpecularcoefficientMaterialproperties(coefficientsin shadingequation)University of Texas at Austin CS384G - Computer Graphics Spring 2010 Don Fussell 19Can define material by programA ‘surface shader’ computes the color of each ray that hitsthe surface.Example: Renderman surface shader/* * Checkerboard */surface checker(float Kd=.5, Ka=.1) { float smod = mod(10*s, 1); float tmod = mod(10*t, 1); if (smod < 0.5) { if (tmod < 0.5)
View Full Document