Game Development Reference
In-Depth Information
The following figure shows two viewing frustums from the side view. The first has a
viewing angle of 40 degrees and the other has an angle of 18.5 degrees. The distance
of the near and far clip planes is the same in both cases.
40
18.5
A distant object will appear larger but will disappear if moved away from the x axis
in the smaller field of view (FOV). The objects will disappear quickly if moved away
from the camera but will be visible when moved farther away from the x axis in the
larger field of view.
The value we would specify for the viewing angle will vary from one game to the
next. An angle within the range of 45 and 60 degrees are usually safe to use.
The aspect ratio is calculated by dividing the frustum's width by its height. The
aspect ratio is used to calculate the viewing angle on the x axis. The aspect ratio, the
viewing angle, and the distances of the near and far planes are used to calculate the
projection matrix. The projection matrix is used to depict 3D objects on a 2D screen.
Defining the view frustum
Now, let's again look at the glMatrix function we have used throughout our code:
mat4.perspective(this.projMatrix, degToRadian(this.fieldOfView),
aspectRatio, this.nearClippingPlane, this.farClippingPlane)
The four parameters that we discussed are passed to the preceding function. The field
of view, the aspect ratio (width/height of our canvas), and the distances of the near
and far clipping planes are passed to create our perspective transformation matrix.
 
Search WWH ::




Custom Search