Hubbry Logo
Texture mappingTexture mappingMain
Open search
Texture mapping
Community hub
Texture mapping
logo
8 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Contribute something
Texture mapping
Texture mapping
from Wikipedia
Mapping a two-dimensional texture onto a 3D model
1: 3D model without textures
2: Same model with textures

Texture mapping[1][2][3] is a term used in computer graphics to describe how 2D images are projected onto 3D models. The most common variant is the UV unwrap, which can be described as an inverse paper cutout, where the surfaces of a 3D model are cut apart so that it can be unfolded into a 2D coordinate space (UV space).

Semantic

[edit]

Texture mapping can multiply refer to (1) the task of unwrapping a 3D model (converting the surface of a 3D model into a 2D texture map), (2) applying a 2D texture map onto the surface of a 3D model, and (3) the 3D software algorithm that performs both tasks.

A texture map refers to a 2D image ("texture") that adds visual detail to a 3D model. The image can be stored as a raster graphic. A texture that stores a specific property—such as bumpiness, reflectivity, or transparency—is also referred to as a color map or roughness map.

The coordinate space that converts from a 3D model's 3D space into a 2D space for sampling from the texture map is variously called UV space, UV coordinates, or texture space.

Algorithm

[edit]

The following is a simplified explanation of how an algorithm could work to render an image:

  1. For each pixel, trace the coordinates of the screen into the 3D scene.
  2. If a 3D model is hit or, more precisely, the polygon of a 3D model hits the 2D UV coordinates, then
  3. The UV Coordinates are used to read the color from the texture and apply it to the pixel.

History

[edit]

The original technique was pioneered by Edwin Catmull in 1974 as part of his doctoral thesis.[4]

Texture mapping originally referred to diffuse mapping, a method that simply mapped pixels from a texture to a 3D surface ("wrapping" the image around the object). In recent decades, the advent of multi-pass rendering, multitexturing, mipmaps, and more complex mappings such as height mapping, bump mapping, normal mapping, displacement mapping, reflection mapping, specular mapping, occlusion mapping, and many other variations on the technique (controlled by a materials system) have made it possible to simulate near-photorealism in real time by vastly reducing the number of polygons and lighting calculations needed to construct a realistic and functional 3D scene.

Examples of multitexturing:
1: Untextured sphere, 2: Texture and bump maps, 3: Texture map only, 4: Opacity and texture maps

Texture maps

[edit]

A texture map[5][6] is an image applied ("mapped") to the surface of a shape or polygon.[7] This may be a bitmap image or a procedural texture. They may be stored in common image file formats, referenced by 3D model formats or material definitions, and assembled into resource bundles.

They may have one to three dimensions, although two dimensions are most common for visible surfaces. For use with modern hardware, texture map data may be stored in swizzled or tiled orderings to improve cache coherency. Rendering APIs typically manage texture map resources (which may be located in device memory) as buffers or surfaces, and may allow 'render to texture' for additional effects such as post processing or environment mapping.

Texture maps usually contain RGB color data (either stored as direct color, compressed formats, or indexed color), and sometimes an additional channel for alpha blending (RGBA) especially for billboards and decal overlay textures. It is possible to use the alpha channel (which may be convenient to store in formats parsed by hardware) for other uses such as specularity.

Multiple texture maps (or channels) may be combined for control over specularity, normals, displacement, or subsurface scattering, e.g. for skin rendering.

Multiple texture images may be combined in texture atlases or array textures to reduce state changes for modern hardware. (They may be considered a modern evolution of tile map graphics). Modern hardware often supports cube map textures with multiple faces for environment mapping.

Creation

[edit]

Texture maps may be acquired by scanning or digital photography, designed in image manipulation software such as GIMP or Photoshop, or painted onto 3D surfaces directly in a 3D paint tool such as Mudbox or ZBrush.

Texture application

[edit]

