Game Development Reference
Step 5. Create two new materials in the Project called Material 1 and
Material 2 . You don't need to give them any particular settings.
Step 6. Add Material 1 to one plane and Material 2 to the other. Now
look at the number of draw calls. It will be equal to 2, the same as the
number of materials.
Step 7. Right-click on one of the planes in the Hierarchy and select
Duplicate. The number of draw calls will remain at 2 as there are still
only two materials being used.
Step 8. Create another material and add it to the latest plane. The
number of draw calls will increase to 3.
As the number of draw calls increases, the slower your game will run. Albeit
a great number of draw calls would be required to make any noticeable
difference on a high-performance gaming machine. However, if you port your
application to a mobile device, a dramatic effect on performance is seen after
around 15 draw calls.
Materials aren't the only things that will increase the number of draw calls. As
the polycounts of the meshes in the game environment increase, so too will
the draw calls. However, polycounts don't have a one-to-one relationship with
performance as materials do. Therefore, it is essential to consider the way in
which sprite materials are handled.
3.3 Texture Atlas
Considering that a single material made from a texture that is 512 × 512 will
take the same number of draw calls as one that is 32 × 32, it seems a waste
to use only a 32 × 32 texture. Therefore, if the 32 × 32 image were put into a
512 × 512 image, there would be plenty of space in that image for other small
images. Combining images into one texture is a common technique in games
and is called a texture atlas .
In a texture atlas, each smaller image has its own set of pixel coordinates
and a width and height. To create such an atlas you can use a paint
program such as Photoshop or Gimp to combine smaller images into a
single larger one. Figure 3.2 shows an example texture map in Gimp. Each
image is placed such that a bounding box around it does not overlap with
any other image. This allows for easy extraction of single images from the
texture map in the game engine. In this example, the bounding box for the
small car starts at (0,0) pixels and ends at (40,40) pixels. Gimp is useful for
creating texture atlases; the pixel location of the mouse cursor is shown in
the lower left-hand corner of the window. This makes it easier to extract
the bounding boxes for each image. In Gimp, however, (0,0) is in the upper
left-hand corner of the image. If you were to use Adobe Illustrator, (0,0) is