Texture MappingJason LawrenceCS445: GraphicsAcknowledgment: slides by Misha Kazhdan, Allison Klein, Tom Funkhouser,Adam Finkelstein and David DobkinTexturesWe know how to go from this… to thisJ. BirnTexturesBut what about this… to this?J. BirnTextures• How can we go about drawing surfaces with complex detail?Target ModelTextures• How can we go about drawing surfaces with complex detail?• We could tessellate the spherein a complex fashion and thenassociate the appropriatematerial properties to each vertexTarget ModelComplex SurfaceTextures• How can we go about drawing surfaces with complex detail?• We could use a simpletessellation and use the locationof surface points to look up theappropriate color valuesTarget ModelSimple SurfaceTexture ImageTextures• Advantages:oThe 3D model remains simpleoIt is easier to design/modify a texture image than it is to design/modify a surface in 3D.Target ModelSimple SurfaceTexture ImageTexturesProperties:• Alter shading of individual pixels• Implemented as part of shading process• Rely on maps being stored as 1D, 2D, or 3D images• Subject to aliasing errorsTexturesGeneral Implementation Approach:•Associate a collection of coordinates (s1,…,sn) to every vertex (0≤si≤1)•Use the color of the image at position (s1,…,sn) to define the color of a vertexAnother Example: Brick WallAnother Example: Brick Wall+2D Texture• Coordinates described by variables s and t and range over interval (0,1)• Texture elements are called texels• Often 4 bytes (rgba) per texelts2D TexturetsglBegin(GL_TRIANGLE);glTexCoord2f(0.0, 0.0);glVertex3f(0.0, 0.0, 0.0);glTexCoord2f(1.0, 0.0);glVertex3f(1.0, 0.0, 0.0);glTexCoord2f(1.0, 1.0);glVertex3f(1.0, 1.0, 0.0);glEnd();3D Rendering Pipeline (for direct illumination)3D PrimitivesImage2D Image Coordinates3D Modeling Coordinates3D World Coordinates3D Camera Coordinates2D Screen Coordinates2D Screen Coordinates3D World Coordinates2D Image CoordinatesTexture mappingLightingCameraTransformationModelingTransformationProjectionTransformationClippingViewportTransformationScanConversionOverview• Texture mapping methodsoParameterizationoMappingoFiltering• Texture mapping applicationsoModulation texturesoIllumination mappingoBump mappingoEnvironment mappingoShadow mapsoVolume TexturesParameterizationgeometry+=image texture map• Q: How do we decide where on the geometry! each color from the image should go?Option: Unfold/Map Entire Surface[Piponi2000]Option: Unfold/Map Entire Surface• Tricky, because mapped surface may have severe distortions • However, because texture is continuous, may be easier to think aboutGu et al. 2003Option: Unfold/Map Entire Surface• Tricky, because mapped surface may have severe distortions • However, because texture is continuous, may be easier to think aboutGu et al. 2003In general, it is impossible to parameterize a complex shape to a simple base domain so that both angles and areas are preservedOption: Make an Atlas[Sander2001]charts atlas surfaceOption: make an atlas• Less distortion on each little piece of atlas• Need to pack to patches to reduce wasted space in texture image• May be more difficult to think about the relationships between the different piecesOverview• Texture mapping methodsoParameterizationoMappingoFiltering• Texture mapping applicationsoModulation texturesoIllumination mappingoBump mappingoEnvironment mappingoShadow MapsoVolume texturesTexture Mapping• Steps:oDefine textureoSpecify mapping from surface to textureoLookup texture values during scan conversion(0,0)(1,0)(0,1)uvxyModelingCoordinateSystemImageCoordinateSystemstTextureCoordinateSystem(1,1)Texture Mapping• Scan conversion:oInterpolate texture coordinates down/across scan linesoDo perspective divide at each pixel based on mapping from screen space to 3-space(s1,t1)I3(s2,t2)(s3,t3)Texture MappingLinear interpolationof texture coordinatesin screen spaceCorrect interpolationwith perspective divideHill Figure 8.42Overview• Texture mapping methodsoParameterizationoMappingoFiltering• Texture mapping applicationsoModulation texturesoIllumination mappingoBump mappingoEnvironment mappingoShadow mapsoVolume TexturesTexture FilteringAngel Figure 9.4Must sample texture to determine color at each pixel in imageTexture FilteringMust sample texture to determine color at each pixel in image• In general, the transformation from screen space to texture space does not preserve areastxyMinificationTexture FilteringMust sample texture to determine color at each pixel in image• In general, the transformation from screen space to texture space does not preserve area• Need to compute the average of the pixels in texture space to get the color for screen spacestxyMinificationTexture FilteringMust sample texture to determine color at each pixel in image• In general, the transformation from screen space to texture space does not preserver area• Need to compute the average of the pixels in texture space to get the color for screen spacestxyMinificationIf the distortion is very large, this will require a lot of texture look-ups/adds.Texture FilteringSize of filter depends on the projective deformation• Can prefilter images for better performanceoMip mapsoSummed area tablesstxyMinificationMip Maps• Keep textures prefiltered at multiple resolutionsoFor each pixel, use the mip-map closest level oFast, easy for hardwareMip Maps• Keep textures prefiltered at multiple resolutionsoFor each pixel, use the mip-map closest level oFast, easy for hardwareAverage overmany pixelsMip Maps• Keep textures prefiltered at multiple resolutionsoFor each pixel, use the mip-map closest level oFast, easy for hardwareAverage overa few pixelsMip Maps• Keep textures prefiltered at multiple resolutionsoFor each pixel, use the mip-map closest level oFast, easy for hardwareAgain: we’re trading aliasing for blurring!Mip Maps• Keep textures prefiltered at multiple resolutionsoFor each pixel, use the mip-map closest level oFast, easy for hardware• This type of filtering is isotropic:oIt doesn’t take into account that there is more compression in the vertical direction than in the horizontal oneAgain: we’re trading aliasing for blurring!stSummed-area tablesKey Idea:• Approximate the summation/integration over an arbitrary region by a summation/integration over an axis-aligned rectangle.stst(a,c)(a,d)(b,d)(b,c)Summed-area tablesKey Idea:• Approximate the
View Full Document