This process is akin to applying patterned paper to a plain white box. Every vertex in a polygon is assigned a texture coordinate (which in the 2D case is also known as UV coordinates).[8] This may be done through explicit assignment of vertex attributes, manually edited in a 3D modelling package through UV unwrapping tools. It is also possible to associate a procedural transformation from 3D space to texture space with the material. This might be accomplished via planar projection or, alternatively, cylindrical or spherical mapping. More complex mappings may consider the distance along a surface to minimize distortion. These coordinates are interpolated across the faces of polygons to sample the texture map during rendering. Textures may be repeated or mirrored to extend a finite rectangular bitmap over a larger area, or they may have a one-to-one unique "injective" mapping from every piece of a surface (which is important for render mapping and light mapping, also known as baking).

Texture space

[edit]

Texture mapping maps the model surface (or screen space during rasterization) into texture space; in this space, the texture map is visible in its undistorted form. UV unwrapping tools typically provide a view in texture space for manual editing of texture coordinates. Some rendering techniques such as subsurface scattering may be performed approximately by texture-space operations.

Multitexturing

[edit]

Multitexturing is the use of more than one texture at a time on a polygon.[9] 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. Microtextures or detail textures are used to add higher frequency details, and dirt maps add weathering and variation; this can greatly reduce the apparent periodicity of repeating textures. Modern graphics may use more than 10 layers, which are combined using shaders, for greater fidelity. 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 video games, as graphics hardware has become powerful enough to accommodate it in real-time.[10]

Texture filtering

[edit]

The way that samples (e.g. when viewed as pixels on the screen) are calculated from the texels (texture pixels) is governed by texture filtering. The cheapest 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. Anisotropic filtering better eliminates directional artefacts when viewing textures from oblique viewing angles.

Texture streaming

[edit]

Texture streaming is a means of using data streams for textures, where each texture is available in two or more different resolutions, as to determine which texture should be loaded into memory and used based on draw distance from the viewer and how much memory is available for textures. Texture streaming allows a rendering engine to use low resolution textures for objects far away from the viewer's camera, and resolve those into more detailed textures, read from a data source, as the point of view nears the objects.

Baking

[edit]

As an optimization, it is possible to render detail from a complex, high-resolution model or expensive process (such as global illumination) into a surface texture (possibly on a low-resolution model). This technique is called baking (or render mapping) and is most commonly used for light maps, but may also be used to generate normal maps and displacement maps. Some computer games (e.g. Messiah) have used this technique. The original Quake software engine used on-the-fly baking to combine light maps and colour maps in a process called surface caching.

Baking can be used as a form of level of detail generation, where a complex scene with many different elements and materials may be approximated by a single element with a single texture, which is then algorithmically reduced for lower rendering cost and fewer drawcalls. It is also used to take high-detail models from 3D sculpting software and point cloud scanning and approximate them with meshes more suitable for realtime rendering.

Rasterisation algorithms

[edit]

Various techniques have evolved in software and hardware implementations. Each offers different trade-offs in precision, versatility, and performance.

Affine texture mapping

[edit]
Because affine texture mapping does not take into account the depth information about a polygon's vertices, where the polygon is not perpendicular to the viewer, it produces a noticeable defect, especially when rasterized as triangles.

Affine texture mapping linearly interpolates texture coordinates across a surface, making it the fastest form of texture mapping. Some software and hardware (such as the original PlayStation) project vertices in 3D space onto the screen during rendering and linearly interpolate the texture coordinates in screen space between them. This may be done by incrementing fixed-point UV coordinates or by an incremental error algorithm akin to Bresenham's line algorithm.

In contrast to perpendicular polygons, this leads to noticeable distortion with perspective transformations (as shown in the figure: the checker box texture appears bent), especially as primitives near the camera. This distortion can be reduced by subdividing polygons into smaller polygons.

Using quad primitives for rectangular objects can look less incorrect than if those rectangles were split into triangles. However, since interpolating four points adds complexity to the rasterization, most early implementations preferred triangles only. Some hardware, such as the forward texture mapping used by the Nvidia NV1, offered efficient quad primitives. With perspective correction, triangles become equivalent to quad primitives and this advantage disappears.

For rectangular objects, especially when perpendicular to the view, linearly interpolating across a quad can give an affine result that is superior to the same rectangle split into two affine triangles.

