Often smooth shading of geometry is not desirable. For example the plywood table top is not a smoothly shaded object. Indeed, hardly any object in real life are made of smooth listless surfaces. We use textures to augment the reality obtained by smooth surfaces. A texture is an image that we paste atop the geometry, e.g., a polygon. The image could be generated by a procedure, or may just be a photograph or a painting. We first provide guidelines for pasting the image onto the geometry -- it's orientation, position and scale on the geometry. This is typically done by imposing an additional coordinate system onto the geometry. In addition to the [x, y, z] coordinates of a point we also associate with it the [u, v] texture coordinates. [u, v] may be as simple as an index into an RGB-table corresponding to the texture image. Of-course, if u and v are fractional, we must convert them to integers in order to use them as indices. Rounding off is one simple way to do it. In general a transformation of [u, v] leads to an index [s, t] in the texture table.
To add texture mapping to the scan-line algorithm, we just interpolate the texture coordinates along polygon edges and then along a span. For each pixel, thus, we obtain a texture coordinate [u,v] which we transform to [s,t] and blend the intensity in the corresponding texture entry with the one obtained by smooth shading that we talked about earlier.
Just as sampling of continuous geometry to create a pix-map can cause aliasing, a sampled table of values for a continuous texture image can result in aliasing. Anti-aliasing of textures can be performed just as it is performed for geometry rendering -- by filtering. We super-sample the texture and take a weighted average of the sub-samples (i.e., filter them) to obtain the final value. Mip-maps are a convenient arrangement to store such filtered table computed a priori. Multiple levels of filters are stored with increasing filter size. The MIP-MAP is arranged in a square (2D table) divided into four sub-squares. Three of those sub-squares store the R, G and B components of the texture respectively. The fourth sub-square recursively stores a filtered MIP-MAP with 2x2 super-sampling.