Texture MappingTextures3D Rendering Pipeline (for direct illumination)Surface TexturesSlide 5ParameterizationOption: Varieties of projectionsOption: unfold the surfaceOption: make an atlasOption: it’s the artist’s problemOverviewSlide 12Slide 13Slide 14Naïve Texture MappingNaïve Texturing ArtifactsInterpolating ParametersSlide 18Slide 19Perspective-Correct InterpolationSlide 21Texture FilteringTexture Map AliasingSlide 24Mip MapsMIP-map ExampleSummed-area tablesSummed-Area TablesSlide 29Modulation texturesTexture Mapping VariationsBump MappingMore Bump MappingDisplacement MappingIllumination MapsEnvironment MapsSolid texturesProcedural TextureProcedural Texture GallerySlide 40Slide 41Slide 42Slide 43Slide 44Greg HumphreysCS445: Intro GraphicsUniversity of Virginia, Fall 2003Texture MappingGreg HumphreysUniversity of VirginiaCS 445, Fall 2003SurfaceImageTextureTextures•Describe color variation in interior of 3D polygonWhen scan converting a polygon, vary pixel colors according to values fetched from a textureAngel Figure 9.3“Texels”“Pixels”3D Rendering Pipeline (for direct illumination)3D PrimitivesModelingTransformationModelingTransformationProjectionTransformationProjectionTransformationClippingClippingLightingLightingImageViewportTransformationViewportTransformationScanConversionScanConversion2D Image Coordinates3D Modeling Coordinates3D World Coordinates3D Camera Coordinates2D Screen Coordinates2D Screen CoordinatesViewingTransformationViewingTransformation3D World Coordinates2D Image CoordinatesTexture mappingSurface Textures•Add visual detail to surfaces of 3D objectsPolygonal modelWith surface textureSurface Textures•Add visual detail to surfaces of 3D objects[Daren Horley]Parameterizationgeometrygeometry++==imageimagetexture maptexture map•Q: How do we decide where on the geometryeach color from the image should go?Option: Varieties of projections[Paul Bourke][Paul Bourke]Option: unfold the surface[Piponi2000]Option: make an atlas[Sander2001]charts atlas surfaceOption: it’s the artist’s problemOverview•Texture mapping methodsParameterizationMappingFiltering•Texture mapping applicationsModulation texturesIllumination mappingBump mappingEnvironment mappingImage-based renderingVolume texturesNon-photorealistic renderingTexture Mapping•Steps:Define textureSpecify mapping from texture to surfaceLookup texture values during scan conversion(0,0)(1,0)(0,1)uvxyModelingCoordinateSystemImageCoordinateSystemstTextureCoordinateSystemTexture Mapping•When scan convert, map from …image coordinate system (x,y) tomodeling coordinate system (u,v) totexture image (t,s)(0,0)(1,0)(1,1)(0,1)uvxyModelingCoordinateSystemImageCoordinateSystemstTextureCoordinateSystemTexture MappingAllison Klein, Princeton•Texture mapping is a 2D projective transformationtexture coordinate system: (t,s) toimage coordinate system (x,y)Naïve Texture Mapping•A first cut at a texture-mapping rasterizer:For each pixel:»Interpolate u & v down edges and across spans»Look up nearest texel in texture map»Color pixel according to texel color (possibly modulated by lighting calculations)McMillan’s demo of this is at http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture21/Slide05.htmlWhat artifacts do you see in this demo?Naïve Texturing Artifacts•Warping at edges of triangles•A more obvious example: http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture21/Slide06.html•Consider the geometry of interpolating parameters more carefullyInterpolating Parameters•The problem turns out to be fundamental to interpolating parameters in screen-spaceUniform steps in screen space uniform steps in world spaceTexture MappingLinear interpolationof texture coordinatesCorrect interpolationwith perspective divideHill Figure 8.42Interpolating Parameters•Perspective foreshortening is not getting applied to our interpolated parametersParameters should be compressed with distanceLinearly interpolating them in screen-space doesn’t do this •Is this a problem with Gouraud shading?•A: It can be, but we usually don’t notice (why?)http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture21/Slide17.htmlPerspective-Correct Interpolation•Skipping a bit of math to make a long story short…Rather than interpolating u and v directly, interpolate u/z and v/z »These do interpolate correctly in screen space»Also need to interpolate z and multiply per-pixelProblem: we don’t know z anymoreSolution: we do know w 1/zSo…interpolate uw and vw and w, and compute u = uw/w and v = vw/w for each pixel»This unfortunately involves a divide per pixel (Just 1?)http://graphics.lcs.mit.edu/classes/6.837/F98/Lecture21/Slide14.htmlOverview•Texture mapping methodsParameterizationMappingFiltering•Texture mapping applicationsModulation texturesIllumination mappingBump mappingEnvironment mappingImage-based renderingNon-photorealistic renderingTexture FilteringAngel Figure 9.4•Must sample texture to determine color at each pixel in imageTexture Map Aliasing•Naive texture mapping aliases badly •Look familiar?int uval = (int) (u * denom + 0.5f);int vval = (int) (v * denom + 0.5f);int pix = texture.getPixel(uval, vval);•Actually, each pixel maps to a region in texture|PIX| < |TEX| »Easy: interpolate (bilinear) between texel values |PIX| > |TEX|»Hard: average the contribution from multiple texels|PIX| ~ |TEX|»Still need interpolation!Texture FilteringAngel Figure 9.14•Size of filter depends on projective warpCan prefilter images »Mip maps»Summed area tablesMagnification MinificationMip Maps•Keep textures prefiltered at multiple resolutionsFor each pixel, linearly interpolate between two closest levels (e.g., trilinear filtering) Fast, easy for hardware•Why “Mip” maps?MIP-map Example•No filtering:•MIP-map texturing:AAAAAAAGHMY EYES ARE BURNINGWhere are my glasses?Summed-area tables•At each texel keep sum of all values down & rightTo compute sum of all values within a rectangle,simply subtract two entriesBetter ability to capture very oblique projectionsBut, cannot store values in a single byteS1S2Summed-Area Tables•Mipmaps assume that each pixel projects to a square in the texture (which is a lie)•SAT can integrate texels covered by the pixel more exactly (but still quickly)•Example:MIP-map texturing Summed-area table
View Full Document