For rectangular objects that are at right angles to the viewer (like floors and walls), the perspective only needs to be corrected in one direction across the screen rather than both. The correct perspective mapping can be calculated at the left and right edges of the floor. Affine linear interpolation across that horizontal span will look correct because every pixel along that line is the same distance from the viewer.

Perspective correctness

[edit]

Perspective correct texturing accounts for the vertices' positions in 3D space rather than simply interpolating coordinates in 2D screen space.[11] While achieving the correct visual effect, perspective correct texturing is more expensive to calculate.[11]

To perform perspective correction of the texture coordinates and , with being the depth component from the viewer's point of view, it is possible to take advantage of the fact that the values , , and are linear in screen space across the surface being textured. In contrast, the original , , and , before the division, are not linear across the surface in screen space. It is therefore possible to linearly interpolate these reciprocals across the surface, computing corrected values at each pixel, to produce a perspective correct texture mapping.

To do this, the reciprocals at each vertex of the geometry (three points for a triangle) are calculated. Vertex has reciprocals , , and . Then, linear interpolation can be done on these reciprocals between the vertices (e.g., using barycentric coordinates), resulting in interpolated values across the surface. At a given point, this yields the interpolated and (reciprocal ). However, as our division by altered their coordinate system, this cannot be used as texture coordinates. To correct back to the space, the corrected is calculated by taking the reciprocal once again: . This is then used to correct the coordinates: and .[12]

