Abstracting the Eye

How to 3D

Chapter 7: Camera

Abstracting the Eye

One stop on the graphics pipeline is eye space, the coordinate system in which the viewer's eye is assumed to be at the origin looking down the negative z-axis. You've learned that this space is convenient for lighting. In particular, having the eye at \(\begin{bmatrix}0&0&0\end{bmatrix}\) simplifies computation of a fragment's specular term. However, parking the eye permanently at the origin and fixing its gaze to the negative z-axis is limiting. We have to arrange the whole world around the inflexible eye. That seems backward. Isn't the eye just another entity in the world like the models? We want to place the eye anywhere in the world and have it look in any direction.

Many graphics libraries open up all of world space to the viewer by providing a camera abstraction. The camera is positioned at an arbitrary world space location, and the abstraction builds a translation matrix that transforms the scene so this location becomes the origin. The camera is then pointed in any direction, and the abstraction builds a rotation matrix that rotates the scene so that this line of sight becomes the negative z-axis.

In this chapter you will learn how to build this abstraction. By its end, you will be able to answer the following questions:

The camera abstractions that we'll build are something of an illusion, just like the orthographic and perspective projection matrices. None of these change the fundamental fact that WebGL only renders a unit cube around the origin. The abstractions just make us think that the world is bigger and that the eye is mobile. In truth, they just build matrices that place the chunk of the world that we want to see into the small box that WebGL expects.

LookAt Matrix →