3D graphics eBook - Course Materials Repository
3D graphics eBook - Course Materials Repository
3D graphics eBook - Course Materials Repository
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Texture filtering 212<br />
Texture filtering<br />
In computer <strong>graphics</strong>, texture filtering or texture smoothing is the method used to determine the texture color for a<br />
texture mapped pixel, using the colors of nearby texels (pixels of the texture). Mathematically, texture filtering is a<br />
type of anti-aliasing, but it filters out high frequencies from the texture fill whereas other AA techniques generally<br />
focus on visual edges. Put simply, it allows a texture to be applied at many different shapes, sizes and angles while<br />
minimizing blurriness, shimmering and blocking.<br />
There are many methods of texture filtering, which make different trade-offs between computational complexity and<br />
image quality.<br />
The need for filtering<br />
During the texture mapping process, a 'texture lookup' takes place to find out where on the texture each pixel center<br />
falls. Since the textured surface may be at an arbitrary distance and orientation relative to the viewer, one pixel does<br />
not usually correspond directly to one texel. Some form of filtering has to be applied to determine the best color for<br />
the pixel. Insufficient or incorrect filtering will show up in the image as artifacts (errors in the image), such as<br />
'blockiness', jaggies, or shimmering.<br />
There can be different types of correspondence between a pixel and the texel/texels it represents on the screen. These<br />
depend on the position of the textured surface relative to the viewer, and different forms of filtering are needed in<br />
each case. Given a square texture mapped on to a square surface in the world, at some viewing distance the size of<br />
one screen pixel is exactly the same as one texel. Closer than that, the texels are larger than screen pixels, and need<br />
to be scaled up appropriately - a process known as texture magnification. Farther away, each texel is smaller than a<br />
pixel, and so one pixel covers multiple texels. In this case an appropriate color has to be picked based on the covered<br />
texels, via texture minification. Graphics APIs such as OpenGL allow the programmer to set different choices for<br />
minification and magnification filters.<br />
Note that even in the case where the pixels and texels are exactly the same size, one pixel will not necessarily match<br />
up exactly to one texel - it may be misaligned, and cover parts of up to four neighboring texels. Hence some form of<br />
filtering is still required.<br />
Mipmapping<br />
Mipmapping is a standard technique used to save some of the filtering work needed during texture minification.<br />
During texture magnification, the number of texels that need to be looked up for any pixel is always four or fewer;<br />
during minification, however, as the textured polygon moves farther away potentially the entire texture might fall<br />
into a single pixel. This would necessitate reading all of its texels and combining their values to correctly determine<br />
the pixel color, a prohibitively expensive operation. Mipmapping avoids this by prefiltering the texture and storing it<br />
in smaller sizes down to a single pixel. As the textured surface moves farther away, the texture being applied<br />
switches to the prefiltered smaller size. Different sizes of the mipmap are referred to as 'levels', with Level 0 being<br />
the largest size (used closest to the viewer), and increasing levels used at increasing distances.