Sei sulla pagina 1di 3

12/10/2010 13:29

Texture mapping
From Wikipedia, the free encyclopedia

Texture mapping is a method for adding detail, surface texture (a bitmap or raster image), or color to a computer-
generated graphic or 3D model. Its application to 3D graphics was pioneered by Dr Edwin Catmull in his Ph.D. thesis
of 1974.

Contents
1 Texture mapping
2 Perspective correctness 1 = 3D model without textures
3 Resolution 2 = 3D model with textures
4 See also
5 References
6 External links

Texture mapping
A texture map is applied (mapped) to the surface of a shape or polygon.[1] This process is akin to applying patterned paper to a plain white box.

Multitexturing is the use of more than one texture at a time on a polygon.[2] For instance, a light map texture may be used to light a surface as an
alternative to recalculating that lighting every time the surface is rendered. Another multitexture technique is bump mapping, which allows a texture to
directly control the facing direction of a surface for the purposes of its lighting calculations; it can give a very good appearance of a complex surface, such as
tree bark or rough concrete, that takes on lighting detail in addition to the usual detailed coloring. Bump mapping has become popular in recent video games
as graphics hardware has become powerful enough to accommodate it in real-time.

The way the resulting pixels on the screen are calculated from the texels (texture pixels) is governed by texture
filtering. The fastest method is to use the nearest-neighbour interpolation, but bilinear interpolation or trilinear
interpolation between mipmaps are two commonly used alternatives which reduce aliasing or jaggies. In the event of a
texture coordinate being outside the texture, it is either clamped or wrapped.

Examples of multitexturing
Perspective correctness
1. Untextured sphere 2. Texture and
bump maps 3. Texture map only 4. Texture coordinates are specified at each vertex
Opacity and texture maps of a given triangle, and these coordinates are
interpolated using an extended Bresenham's line
algorithm. If these texture coordinates are linearly
interpolated across the screen, the result is affine texture mapping. This is a fast
calculation, but there can be a noticeable discontinuity between adjacent triangles when
these triangles are at an angle to the plane of the screen (see figure at right textures (the
checker boxes) appear bent).
Because affine texture mapping does not take into account the
Perspective correct texturing accounts for the vertices' positions in 3D space, rather depth information about a polygon's vertices, where the polygon
than simply interpolating a 2D triangle. This achieves the correct visual effect, but it is is not perpendicular to the viewer it produces a noticeable
slower to calculate. Instead of interpolating the texture coordinates directly, the defect.
coordinates are divided by their depth (relative to the viewer), and the reciprocal of the
depth value is also interpolated and used to recover the perspective-correct coordinate.
This correction makes it so that in parts of the polygon that are closer to the viewer the difference from pixel to pixel between texture coordinates is smaller
(stretching the texture wider), and in parts that are farther away this difference is larger (compressing the texture).

Affine texture mapping directly interpolates a texture coordinate between two endpoints and :
where
Perspective correct mapping interpolates after dividing by depth , then uses its interpolated reciprocal to recover the correct coordinate:

All modern graphics hardware implements perspective correct texturing.

http://en.wikipedia.org/wiki/Texture_mapping 1 de 3
12/10/2010 13:29
Classic texture mappers generally did only simple mapping with at most one lighting effect and the
perspective correctness was about 16 times more expensive. Thus to on the one hand not wait on the
divisions and on the other hand not let the division and multiplication circuits run idle every triangle is
subdivided in subgroups of about 16 pixels. For perspective texture mapping ignorant hardware a
triangle is broken down into smaller triangles for rendering, which in non architectural applications has
some synergy with level of detail. Software renderers generally preferred screen subdivision because it
has less overhead. Additionally they try to do linear interpolation along a line of pixels to simplify the
set-up (compared to 2d affine interpolation) and thus again the overhead (also affine texture-mapping
does not fit into the low number of registers of the 086 CPU, the 68000 or any RISC is much more
suited). For instance, Doom restricted the world to vertical walls and horizontal floors/ceilings. This
meant the walls would be a constant distance along a vertical line and the floors/ceilings would be a
constant distance along a horizontal line. A fast affine mapping could be used along those lines
because it would be correct. A different approach was taken for Quake, which would calculate
perspective correct coordinates only once every 16 pixels of a scanline and linearly interpolate Doom renders vertical spans (walls) with affine
between them, effectively running at the speed of linear interpolation because the perspective correct texture mapping.
calculation runs in parallel on the co-processor [3]. The polygons are rendered independently, hence it
may be possible to switch between spans and columns or diagonal directions depending on the
orientation of the polygon normal to achieve a more constant z, but the effort seems not to be worth it.

