Game Development Reference
In-Depth Information
Sprites and tiles
One of the most important characteristics of a sprite image is transparency (also
called the alpha channel ). The image must be combined with underlying graphics
(with backgrounds or other sprites) at the game screen, creating an appearance of a
solid picture. Some decades ago, when computers had no such advanced calculat-
ing power, the sprites were small, and the simplest form of transparency was used.
Each pixel could be turned on or off, so the images featured so called hard edges ;
there was no soft transition between a transparent pixel and an opaque one. To mark
a zone in the image which would be transparent, a special color was used; usually, it
was a color never featured in the drawn artwork, for example, magenta (sometimes
developers called it magic pink ). The sprites with such transparency had sharp con-
tour and worked well only on graphic video systems with a small resolution.
Nowadays, most platforms, including mobile devices, support a more complex type of
transparency called alpha channel that supports shades of opacity. With this, smooth
transitions and translucent elements can be displayed. In most cases, the PNG file
format is used for sprites. It is lossless, no pixels will be lost after exporting the im-
age, and by default, the image editing tools create PNGs with a straight (non-premul-
tiplied) alpha channel. The term straight means that pixels have no precalculated data
for compositing, the only information is the exact RGB value and the alpha channel
(colors and alpha are not interconnected; a value of transparency cannot distort val-
ues in color channels). On the other hand, premultiplied type of transparency (color
and alpha channels are interconnected and by changing alpha information you also
change the RGB values) is in demand, because of its efficiency, natural behavior, and
being compression friendly, but PNG by default cannot work with it. This is why some
developers try to choose TGA or TIFF, which support both types of alpha channels, or
try to find third-party tools to convert the straight alpha channel type of transparency
in PNG to premultiplied. Besides normal transparency, game engines can also offer
some additional modes when creating the final scene is a bit more complex, which let
us create interesting visual effects. For instance, the Multiply mode, where dark pixels
of foreground images are added to the background but white ones are ignored, helps
to create shadows. A Screen mode is the opposite of Multiply; it lets us light up some
elements, creating the illusion of reflections, hotspots, and so on.
iOS devices also support a specific type of texture compression called PowerVR Tex-
ture Compression ( PVRTC ), created especially for effective storing and using of ras-
ter images; the files themselves are frequently referred to simply as PVRs. The file
Search WWH ::




Custom Search