So how do we select a good value for the viewing distance (d)? We could just experiment to find a value that makes the 3D scene look convincing, but we can take the guesswork out of it by calculating d from the field of view (fov), which is the angular range of the scene that is visible at one moment. For human beings, the fov is the range from the left eye to the right eye, which is about 180 degrees. Figure 8-7 shows the relationship between fov and viewing distance. When the fov angle increases (grows wider), the viewing distance decreases as more of the scene becomes visible. The opposite happens when the fov decreases (becomes narrower); viewing distance increases and less of the scene is visible.
Figure 8-6. The viewing distance in a perspective projection screen height screen width
Field of view is a better way to define how much perspective there will be in your 3D scene, but we still need a value for d in the perspective projection. To calculate d from the fov, we need to use a little trigonometry. Listing 8-7 is a function that takes the fov plus the screen width, and uses the tan function in the math module to calculate the viewing distance.
Was this article helpful?