All Topics  
Texture mapping

 

   Email Print
   Bookmark   Link






 

Texture mapping



 
 
Texture mapping is a method for adding detail, surface texture, or colour to a computer-generated graphic
Computer-generated imagery

Computer-generated imagery is the application of the field of computer graphics or, more specifically, 3D computer graphics to special effects in films, television programs, Television commercials, simulators and simulation generally, and printed media....
 or 3D model. Its application to 3D graphics was pioneered by Dr Edwin Catmull
Edwin Catmull

Edwin Catmull, Ph.D. is an Academy Award winning computer scientist and current president of Walt Disney Animation Studios and Pixar Animation Studios....
 in his Ph.D. thesis of 1974.

Texture mapping
A texture map is applied (mapped) to the surface of a shape, or polygon. 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.






Discussion
Ask a question about 'Texture mapping'
Start a new discussion about 'Texture mapping'
Answer questions from other users
Full Discussion Forum



Encyclopedia


Texture mapping is a method for adding detail, surface texture, or colour to a computer-generated graphic
Computer-generated imagery

Computer-generated imagery is the application of the field of computer graphics or, more specifically, 3D computer graphics to special effects in films, television programs, Television commercials, simulators and simulation generally, and printed media....
 or 3D model. Its application to 3D graphics was pioneered by Dr Edwin Catmull
Edwin Catmull

Edwin Catmull, Ph.D. is an Academy Award winning computer scientist and current president of Walt Disney Animation Studios and Pixar Animation Studios....
 in his Ph.D. thesis of 1974.

Texture mapping


A texture map is applied (mapped) to the surface of a shape, or polygon. 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. For instance, a light map
Lightmap

A lightmap is a 3D engine light data structure which contains the brightness of surfaces in a video game. Lightmaps are precomputed and used for static objects....
 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
Bump mapping

Bump mapping is a computer graphics technique where at each pixel, a perturbation to the surface normal of the object being rendering is looked up in a heightmap and applied before the illumination calculation is done ....
, 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. The way the resulting pixel
Pixel

In digital imaging, a pixel is the smallest item of information in an image. Pixels are normally arranged in a 2-dimensional grid, and are often represented using dots, squares, or rectangles....
s on the screen are calculated from the texel
Texel (graphics)

A texel, or texture element is the fundamental unit of texture space, used in computer graphics. Textures are represented by arrays of texels, just as pictures are represented by arrays of pixels....
s (texture pixels) is governed by texture filtering
Texture filtering

In computer graphics, texture filtering is the method used to determine the texture color for a Texture mapping pixel, using the colors of nearby Texel s ....
. The fastest method is to use the nearest-neighbour interpolation, but bilinear interpolation
Bilinear interpolation

In mathematics, bilinear interpolation is an extension of linear interpolation for interpolation functions of two variables on a regular grid. The key idea is to perform linear interpolation first in one direction, and then again in the other direction....
 or trilinear interpolation
Trilinear interpolation

Trilinear interpolation is a method of multivariate interpolation on a Three dimensional space regular grid. It approximates the value of an intermediate point within the local axial rectangular prism linearly, using data on the lattice points....
 between mipmaps
Mipmap

In 3D computer graphics texture filtering, MIP maps are pre-calculated, Optimization collections of images that accompany a main texture, intended to increase rendering speed and reduce aliasing artifacts....
 are two commonly used alternatives which reduce aliasing
Aliasing

In statistics, signal processing, computer graphics and related disciplines, aliasing refers to an effect that causes different continuous signals to become indistinguishable when sampling ....
 or jaggies
Jaggies

"Jaggies" is the informal name for aliasing artifacts in raster images, often caused by non-linear mixing effects producing high-frequency components and/or missing or poor anti-aliasing filtering prior to sampling....
. In the event of a texture coordinate being outside the texture, it is either clamped
Clamping (graphics)

In computer graphics, clamping is the process of limiting a position to an area. Unlike wrapping , clamping merely moves the point to the nearest available value....
 or wrapped
Wrapping (graphics)

In computer graphics, wrapping is the process of limiting a position to an area. A good example of wrapping is wallpaper, a single pattern repeated indefinitely over a wall....
.

Perspective correctness


Texture coordinates are specified at each vertex of a given triangle, and these coordinates are interpolated using an extended Bresenham's line algorithm
Bresenham's line algorithm

The Bresenham line algorithm is an algorithm that determines which points in an n-dimensional raster should be plotted in order to form a close approximation to a straight line between two given points....
. If these texture coordinates are linearly interpolated
Linear interpolation

Linear interpolation is a method of curve fitting using linear polynomials. It is heavily employed in mathematics , and numerous applications including computer graphics....
 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).

Perspective correct texturing accounts for the vertices' positions in 3D space, rather than simply interpolating a 2D triangle. This achieves the correct visual effect, but it is slower to calculate. Instead of interpolating the texture coordinates directly, the 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.

Doom Ingame 1
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
Quake

Quake is a first-person shooter computer game that was released by id Software on June 22, 1996. It was the first game in the popular Quake of computer and video games....
, which would calculate perspective correct coordinates only once every 16 pixels of a scanline and linearly interpolate between them, effectively running at the speed of linear interpolation because the perspective correct calculation runs in parallel on the co-processor . 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. Yet another technique uses 1/z value of the last two drawn pixels to linearly extrapolate the next value. Then the division is done starting from those values so that only a small reminder has to be divided , the amount of bookkeeping makes this method too slow on most systems. Finally, some programmers
Build engine

The Build engine is a first-person shooter game engine created by Ken Silverman for 3D Realms. Like the Doom engine, the Build engine represents its world on a 2D computer graphics grid using closed 2D shapes called sectors, and uses simple flat objects called sprites to populate the world geometry with objects....
 extended the constant distance trick used for Doom by finding the line of constant distance for arbitrary polygons and rendering along it.

See also


External links


  • at GameDev.net
  • using XNA/DirectX, from www.riemers.net
  • Texture mapping with bezier lines
  • Interactive Relighting for Photos