Every game needs a crate texture
Early on textures was simply mapped onto the polygons. Then with the use of multiple textures one could started to blend them in the fixed function pipeline. Now with shaders textures are not so much specific images but rather data that one needs to pick and choose how to use them in the shader. For the details on how textures are used and abused look in the Material section.
A texture can be in one-, two-, or three-dimensions. A 2D texture is a image, a 3D texture is a volume and a 1D texture is like a gradient. Each element in the texture is called a texel and to select a texel one use coordinates of the same dimension as the texture. The coordinates normally go from 0 to 1 so [0.5,0.5] is in the middle of a 2D texture. Getting the texel from the texture with a coordinate is called sampling the texture. A texture can also be in the form of a Cubemap.
The size of the texture is how big each dimension is in number of texel's. It's common for sizes to be power of two (64,128,256,512,...) as graphic cards liked it best that way. The size in all the dimensions does not need to be the same. The max size supported depends on the graphic card and available memory. One solution to large textures is to use Virtual Texture that are not all loaded at the same time.
The format of a texture describe what data each texel contain.
- Texture formats for 2D games - 2015 : Part 1, 2: Palettes, 3: DXT and PVRTC and 4: Overview.
- Understanding BCn Texture Compression Formats - 2012
- Texture tiling and swizzling - 2011
- Using ASTC Texture Compression for Game Assets
Filtering and Mipmapping
Say there is a textured surface on the screen where each texel is covering one pixel. If the surface move closer each texel with start to cover more then one pixel, known as texture magnification. If the surface move away there will be more then one texel inside each pixel, known as texture minification. In each of these cases a filtering function is used to select what the color of the texel that is sampled from the texture will be. The visual quality can be improved with mipmaps. A mipmap for a texture is a chain of down sampled images of the texture. So a 256x256 texture have mipmaps of size 128x128,64x64,32x32 and so on. When trying to sample a texture the mipmap is first selected depending on the distance to the surface drawn and then the mipmap is sampled with the filter functions. Mipmaps only affect minification.
- Nearest: Takes the texel closest to the ones that we try to sample. Creates a Minecraft style blocky pixel effect during magnification.
- Bilinear: Take the four nearest texels to the part we try to sample and combine them.
- Trilinear: Select the two closest mipmaps and sample them both with bilinear filtering. The two values are then interpolated for the final result.
- Mip-mapping is hard – importance of keeping your quads full - 2019
- Shadow Maps Don’t (Always) Need Mips - 2014
- Quick example of Anisotropic Filtering in OpenGL - 2012
- A Way to Visualize Mip Levels - 2011
- Computing Alpha Mipmaps - 2010
- Mipmaps, generation and level selection - 2008
- Applying Sampling Theory To Real-Time Graphics
- Mipmapping with Bidirectional Techniques
- Mip-mapping is hard – importance of keeping your quads fullFake vs True Displacement - Part 1/2 - 2020
- stable filtering — part 2 - 2019
- Bilinear texture filtering – artifacts, alternatives, and frequency domain analysis - 2020
Conformal Texture Mapping - 2017
Rethinking Texture Mapping - 2017
Mesh Color Textures - 2017
Mesh Color Textures - 2017
Textures : can we cheat ? - 2011
Normal Mapping - 2018
Texture Generation Part 2: Normal Swizzling - 2020
Texture Generation - 2020
Alpha Compositing - 2019