Second Life landscape by Vania Lahtoh, CC-BY-SA
Image data is often saved in or loaded from a file
There are many common image formats: JPEG, TIFF, PNG, GIF, etc
Features which may vary between formats are:
Applying textures involves the following steps:
Textures usually originate as image data in main memory (often from a file)
Data is passed to the graphics card for rendering
A "texture object" holds the data in graphics card memory for repeated use
Note: Historically, width & height
had to be powers of 2 - i.e., 2, 4, 8, 16, 32, 64, 128, 256, 512, etc.
This is often still a good idea.
Maximum size is typically 4096 x 4096
Objects need texture coordinates to define how a texture is applied
Texture coordinates form a coordinate system on the texture image, ranging from 0 to 1 in each direction
They are referred to as U & V (Unity3D, Maya, etc) or S & T (OpenGL)
(to distinguish them from X & Y geometric coordinates)
One texture coordinate should be assigned for each vertex
This defines what part of the texture should be used at that point
When a polygon is filled in, the vertices' texture coordinates are interpolated across its surface, to find the texture data for each pixel
A texture does not have to be evenly applied to a polygon.
The image can appear distorted, either as a result of the geometry or the texture coordinates used.
Texture coordinates outside the range 0 - 1 can be used to tile a texture
The "wrap" mode can select between repeating or clamping the texture
Applying a texture involves sampling - for each pixel drawn on the screen, OpenGL must compute a color from the texture image.
Texels (texture pixels) rarely match up exactly 1-to-1 with the pixels on the screen .
Filtering modes select what to do when texels are larger than screen pixels (magnification), or when texels are smaller than screen pixels (minification).
Common modes:
Mipmapping uses versions of the texture at smaller & smaller sizes image, to effectively pre-compute the average of many texels.
As a texture gets more and more minified, many texels will correspond to a single screen pixel, and using a "nearest" or "linear" filter will not compute an accurate result. The texture will appear to flicker as the object moves.
A mipmapped texture avoids the flickering problem when minified. As a result, it can look a bit fuzzier.