Game Development Reference
In-Depth Information
After changing the Perspective type to Orthographic , the camera frustum will also
change from a trapezoidal volume to a box. Everything within the box will be visible,
and nearer objects will continue to obscure more distant ones, but all other senses
of depth will be lost, as shown in the following screenshot. Hence, this camera is
considered suitable for 2D games.
The frustum for an Orthographic camera is a box
The central problem when working with the Orthographic cameras is how to create
a 1:1 relationship between world units (in the scene) and pixels (on screen). This
problem arises because in 2D games and GUIs, it's useful to show graphics on screen
at their default and correct sizes, as defined in the texture files. In most 3D games, by
contrast, texture mapping, foreshortening, and perspective means textures are seen
distorted, that is, projected onto the surface of 3D objects where they are viewed not
directly as though in a photo-editing program, but in perspective. With 2D games
and sprites, the situation is different. These graphics are typically viewed head on.
For this reason, it's desirable to display them in their default sizes, pixel for pixel.
This kind of display is called pixel perfection, because each pixel in the texture will
be shown onscreen and in the game, unchanged. Achieving this in practice, however,
requires a specific approach. In short, to map 1 world unit to 1 pixel, the Size field
in the Camera tab should be set to half the vertical resolution of the game. Thus, if
your game runs at 1024 x 768, the Size field should be 364 , because 768 / 2 = 364,
as shown here:
 
Search WWH ::




Custom Search