Wrapping (graphics)
In the context of computer graphics, "wrapping" refers to the process of repeating a texture pattern across a surface. It's a fundamental technique used to map a two-dimensional image (the texture) onto a three-dimensional model. When the coordinates used to sample the texture (UV coordinates) extend beyond the range of 0 to 1, wrapping dictates how the texture is repeated.
There are several common wrapping modes:
-
Repeat (or Tile): The texture simply repeats horizontally and/or vertically. This is the most common and straightforward wrapping mode. When a UV coordinate is outside the 0-1 range, the integer part is discarded, and only the fractional part is used to sample the texture. This creates a seamless tiling effect.
-
Clamp (or Border): The texture is clamped to its edge pixels. When a UV coordinate is outside the 0-1 range, the texture is sampled from the edge pixel closest to that coordinate. This avoids repeating the texture but can create visible seams if the texture wasn't designed for seamless tiling.
-
Mirror Repeat (or Mirrored Tile): The texture is repeated, but each repetition is mirrored. This can help reduce visible seams between tiles, particularly when the original texture has asymmetrical features.
-
Mirror Clamp (or Mirrored Border): Similar to clamping, but mirrors the texture before clamping. This attempts to minimize the sharp discontinuity that can occur with simple clamping.
The choice of wrapping mode depends on the specific requirements of the application and the nature of the texture being used. Repeat mode is often suitable for textures that are designed to tile seamlessly, such as brick patterns or grass. Clamp mode is more appropriate when you want to avoid tiling or when the texture is not designed for tiling, such as a logo or a photograph. The mirror options can be useful for reducing artifacts when textures aren't perfectly tileable or when using low-resolution textures.