Game Development Reference
In-Depth Information
This texture is 128 × 128 pixels, with alternating vertical lines exactly one pixel in
width. If you reduced this texture in a simple paint program, you might get nothing
but a 64 × 64 texture that is completely black. What
s going on here?
When the texture is reduced to half its size, the naive approach would select every
other pixel in the grid, which in this case happens to be every black pixel on the tex-
ture. The original texture has a certain amount of information, or frequency, in its
data stream. The frequency of the above texture is the number of alternating lines.
Each pair of black-and-white lines is considered one wave in a waveform that
makes up the entire texture. The frequency of this texture is 64, since it takes 64
waves of black-and-white lines to make up the texture.
Subsampling is what occurs if any waveform is sampled at less than twice its fre-
quency. In the previous case, any sample taken at 128 samples or fewer will drop
critical information from the original data stream.
It might seem weird to think of textures having a frequency, but they do. A high
frequency implies a high degree of information content. In the case of a texture, it
has to do with the number of undulations in the waveform that make up the data
stream. If the texture were nothing more than a black square, it would have a mini-
mal frequency and therefore carry only the smallest amount of information. A tex-
ture that is a solid black square, no matter how large, can be sampled at any rate
whatsoever. No information is lost because there isn ' t that much information to
begin with.
In case you are wondering whether or not this subject of subsampling can apply to
audio waveforms, it can. Let
'
s assume that you have a high-frequency sound, say a
tone at 11KHz. If you attempt to sample this tone in a WAV file at 11KHz, exactly
the frequency of the tone, you won
'
ll get a sub-
sampled version of the original sound. Just as the texture turned completely black,
your
'
t be happy with the results. You
'
subsampled sound would be a completely flat
line, erasing the sound
altogether.
It turns out there is a solution for this problem, and it involves processing and filter-
ing the original data stream to preserve as much of the original waveform as possible.
For sounds and textures, the new sample isn ' t just grabbed from an original piece of
data in the waveform. The data closest to the sample is used to figure out what is
happening to the waveform,
instead of one value of the waveform at a discrete
point in time.
In the case of our lined texture used previously, the waveform is alternating from
black to white as you sample horizontally across the texture, so naturally if the tex-
ture diminishes in size, the eye should begin to perceive a 50 percent gray surface. It
'
s
Search WWH ::




Custom Search