Game Development Reference
In-Depth Information
Cameras
There are a number of optimization strategies you can apply to cameras. In the introduction to
the camera component in Chapter 3, you learned that only the game objects in the frustum of the
camera between the near and far clipping planes are rendered (Figure 12-14 ), a built-in operation
called Frustum Culling. Adjusting the clipping planes so they don't encompass a larger area than
necessary minimizes the number of game objects to be rendered.
Field of View
Far
Clipping Plane
Near
Clipping Plane
Frustum
Figure 12-14. Near and far clipping planes define the volume of the camera frustum
The use of layers, discussed earlier in this chapter, can be used in conjunction with the Culling Mask
property of the camera component to limit rendering to only the game objects only in designated
layers. Or, if you need more than an all-or-nothing rendering of a layer of objects, you can use the
Camera.layerCullDistances() function in a script to assign different cull distances to each layer.
Level of Detail (LOD) is a Pro-only feature of Unity that reduces the number of triangles rendered for
an object the further away from the camera it is. Less triangles to render reduces the processor load.
Textures
Good practices with textures begin with the basics. Textures should have dimensions based on
powers of 2, as in 2, 4, 8, 16 and so on. The width and height don't have to be identical values.
More memory is used for non-power-of-2 dimensions, which in turn slows down the GPU. Another
optimization approach is to use a compressed texture file format to reduce memory usage.
More optimization can be achieved with the adjustment of texture import settings properties. Search
for Textures in the Project panel, and select one (if necessary, temporarily change the Texture Type to
Advanced) to view these properties in the Inspector (Figure 12-15 ).
 
Search WWH ::




Custom Search