6.3 Environment Camera
One advantage of ray tracing compared to scan line or rasterization-based rendering methods is that it’s easy to employ unusual image projections. We have great freedom in how the image sample positions are mapped into ray directions, since the rendering algorithm doesn’t depend on properties such as straight lines in the scene always projecting to straight lines in the image.
In this section, we will describe a camera model that traces rays in all directions around a point in the scene, giving a 2D view of everything that is visible from that point. Consider a sphere around the camera position in the scene; choosing points on that sphere gives directions to trace rays in. If we parameterize the sphere with spherical coordinates, each point on the sphere is associated with a pair, where and . (See Section 5.5.2 for more details on spherical coordinates.) This type of image is particularly useful because it represents all of the incident light at a point on the scene. (One important use of this image representation is environment lighting—a rendering technique that uses image-based representations of light in a scene.) Figure 6.14 shows this camera in action with the San Miguel model. values range from 0 at the top of the image to at the bottom of the image, and values range from 0 to , moving from left to right across the image.
The EnvironmentCamera derives directly from the Camera class, not the ProjectiveCamera class. This is because the environmental projection is nonlinear and cannot be captured by a single matrix. This camera is defined in the files cameras/environment.h and cameras/environment.cpp.
To compute the coordinates for this ray, NDC coordinates are computed from the raster image sample position and then scaled to cover the range. Next, the spherical coordinate formula is used to compute the ray direction, and finally the direction is converted to world space. (Note that because the direction is “up” in camera space, here the and coordinates in the spherical coordinate formula are exchanged in comparison to usage elsewhere in the system.)