This correction makes it so that the difference from pixel to pixel between texture coordinates is smaller in parts of the polygon that are closer to the viewer (stretching the texture wider) and is larger in parts that are farther away (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: 3D graphics hardware typically supports perspective correct texturing.

Various techniques have evolved for rendering texture mapped geometry into images with different quality and precision trade-offs, which can be applied to both software and hardware.

Classic software texture mappers generally only performed simple texture mapping with one lighting effect at most (typically applied through a lookup table), and the perspective correctness was about 16 times more expensive.[compared to?]

Restricted camera rotation

[edit]
The Doom engine did not permit ramped floors or slanted walls. This requires only one perspective correction per horizontal or vertical span rather than one per-pixel.

The Doom engine restricted the world to vertical walls and horizontal floors and ceilings, with a camera that could only rotate about the vertical axis. This meant the walls would be a constant depth coordinate along a vertical line and the floors and ceilings would have a constant depth along a horizontal line. After performing one perspective correction calculation for the depth, the rest of the line could use fast affine mapping. Some later renderers of this era simulated a small amount of camera pitch with shearing which allowed the appearance of greater freedom while using the same rendering technique.

Some engines were able to render texture mapped heightmaps (e.g. Nova Logic's Voxel Space, and the engine for Outcast) via Bresenham-like incremental algorithms, producing the appearance of a texture mapped landscape without the use of traditional geometric primitives.[13]

Subdivision for perspective correction

[edit]

Every triangle can be further subdivided into groups of about 16 pixels in order to achieve two goals: keeping the arithmetic mill busy at all times and producing faster arithmetic results.[vague]

World space subdivision

[edit]

For perspective texture mapping without hardware support, a triangle is broken down into smaller triangles for rendering and affine mapping is used on them. The reason this technique works is that the distortion of affine mapping becomes much less noticeable on smaller polygons. The Sony PlayStation made extensive use of this because it only supported affine mapping in hardware and had a relatively high triangle throughput compared to its peers.

Screen space subdivision

[edit]
Screen space subdivision techniques. Top left: Quake-like, top right: bilinear, bottom left: const-z

Software renderers generally prefer 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), thus lessening the overhead further. Another reason is that affine texture mapping does not fit into the low number of CPU registers of the x86 CPU; the 68000 and RISC processors are much more suited for that approach.

A different approach was taken for Quake, 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.[14] As the polygons are rendered independently, 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.[original research?]

Other techniques

[edit]

One other technique is to approximate the perspective with a faster calculation, such as a polynomial. A second uses the value of the last two drawn pixels to linearly extrapolate the next value. For the latter, the division is then done starting from those values so that all that has to be divided is a small remainder.[15] However, the amount of bookkeeping needed makes this technique too slow on most systems.[citation needed]

A third technique, used by the Build Engine (used, most notably, in Duke Nukem 3D), builds on the constant distance trick used by the Doom engine by finding and rendering along the line of constant distance for arbitrary polygons.

Hardware implementations

[edit]

Texture mapping hardware was originally developed for simulation (e.g. as implemented in the Evans and Sutherland ESIG and Singer-Link Digital Image Generators DIG) and professional graphics workstations (such as Silicon Graphics) and broadcast digital video effects machines such as the Ampex ADO. Texture mapping hardware later appeared in arcade cabinets, consumer video game consoles, and PC video cards in the mid-1990s.

In flight simulations, texture mapping provided important motion and altitude cues necessary for pilot training not available on untextured surfaces. Additionally, texture mapping was implemented so that real-time processing of prefiltered texture patterns stored in memory could be accessed by the video processor in real-time.[16]

Modern graphics processing units (GPUs) provide specialised fixed function units called texture samplers, or texture mapping units, to perform texture mapping, usually with trilinear filtering or better multi-tap anisotropic filtering and hardware for decoding specific formats such as DXTn. As of 2016, texture mapping hardware is ubiquitous as most SOCs contain a suitable GPU.

Some hardware implementations combine texture mapping with hidden-surface determination in tile-based deferred rendering or scanline rendering; such systems only fetch the visible texels at the expense of using greater workspace for transformed vertices. Most systems have settled on the z-buffering approach, which can still reduce the texture mapping workload with front-to-back sorting.

On earlier graphics hardware, there were two competing paradigms of how to deliver a texture to the screen:

  1. Forward texture mapping iterates through each texel on the texture and decides where to place it on the screen.
  2. Inverse texture mapping instead iterates through pixels on the screen and decides what texel to use for each.

Of these methods, inverse texture mapping has become standard in modern hardware.

Inverse texture mapping

[edit]

With this method, a pixel on the screen is mapped to a point on the texture. Each vertex of a rendering primitive is projected to a point on the screen, and each of these points is mapped to a u,v texel coordinate on the texture. A rasterizer will interpolate between these points to fill in each pixel covered by the primitive.

The primary advantage of this method is that each pixel covered by a primitive will be traversed exactly once. Once a primitive's vertices are transformed, the amount of remaining work scales directly with how many pixels it covers on the screen.

The main disadvantage is that the memory access pattern in the texture space will not be linear if the texture is at an angle to the screen. This disadvantage is often addressed by texture caching techniques, such as the swizzled texture memory arrangement.

The linear interpolation can be used directly for simple and efficient affine texture mapping, but can also be adapted for perspective correctness.

Forward texture mapping

[edit]

Forward texture mapping maps each texel of the texture to a pixel on the screen. After transforming a rectangular primitive to a place on the screen, a forward texture mapping renderer iterates through each texel on the texture, splatting each one onto a pixel of the frame buffer. This was used by some hardware, such as the 3DO, the Sega Saturn and the NV1.

The primary advantage is that the texture will be accessed in a simple linear order, allowing very efficient caching of the texture data. However, this benefit is also its disadvantage: as a primitive gets smaller on screen, it still has to iterate over every texel in the texture, causing many pixels to be overdrawn redundantly.

This method is also well suited for rendering quad primitives rather than reducing them to triangles, which provided an advantage when perspective correct texturing was not available in hardware. This is because the affine distortion of a quad looks less incorrect than the same quad split into two triangles (see the § Affine texture mapping section above). The NV1 hardware also allowed a quadratic interpolation mode to provide an even better approximation of perspective correctness.

UV mapping became an important technique for 3D modelling and assisted in clipping the texture correctly when the primitive went past the edge of the screen, but existing hardware did not provide effective implementations of this. These shortcomings could have been addressed with further development, but GPU design has mostly shifted toward using the inverse mapping technique.

Applications

[edit]

Beyond 3D rendering, the availability of texture mapping hardware has inspired its use for accelerating other tasks:

Tomography

[edit]

It is possible to use texture mapping hardware to accelerate both the reconstruction of voxel data sets from tomographic scans, and to visualize the results.[17]

User interfaces

[edit]

Many user interfaces use texture mapping to accelerate animated transitions of screen elements, e.g. Exposé in Mac OS X.

See also

[edit]

References

[edit]

Software

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
Texture mapping is a fundamental technique in that involves applying a two-dimensional or procedural function, referred to as a texture, onto the surface of a three-dimensional model to simulate surface details such as color, patterns, roughness, or other attributes, thereby enhancing visual realism without requiring additional geometric complexity. This method allows for the efficient representation of high-frequency details like , fabric weaves, or variations on otherwise smooth polygons or curved surfaces. The concept of texture mapping was pioneered by in his 1974 PhD thesis, where he introduced an algorithm for mapping color textures onto bicubic surface patches during scan-line rendering, marking a significant advancement in generating shaded images of curved surfaces. Building on this, James F. Blinn and Martin E. Newell extended the approach in 1976 by incorporating texture mapping with reflection models to simulate environmental reflections; Blinn later introduced in 1978 to simulate surface perturbations, further improving the of computer-generated images. Subsequent developments, including filters and mipmapping, addressed challenges like visual artifacts during magnification or minification, as surveyed by Paul Heckbert in 1986, who categorized techniques into geometric mapping and filtering methods. Key techniques in texture mapping include perspective-correct interpolation to ensure accurate projection onto slanted surfaces, UV mapping for parameterizing how textures align with model coordinates, and advanced variants like for simulating lighting on detailed surfaces without altering geometry. These methods have become integral to real-time rendering in video games, , and , enabling high-fidelity visuals through on graphics processing units (GPUs). Further developments include procedural textures and volumetric mapping for applications in scientific visualization and architectural design. As of 2024, advancements like AI-assisted texture generation and integration with continue to expand the field.

Core Concepts

Definition and Purpose

Texture mapping is a fundamental technique in that associates values from a two-dimensional image or procedural function, known as a texture, with corresponding points on the surface of a three-dimensional model. This process enables the simulation of diverse material properties, including color variations, , and intricate patterns, by projecting the texture onto the 3D as if applying a or to an object. The primary purpose of texture mapping is to improve the visual realism and detail of rendered scenes without requiring an increase in the model's polygon count, which would otherwise demand significantly more computational resources. By leveraging precomputed 2D images or procedural functions, it efficiently captures and applies complex surface characteristics—such as the grain of , the weave of fabric, or the irregularity of —that would be impractical to model geometrically at high resolution. This approach balances performance and , making it indispensable in applications ranging from video games to architectural visualization. In its basic workflow, texture mapping begins with the assignment of texture coordinates, conventionally labeled as (u, v) parameters ranging from 0 to 1, to each vertex of the 3D polygon mesh. During rasterization, these coordinates are perspective-correctly interpolated across the polygon's interior to map each surface point to a specific location in the texture, from which the corresponding value is sampled and applied. Texture mapping differs from traditional shading methods, which primarily calculate illumination and color based on surface normals, light directions, and material reflectivity to simulate how light interacts with a uniform surface. Instead, texture mapping augments this by incorporating spatially varying, image-derived or procedurally generated details that modulate the base shading, allowing for more nuanced and believable material representations when combined.

Mathematical Foundations

Texture coordinates, often denoted as (u, v), parameterize points on a 3D surface in a normalized 2D space ranging from 0 to 1, where (0, 0) typically corresponds to the bottom-left corner of the texture image and (1, 1) to the top-right corner. These coordinates are assigned to each vertex of a and define how the texture is mapped onto the surface. To handle cases where coordinates fall outside [0, 1], wrapping modes extend the mapping: repeat mode tiles the texture by using the fractional part of the coordinates (e.g., u mod 1), clamp mode restricts values to [0, 1] by clamping excesses, and mirror mode reflects the texture across boundaries for seamless repetition. In the rendering pipeline, texture coordinates undergo transformation from world or object space to texture space using a dedicated texture matrix, which is typically a 4×4 matrix applied after the model-view-projection transformations. The transformed texture coordinate vector t\vec{t}
Add your contribution
Related Hubs
Contribute something
User Avatar
No comments yet.