`Michael Cohen, Claude Puech, and Francois Sillion, eds.
`Paris, France, June, 1993. pp. 259-266 .
`
`.. . Te:xture :M:apping
`as a
`Fundamental Drawing Primitive
`
`Paul Haeberli
`Mark Segal
`Silicon Graphics Computer Systems*
`
`Abstract
`
`Texture mapping has traditionally been used to add
`realism to computer graphics images. In recent years,
`this technique has moved from the domain of software
`rendering systems to that of high performance graphics
`hardware.
`But texture mapping hardware can be used for many
`more applications than simply applying diffuse pat(cid:173)
`terns to polygons.
`We survey applications of texture mapping including
`simple texture mapping, projective textures, and image
`warping. We then describe texture mapping techniques ·
`for drawing anti-aliased lines, air-brushes, and anti(cid:173)
`aliased text. Next we show how texture mapping may
`be used as a fundamental graphics primitive for volume
`rendering, environment mapping, color interpolation,
`contouring, and many other applications.
`
`CR Categories and Subject Descriptors: I.3.3 [Com(cid:173)
`puter Graphics]: Picture/Image Generation; I.3.7
`[Computer Graphics]: Three-Dimensional Graphics
`and Realism- color, shading, shadowing, texture-mapping,
`line drawing, and anti-aliasing
`
`1
`
`Introduction
`
`Texture mapping[Cat74][Hec86] is a powerful tech(cid:173)
`nique for adding realism to a computer-generated
`scene. In its basic form, texture mapping lays an image
`(the texture) onto an object in a scene. More general
`forms of texture mapping generalize the image to other
`information; an "image" of altitudes, for instance, can
`be used to control shading across a surface to achieve
`such effects as bump-mapping.
`Because texture. mapping is so ·useful, if is being.
`provided as a standard rendering technique both in
`graphics software interfaces and in computer graph(cid:173)
`ics hardware[HL90][DWS+88]. Texture mapping can
`
`*2011 N. Shoreline Blvd., Mountain View, CA 94043 USA
`
`therefore be used in a scene with only a modest in(cid:173)
`crease in the complexity of the program that generates
`that scene, sometimes with little effect on scene genera(cid:173)
`tion time. The wide availability and high-performance
`of texture mapping makes it a desirable rendering tech(cid:173)
`nique for achieving a number of effects that are nor(cid:173)
`mally obtained with special purpose drawing hard(cid:173)
`ware.
`After a brief review of the mechanics of texture map(cid:173)
`ping, we describe a few of its standard applications.
`We go on to describe some novel applications of tex(cid:173)
`ture mapping.
`
`2 Texture Mapping
`
`When mapping an image onto an object, the color of the
`object at each pixel is modified by a corresponding color
`from the image. In general, obtaining this color from
`the image conceptually requires several steps[Hec89].
`The image is normally stored as a sampled array, so a
`continuous image must first be reconstructed from the
`samples. Next, the image must be warped to match
`any distortion (caused, perhaps, by perspective) in the
`projected object being displayed. Then this warped
`image is filtered to remove high-frequency components
`that would lead to aliasing in the final step: resampling
`to obtain the desired color to apply to the pixel being
`textured.
`In practice, the required filtering is approximated by
`one of several methods. One of the most popular is
`mipmapping[Wi183]. Other filtering techniques may also
`be used[Cro84].
`There are a number of generalizations to this basic
`texture mapping scheme. The image to be mapped
`need_ not be two-dimensional; the sampling and fil(cid:173)
`tering techniques may be applied for both one- and
`three-dimensional images[Pea85]. In the case of a three(cid:173)
`dimensional image, a two-dimensional slice must be
`selected to be mapped onto an object's boundary, since
`the result of rendering must be two-dimensional. The
`
`1
`
`F
`
`
`
`image may not be stored as an array but may be pro(cid:173)
`cedurally generated[Pea85][Per85]. Finally, the image
`may not represent color at all, but may instead describe
`transparency or other surface properties to be used in
`lighting or shading calculations[CG85].
`
`3 Previous Uses of Texture Map(cid:173)
`ping
`
`In basic texture mapping, an image is applied to a poly(cid:173)
`gon (or some other surface facet) by assigning texture
`coordinates to the polygon's vertices. These coordi(cid:173)
`nates index a texture image, and are interpolated across
`the polygon to determine, at each of the polygon's pix(cid:173)
`els, a texture image value. The result is that some por(cid:173)
`tion of the texture image is mapped onto the polygon
`when the polygon is viewed ori ilie screen: Typical
`two-dimensional images in this application are images
`of bricks or a road surface (in this case the texture image
`is often repeated across a polygon); a three-dimensional
`image might represent a block of marble from which
`objects could be "sculpted."
`
`3.1 Projective Textures
`
`A generalization of this technique projects a texture
`onto surfaces as if the texture were a projected slide or
`movie[SKvW+92]. In this case the texture coordinates
`at a vertex are computed as the result of the projection
`rather than being assigned fixed values. This technique
`may be used to simulate spotlights as well as the re(cid:173)
`projection of a photograph of an object back onto that
`object's geometry.
`Projective textures are also useful for simulating
`shadows. In this case, an image is constructed that rep(cid:173)
`resents distances from a light source to surface points
`nearest the light source. This image can be computed by
`performing z-buffering from the light's point of view
`and then obtaining the resulting z-buffer. When the
`scene is viewed from the eyepoint, the distance from
`the light source to each point on a surface is computed
`and compared to the corresponding value stored in the
`texture image. If the values are (nearly) equal, then
`the point is not in shadow; otherwise, it is in shadow.
`This technique should not use mipmapping, because
`filtering must be applied after the shadow comparison
`is performed[RSC87].
`
`3.2 Image Warping
`
`Image warping may be implemented with texture map(cid:173)
`ping by defining a correspondence between a uni(cid:173)
`form polygonal mesh (representing the original im(cid:173)
`age) and a warped mesh (representing the warped
`
`image)[OTOK87]. The warp may be affine (to gen(cid:173)
`erate rotations, translations, shearings, and zooms) or
`higher-order. The points of the warped mesh are as(cid:173)
`signed the corresponding texture coordinates of the
`uniform mesh, and the mesh is texture mapped with
`the original image. This technique allows for easily(cid:173)
`controlled interactive image warping. The technique
`can also be used for panning across a large texture im(cid:173)
`age by using a mesh that indexes only a portion of the
`entire image.
`
`3.3 Transparency Mapping
`
`Texture mapping may be used to lay transparent or
`semi-transparent objects over a scene by representing
`transparency values in the texture image as well as
`color values. This technique is useful for simulating
`clouds[Gar85]· and trees for example, by drawing ap(cid:173)
`propriately textured polygons over a background. The
`effect is that the background shows through around
`the edges of the clouds or branches of the trees. Texture
`map filtering applied to the transparency and color val(cid:173)
`ues automatically leads to soft boundaries between the
`clouds or trees and the background.
`
`3.4 Surface Trimming
`
`Finally, a similar technique may be used to cut holes
`out of polygons or perform domain space trimming on
`curved surfaces[Bur92]. An image of the domain space
`trim regions is generated. As the surface is rendered, its
`domain space coordinates are used to reference this im(cid:173)
`age. The value stored in the image determines whether
`the corresponding point on the surface is trimmed or
`not.
`
`4 Additional Texture Mapping Ap(cid:173)
`plications
`
`Texture mapping may be used to render objects that are
`. usually rendered by other, specialized means. Since it is
`becoming widely available, texture mapping may be a
`good choice to implement these techniques even when
`these graphics primitives can be drawn using special
`purpose methods.
`
`4.1 Anti-aliased Points and Line Segments
`
`One simple use of texture mapping is to draw anti(cid:173)
`aliased points of any width. In this case the texture
`image is of a filled circle with a smooth (anti-aliased)
`boundary. When a point is specified, it's coordinates
`indicate the center of a square whose width is deter(cid:173)
`mined by the point size. The texture coordinates at the
`
`2
`
`
`
`r .. u-..nnnnn .. nu.n .. .- ....................................... _.. ....................................... .._ .......... ~
`- " 1
`
`~
`
`I
`
`I
`
`h 1111/!1/l
`
`u ......................................................................... J
`
`0
`
`Figure 1. Anti-aliased line segments.
`
`square's comers are those corresponding to the comers
`of the texture image. This method has the advantage
`that any point shape may be accommodated simply by
`varying the texture image.
`A similar technique can be used to draw anti-aliased,
`line segments of any width{Gro90]:The texture image
`is a filtered circle as used above. Instead of a line seg(cid:173)
`ment, a texture mapped rectangle, whose width is the
`desired line width, is drawn centered on and aligned
`with the line segment. If line segments with round
`ends are desired, these can be added by drawing an
`additional textured rectangle on each end of the line
`segment (Figure 1).
`
`4.2 Air-brushes
`
`Repeatedly drawing a translucent image on a back(cid:173)
`ground can give the effect of spraying paint onto a
`canvas. Drawing an image can be accomplished by
`drawing a texture mapped polygon. Any conceivable
`brush "footprint", even a multi-colored one, may be
`drawn using an appropriate texture image with red,
`green, blue, and alpha. The brush image may also eas(cid:173)
`ily be scaled and rotated (Figure 2).
`
`4.3 Anti-aliased Text
`
`If the texture image is an image of§l_9:tarac:~er, then a
`polygon textured with that image will show that char(cid:173)
`acter on its face. If the texture image is partitioned
`into an array of rectangles, each of which contains the
`image of a different character, then any character may
`be displayed by drawing a polygon with appropriate
`texture coordinates assigned to its vertices. An advan(cid:173)
`tage of this method is that strings of characters may
`
`be arbitrarily positioned and oriented in three dimen(cid:173)
`sions by appropriately positioning and orienting the
`textured polygons. Character kerning is accomplished
`simply by positioning the polygons relative to one an(cid:173)
`other (Figure 3).
`AntiaJiased Characters of any size may be obtained
`with a single texture map simply by drawing a polygon
`of the desired size, but care must be taken if mipmap(cid:173)
`ping is used. Normally, the smallest mipmap is 1 pixel
`square, so if all the characters are stored in a single tex(cid:173)
`ture map, the smaller mipmaps will contain a number
`of characters filtered together. This will generate unde(cid:173)
`sirable effects when displayed characters are too small.
`Thus, if a single texture image is used for all characters,
`then each must be carefully placed in the image, and
`mipmaps must stop at the point where the image of a
`single character is reduced to 1 pixel on a side. Alterna(cid:173)
`tively, each character could be placed in its own (small)
`texture map.
`
`4.4 Volume Rendering
`
`There are three ways in which texture mapping may be
`used to obtain an image of a solid, translucent object.
`The first is to draw slices of the object from back to
`front[DCH88]. Each slice is drawn by first generating
`a texture image of the slice by sampling the data rep(cid:173)
`resenting the volume along the plane of the slice, and
`·then drawing a texture mapped polygon to produce the
`slice. Each slice is blended with the previously drawn
`slices using transparency.
`The second method uses 3D texture mapping[Dre92].
`In this method, the volumetric data is copied into the
`3D texture image. Then, slices perpendicular to the
`viewer are drawn. Each slice is again a texture mapped
`
`3
`
`
`
`Figure 2. Painting with texture maps .
`
`aozx :1\*lii:::::u.-, ·(cid:173)
`>ez.o c rsz1u + 11'111
`WXYZ5\6#t;<
`(1(:{)PiiRSTti\l
`F c-; HI t:rK LAt1N
`3210?®ABCDE
`k llj'I'J ,, 'Fl 4 l - 8' 94
`~,-· ,.. . rli5 .u J/ c-.· /
`J~iQJ$/({J)[.Jq
`.. ·· Figure 3: Anfi-a]iased text.
`
`polygon, but this time the texture coordinates at the
`polygon's vertices determine a slice through the 3D tex(cid:173)
`ture image. This method requires a 3D texture mapping
`capability, but has the advantage that texture memory
`need be loaded only once no matter what the view(cid:173)
`point. If the data are too numerous to fit in a single
`3D image, the full volume may be rendered in multiple
`passes, placing only a portion of the volume data into
`the texture image on each pass.
`A third way is to use texture mapping to implement
`"splatting" as described by[Wes90][LH91].
`
`4.5 Movie Display
`
`Three-dimensional texture images may also be used to
`display animated sequences[Ake92]. Each frame forms
`one two-dimensional slice of a three-dimensional tex-
`
`ture. A frame is displayed by drawing a polygon with
`texture coordinates that select the desired slice. This
`can be used to smoothly interpolate between frames of
`the stored animation. Alpha values may also be asso(cid:173)
`ciated with each pixel to make animated "sprites".
`
`4.6 Contouring
`
`Contour curves drawn on an object can provide valu(cid:173)
`able information about the object's geometry. Such
`curves may represent height above some plane (as in a
`topographic map) that is either fixed or moves with the
`object[Sab88]. Alternatively, the curves may indicate
`intrinsic surface properties, such as geodesics or loci of
`constant curvature.
`Contouring is achieved with texture mapping by first
`defining a one-dimensional texture image that is of con-
`
`4
`
`
`
`Figure 4. Contouring showing distance from a plane.
`
`stant color except at some spot along its length. Then,
`texture coordinates are computed for vertices of each
`polygon in the object to be contoured using a texture co(cid:173)
`ordinate generation function. This function may calculate
`the distance of the vertex above some plane (Figure 4),
`or may depend on certain surface properties to produce,
`for instance, a curvature value. Modular arithmetic is
`used in texture coordinate interpolation to effectively
`cause the single linear texture image to repeat over and
`over. The result is lines across the polygons that com(cid:173)
`prise an object, leading to contour curves.
`A two-dimensional (or even three-dimensional) tex(cid:173)
`ture image may be used with two (or three) texture
`coordinate generation functions to produce multiple
`curves, each representing a different surface character(cid:173)
`istic.
`
`4.7 Generalized Projections
`
`Texture mapping may be used to produce a non(cid:173)
`standard projection of a three-dimensional scene, such
`as a cylindrical or spherical projection[Gre86]. The tech(cid:173)
`nique is similar to image warping. First, the scene is
`rendered six times from a single viewpoint, but with
`six distinct viewing directions: forward, backward, up,
`down, left, and right. These six views form a cube en(cid:173)
`closing the viewpoint. The desired projection is formed
`by projecting the cube of images onto an array of poly(cid:173)
`gons (Figure 5).
`
`4.8 Color Interpolation in non-RGB Spaces
`
`The texture image may not represent an image at all,
`but may instead be thought of as a lookup table. In(cid:173)
`termediate values not represented in the table are ob(cid:173)
`tained through linear interpolation, a feature normally
`provided to handle image filtering.
`One way to use a three-dimensional lookup table is to
`fill it with RGB values that correspond to, for instance,
`HSV (Hue, Saturation, Value) values. The H, 5, and V
`values index the three dimensional tables. By assigning
`HSV values to the vertices of a polygon linear color in(cid:173)
`terpolation may be carried out in HSV space rather than
`RGB space. Other color spaces are easily supported.
`
`4.9 Phong Shading
`
`Phong shading with an infinite light and a local viewer
`may be simulated using a 3D texture image as follows.
`First, consider the function of x, y, and z that assigns
`a brightness value to coordinates that represent a (not
`necessarily unit length) vector. The vector is the reflec(cid:173)
`tion off of the surface of the vector from the eye to a
`point on the surface, and is thus a function of the nor(cid:173)
`mal at that point. The brightness function depends on
`the location of the light source. The 3D texture image
`is a lookup table for the brightness function given are(cid:173)
`flection vector. Then, for each polygon in the scene, the
`reflection vector is computed at each of the polygon's
`vertices. The coordinates of this vector are interpolated
`
`5
`
`
`
`Figure 5. 360 Degree fisheye projection.
`
`across the polygon and index the brightness function
`stored in the texture image. The brightness value so
`obtained modulates the color of the polygon. Multi(cid:173)
`ple lights may be obtained by incorporating multiple
`brightness functions into the texture image.
`
`4.10 Environment Mapping
`
`Environment mapping[Gre86] may be achieved
`through texture mapping in one of two ways. The first
`way requires sixtextyre images, ~il<::h_~Qfl'~spoll.ding to
`a face of a cube, that represent the surrounding environ(cid:173)
`ment. At each vertex of a polygon to be environment
`mapped, a reflection vector from the eye off of the sur(cid:173)
`face is computed. This reflection vector indexes one of
`the six texture images. As long as all the vertices of the
`polygon generate reflections into the same image, the
`image is mapped onto the polygon using projective tex(cid:173)
`turing. If a polygon has reflections into more than one
`face of the cube, then the polygon is subdivided into
`pieces, each of which generates reflections into only
`one face. Because a reflection vector is not computed at
`each pixel, this method is not exact, but the results are
`quite convincing when the polygons are small.
`The second method is to generate a single texture
`image of a perfectly reflecting sphere in the environ(cid:173)
`ment. This image consists of a circle representing the
`hemisphere of the environment behind the viewer, sur(cid:173)
`rounded by an annulus representing the hemisphere in
`front of the viewer. The image is that of a perfectly
`reflecting sphere located in the environment when the
`viewer is infinitely far from the sphere. At each polygon
`vertex, a texture coordinate generation function gen(cid:173)
`erates coordinates that index this texture image, and
`these are interpolated across the polygotc If the (nor~
`malized) reflection vector at a vertex is r = ( x y
`z ),
`and m = J2(z + 1), then the generated coordinates
`are xI m and y I m when the texture image is indexed
`
`(x, y, z)
`
`(xo y 0 ~ z;1
`
`)
`
`(0,0,1) .,_ _ __._~ - - - - - - - - -
`
`(Xp Yt)
`
`X
`xt = V2(z+1)
`
`Yt=~
`
`tiJJH;,
`x 2 + y 2 + (z + 1)2 = 2(z+1)
`
`Texture
`Image
`Figure 6. Spherical reflection geometry.
`
`by coordinates ranging from -1 to 1. (The calculation
`is diagrammed in Figure 6). This method has the dis(cid:173)
`advantage that the texture image must be recomputed
`whenever the view direction changes, but requires only
`a single texture image with no special polygon subdi(cid:173)
`vision (Figure 7).
`
`4.11 3D Halftoning
`
`Normal halftoned images are created by thresholding
`a source image with a halftone screen. Usually this
`halftone pattern of lines or dots bears no direct rela(cid:173)
`tionship to the geometry of the scene. Texture map(cid:173)
`ping allows halftonepattetns to be generated using a
`3D spatial function or parametric lines of a surface (Fig(cid:173)
`ure 8). This permits us to make halftone patterns that
`are bound to the surface geometry[ST90].
`
`6
`
`
`
`0
`
`Figure 7. Environment mapping.
`
`Figure 8. 3D halftoning.
`
`5 Conclusion
`
`Many graphics systems now provide hardware that
`supports texture mapping. As a result, generating a
`texture mapped scene need not take longer than gener(cid:173)
`ating a scene without texture mapping.
`We have shown that, in addition to its standard uses,
`texture mapping can be used for a large number of
`interesting applications, and that texture mapping is a
`powerful and flexible low level graphics drawing prim(cid:173)
`itive.
`
`References
`
`Kurt Akeley.
`1992.
`
`Personal Communication,
`
`[Cat74]
`
`[CG85]
`
`[Cro84]
`
`[DCH88]
`
`Ed Catmull. A Subdivision Algorithm for
`-Computer Display of Curved Surfaces. PhD
`thesis, University of Utah, 1974.
`
`Richard J. Carey and Donald P. Green(cid:173)
`berg. Textures for realistic image synthe(cid:173)
`sis. Computers & Graphics, 9(3):125-138,
`1985.
`
`F. C. Crow. Summed-area tables for texture
`mapping. Computer Graphics (SIGGRAPH
`'84 Proceedings), 18:207-212, July 1984.
`
`Robert A. Drebin, Loren Carpenter, and
`Pat Hanrahan. Volume rendering. Com(cid:173)
`puter Graphics (SIGGRAPH '88 Proceed(cid:173)
`ings), 22(4):65-74, August 1988.
`
`[Ake92]
`
`[Bur92]
`
`Derrick Bums. Personal Communication,
`1992.
`
`[Dre92]
`
`Bob Drebin. Personal Communication,
`1992.
`
`7
`
`
`
`[Dws+88] Michael Deering, Stephanie Winner, Bic
`Schediwy, Chris Duffy, and Neil Hunt.
`The triangle processor and normal vector
`shader: A VLSI system for high perfor(cid:173)
`mance graphics. Computer Graphics (SIC(cid:173)
`GRAPH '88 Proceedings), 22(4):21-30, Au(cid:173)
`gust 1988.
`
`G. Y. Gardner. Visual simulation of clouds.
`Computer Graphics (SIGGRAPH '85 Proceed(cid:173)
`ings), 19(3):297-303,July 1985.
`
`Ned Greene. Applications of world projec(cid:173)
`tions. Proceedings of Graphics Interface '86,
`pages 108-114,May 1986.
`
`[ST90]
`
`[Sab88]
`
`Paolo Sabella. A rendering algorithm
`for visualizing 3d scalar fields. Com(cid:173)
`puter Graphics (SIGGRAPH '88 Proceed(cid:173)
`ings), 22(4):51-58, August 1988.
`
`[SKvW+92] Mark Segal, Carl Korobkin, Rolf van
`Widenfelt, Jim Foran, and Paul Haeberli.
`Fast shadows and lighting effects using
`texture mapping. Computer Graphics (SIC(cid:173)
`GRAPH '92 Proceedings), 26(2):249-252,
`July 1992.
`
`Takafumi Saito and Tokiichiro Takahashi.
`Comprehensible rendering of 3-d shapes.
`Computer Graphics (SIGGRAPH '90 Proceed(cid:173)
`ings), 24(4):197-206, August 1990.
`
`Lee Westover. Footprint evaluation for
`volume rendering. Computer Graphics
`(SIGGRAPH '90 Proceedings), 24(4):367-
`376, August 1990.
`
`Lance Williams. Pyramidal parametrics.
`Computer Graphics (SIGGRAPH '83 Proceed(cid:173)
`ings), 17(3):1-ll,July 1983.
`
`[Gar85]
`
`[Gre86]
`
`[Gro90]
`
`[Hec86]
`
`[Hec89]
`
`[HL90]
`
`[LH91]
`
`Mark Grossman. Personal Communica(cid:173)
`tion, 1990.
`
`[Wes90]
`
`[Wil83]
`
`Paul S. Heckbert. Survey of texture map(cid:173)
`ping. IEEE Computer Graphics and Applica(cid:173)
`tions, 6(11):56--67, November 1986.
`
`Paul S. Heckbert. Fundamentals of tex(cid:173)
`ture mapping and image warping. M.sc.
`thesis, Department of Electrical Engineer(cid:173)
`ing and Computer Science, University of
`California, Berkeley, June 1989.
`
`Pat Hanrahan and Jim Lawson. A lan(cid:173)
`guage for shading and lighting calcula(cid:173)
`tions. Computer Graphics (SIGGRAPH '90
`Proceedings), 24(4):289-298, August 1990.
`
`David Laur and Pat Hanrahan. Hierar(cid:173)
`chical splatting: A progressive refinement
`algorithm for volume rendering. Com(cid:173)
`puter Graphics (SIGGRAPH '91 Proceed(cid:173)
`ings), 25(4):285-288, July 1991.
`
`[OTOK87] Masaaki Oka, Kyoya Tsutsui, Akio Ohba,
`and Yoshitaka Kurauchi. Real-time ma(cid:173)
`nipulation of texture-mapped surfaces.
`Computer Graphics (Proceedings of SIC(cid:173)
`GRAPH '87),July 1987.
`
`[Pea85]
`
`[Per85]
`
`D. R. Peachey. Solid texturing of complex
`surfaces. Computer Graphics (SIGGRAPH
`'85 Proceedings), 19(3):279~~8(:),Jl1lyl985.
`
`K. Perlin. An image synthesizer. Com(cid:173)
`puter Graphics (SIGGRAPH '85 Proceed(cid:173)
`ings), 19(3):287-296,July 1985.
`
`[RSC87] William Reeves, David Salesin, and Rob
`Cook. Rendering antialiased shadows
`with depth maps. Computer Graphics (SIC(cid:173)
`GRAPH '87 Proceedings), 21(4):283-291,
`July 1987.
`
`8
`
`