Another technique was subdividing the polygons into smaller polygons, like triangles in 3d-space or squares in screen
space, and using an affine mapping on them. The distortion of affine mapping becomes much less noticeable on smaller
polygons. Yet another technique was approximating the perspective with a faster calculation, such as a polynomial. Still
another technique uses 1/z value of the last two drawn pixels to linearly extrapolate the next value. The division is then
done starting from those values so that only a small remainder has to be divided [4], but the amount of bookkeeping
makes this method too slow on most systems. Finally, some programmers extended the constant distance trick used for
Doom by finding the line of constant distance for arbitrary polygons and rendering along it.

Resolution Screen space sub division


techniques. Top left: Quake
The resolution of a texture map is usually given in terms of pixel width, assuming the map is square: as an example, a 1K like, top right: bilinear, bottom
left: const-z
texture has a resolution of 1024x1024, that is 1048576 pixels.

Graphics cards cannot render texture maps beyond a threshold that depends on their technical specifications, mostly in terms of RAM.

See also
Bump mapping
Clamping
Displacement mapping
Edwin Catmull
Normal mapping
Relief mapping (computer graphics)
Parametrization
Texture synthesis
Texture atlas
Texture filtering
Texture splatting a technique for combining textures.
UV Mapping
UVW Mapping
Wrapping (graphics)
Baked textures

References
1. ^ Jon Radoff, Anatomy of an MMORPG, http://radoff.com/blog/2008/08/22/anatomy-of-an-mmorpg/
2. ^ Blythe, David. Advanced Graphics Programming Techniques Using OpenGL (http://www.opengl.org/resources/code/samples/sig99/advanced99
/notes/notes.html) . Siggraph 1999. (see: Multitexture (http://www.opengl.org/resources/code/samples/sig99/advanced99/notes/node60.html) )
3. ^ Abrash, Michael. Michael Abrash's Graphics Programming Black Book Special Edition. The Coriolis Group, Scottsdale Arizona, 1997. ISBN
1-57610-174-6 (PDF (http://www.gamedev.net/reference/articles/article1698.asp) ) (Chapter 70, pg. 1282)
4. ^ Spackman, John Neil, "Apparatus and method for performing perspectively correct interpolation in computer graphics", US patent 5739818
(http://v3.espacenet.com/textdoc?DB=EPODOC&IDX=US5739818) , issued 1998-04-14

External links
Perspective Corrected Texture Mapping (http://www.gamedev.net/reference/articles/article331.asp) at GameDev.net
Introduction into texture mapping using C and SDL (http://www.happy-werner.de/howtos/isw/parts/3d/chapter_2/chapter_2_texture_mapping.pdf)
Programming a textured terrain (http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series4/Textured_terrain.php) using XNA/DirectX, from
www.riemers.net
Perspective correct texturing (http://www.gamers.org/dEngine/quake/papers/checker_texmap.html)
Time Texturing (http://www.fawzma.com/time-texturing-texture-mapping-with-bezier-lines/) Texture mapping with bezier lines
Polynomial Texture Mapping (http://www.hp.com/idealab/us/en/relight.html) Interactive Relighting for Photos
Retrieved from "http://en.wikipedia.org/wiki/Texture_mapping"

http://en.wikipedia.org/wiki/Texture_mapping 2 de 3
12/10/2010 13:29
Categories: Texture mapping

This page was last modified on 12 October 2010 at 11:15.


Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. See Terms of Use for details.
Wikipedia is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.

http://en.wikipedia.org/wiki/Texture_mapping 3 de 3

Potrebbero piacerti anche