CS 445 / 645 Introduction to Computer GraphicsTexture MappingTexture MapsSlide 4Slide 5Example Texture MapSlide 7Slide 8Texture CoordinatesTexturesExample use of TextureStep 2 – create Texture ObjectsStep 3 – Specify which texture object is about to be definedStep 4 – Begin defining textureStep 5 – Assign image dataglTexImage2D – Arg 1glTexImage2D – Arg 2glTexImage2D – Arg 3glTexImage2D – Args 4-6glTexImage2D – Args 7 & 8glTexImage2D – Arg 9Step 6 – Apply textureglTexEnv()gluScaleImage()glCopyTexImage2D()glTexSubImage2D()Bump MappingSlide 28Displacement MappingMipmapsMIPMAPSSlide 32gluBuild2DMipmapsAdvanced MipmapsFilteringNext AssignmentFinal ExamTestsCS 445 / 645Introduction to Computer GraphicsLecture 17Lecture 17Texture MapsTexture MapsLecture 17Lecture 17Texture MapsTexture MapsTexture MappingLimited ability to generate complex surfaces with Limited ability to generate complex surfaces with geometrygeometryImages can convey the illusion of geometryImages can convey the illusion of geometryImages painted onto Images painted onto polygons is called texture polygons is called texture mappingmappingLimited ability to generate complex surfaces with Limited ability to generate complex surfaces with geometrygeometryImages can convey the illusion of geometryImages can convey the illusion of geometryImages painted onto Images painted onto polygons is called texture polygons is called texture mappingmappingTexture MapsChapter 9 of Open GL Programming Guide (Red Chapter 9 of Open GL Programming Guide (Red Book)Book)Images applied to polygons to enhance the visual Images applied to polygons to enhance the visual effect of a sceneeffect of a scene•Rectangular arrays of dataRectangular arrays of data–Color, luminance, Color, luminance, alphaalpha–Components of array called Components of array called texelstexelsWe’ve also had volumetricWe’ve also had volumetric voxels voxelsChapter 9 of Open GL Programming Guide (Red Chapter 9 of Open GL Programming Guide (Red Book)Book)Images applied to polygons to enhance the visual Images applied to polygons to enhance the visual effect of a sceneeffect of a scene•Rectangular arrays of dataRectangular arrays of data–Color, luminance, Color, luminance, alphaalpha–Components of array called Components of array called texelstexelsWe’ve also had volumetricWe’ve also had volumetric voxels voxelsTexture MappingTexture map is an image, two-dimensional array of color Texture map is an image, two-dimensional array of color values (values (texelstexels))Texels are specified by texture’s (u,v) spaceTexels are specified by texture’s (u,v) spaceAt each screen pixel, texel can be used to substitute a At each screen pixel, texel can be used to substitute a polygon’s surface property (color)polygon’s surface property (color)We must map (u,v) space to polygon’s (s, t) spaceWe must map (u,v) space to polygon’s (s, t) spaceTexture map is an image, two-dimensional array of color Texture map is an image, two-dimensional array of color values (values (texelstexels))Texels are specified by texture’s (u,v) spaceTexels are specified by texture’s (u,v) spaceAt each screen pixel, texel can be used to substitute a At each screen pixel, texel can be used to substitute a polygon’s surface property (color)polygon’s surface property (color)We must map (u,v) space to polygon’s (s, t) spaceWe must map (u,v) space to polygon’s (s, t) spaceUVSTTexture Mapping(u,v) to (s,t) mapping can be explicitly set at vertices (u,v) to (s,t) mapping can be explicitly set at vertices by storing by storing texture coordinatestexture coordinates with each vertex with each vertexHow do we compute (u,v) to (s,t) mapping for points How do we compute (u,v) to (s,t) mapping for points in betweenin between•Watch for aliasingWatch for aliasing•Watch for many to one mappingsWatch for many to one mappings•Watch for perspective foreshortening effects and linear Watch for perspective foreshortening effects and linear interpolationinterpolation(u,v) to (s,t) mapping can be explicitly set at vertices (u,v) to (s,t) mapping can be explicitly set at vertices by storing by storing texture coordinatestexture coordinates with each vertex with each vertexHow do we compute (u,v) to (s,t) mapping for points How do we compute (u,v) to (s,t) mapping for points in betweenin between•Watch for aliasingWatch for aliasing•Watch for many to one mappingsWatch for many to one mappings•Watch for perspective foreshortening effects and linear Watch for perspective foreshortening effects and linear interpolationinterpolationExample Texture MapApplied to tilted polygonExample Texture MapglVertex3d (s, s, s)glTexCoord2d(1,1);glVertex3d (-s, -s, -s)glTexCoord2d(1,1);Example Texture MapglVertex3d (s, s, s)glTexCoord2d(5, 5);glVertex3d (s, s, s)glTexCoord2d(1, 1);Texture CoordinatesEvery polygon has object coordinates and texture Every polygon has object coordinates and texture coordinatescoordinates•Object coordinates describe where polygon vertices are on Object coordinates describe where polygon vertices are on the screenthe screen•Texture coordinates describe texel coordinates of each Texture coordinates describe texel coordinates of each vertex (usually 0 -> 1)vertex (usually 0 -> 1)•Texture coordinates are interpolated along vertex-vertex Texture coordinates are interpolated along vertex-vertex edgesedgesglTexCoord{1234}{sifd}(TYPE coords)glTexCoord{1234}{sifd}(TYPE coords)Every polygon has object coordinates and texture Every polygon has object coordinates and texture coordinatescoordinates•Object coordinates describe where polygon vertices are on Object coordinates describe where polygon vertices are on the screenthe screen•Texture coordinates describe texel coordinates of each Texture coordinates describe texel coordinates of each vertex (usually 0 -> 1)vertex (usually 0 -> 1)•Texture coordinates are interpolated along vertex-vertex Texture coordinates are interpolated along vertex-vertex edgesedgesglTexCoord{1234}{sifd}(TYPE coords)glTexCoord{1234}{sifd}(TYPE coords)TexturesTexture ObjectTexture Object•An OpenGL data type that keeps textures resident in memory and An OpenGL data type that keeps textures resident in memory and provides identifiers to easily access themprovides identifiers to easily access them•Provides efficiency gains over having to repeatedly load and reload a Provides efficiency gains over having to repeatedly
View Full Document