Game Development Reference
In-Depth Information
no surprise that if you combine black and white in equal amounts you get 50 percent
gray.
For textures, each sample involves the surrounding neighborhood of pixels
a pro-
cess known as bilinear filtering. The process is a linear combination of the pixel
values on all sides sampled pixel
nine values in all. These nine values are weighted
and combined to create the new sample. The same approach can be used with sounds
as well, as you might have expected.
Bilinear filtering is done right on the video card and is very fast, but processing tex-
tures at runtime to avoid subsampling is a different story, since the system would
have to create a set of smaller textures from a source texture. This processing can
be expensive, so most game engines do this processing as textures are imported into
the game, and they store these reduced images for each texture as a part of the game
assets. This master texture is known as a mip-map.
Mip-Mapping
Mip-mapping is a set of textures that has been preprocessed to contain one or more
levels of size reduction. In practice, the size reduction is in halves, all the way down
to one pixel that represents the dominant color of the entire texture. You might think
that this is a waste of memory, but it
d think. A
mip-map uses only one-third more memory than the original texture, and consider-
ing the vast improvement in the quality of the rendered result, you should provide
mip-maps for any texture that has a relatively high frequency of information. It is
especially useful for textures with regular patterns, such as our black-and-white line
texture.
The DirectX Texture Tool can generate mip-maps for you. To do this, you just load
your texture and select Format, Generate Mip Maps. You can then see the resulting
reduced textures by pressing PageUp and PageDn.
'
s actually more efficient than you
'
Really Long Polygons Can Be Trouble
One last thing about mip-maps: As you might expect, the renderer will choose
which mip-map to display based on the screen size of the polygon. This means
that it
s not a good idea to create huge polygons on your geometry that can
recede into the distance. The renderer might not be able to make a good choice
that will satisfy the look of the polygon edge, both closest to the camera and
the one farthest away. Some older video cards might select one mip-map for
the entire polygon and would therefore look strange. You can
'
t always count
on every player to have modern hardware. If you have to support these older
cards, you should consider breaking up longer polygons into ones that are
more square.
'
 
 
Search WWH ::




Custom Search