# Distributed Ray Tracing

by Allen Martin

## Introduction

### What is distributed ray tracing?

Distributed ray tracing is not ray tracing on a distributed system.
Distributed ray tracing is a ray tracing method based on randomly distributed oversampling to reduce aliasing artifacts in rendered images.

Traditional ray tracing systems suffer from aliasing artifacts. The term aliasing in computer graphics is loosely defined. It can mean almost anything unwanted in the rendered image. Typically aliasing is used to describe jagged edges. In the real world things are not quite as perfect as in a computer generated world - edges and boundaries are not as sharp, reflections are not as perfect, and things can be in and out of focus. If a renderer is being used to approximate reality then these things must be taken into account.

Distributed ray tracing uses oversampling to reduce aliasing artifacts. Oversampling is a process where instead of sampling a single value, multiple samples are taken and averaged together. The location of where the sample is taken is varied slightly so that the resulting average is an approximation of a finite area covered by the samples. This is called an anti-aliasing method.

## Problem Description

Computer graphics attempts to represent a real-world scene on a video monitor. The raster of a monitor has a finite resolution, but the real-world scene that it is attempting to emulate is infinite resolution. Each pixel in the display covers a finite area, therefore it is an approximation of the part of the scene that can be viewed through that pixel. In traditional ray tracing a single ray per pixel is used to sample the real world by casting it through center of the pixel and evaluating what it hits. This is a single sample approximation for the value of the pixel, and while computationally simple, it may suffer from inaccuracy.

The intensity of a point in a scene can be represented analytically by an integral over the illumination function and the reflectance function. The evaluation of this integral, while extremely accurate, is too expensive for most graphics applications. Traditional ray tracing makes assumptions about the components of this integral to simplify evaluation. For example, the Phong model assumes that diffuse light is reflected equally in all directions, and specular light is at full intensity in the reflected direction and falls off exponentially with the cosine of the angle away from this direction. In addition, light sources are modeled as single points, so the light that emanates from a source and hits a surface can be represented by a single ray.

Distributed ray tracing uses a slightly better approximation for the illumination and reflectance integrals. The idea is based in the theory of oversampling. Instead of approximating an integral by a single scalar value, the function is point sampled and these samples are used to define a more accurate scalar value. The practical benefits of this are:

Gloss (fuzzy reflections)
Fuzzy translucency
Depth of field
Motion blur

## Gloss

Traditional ray tracing is good at representing perfect reflecting surfaces, but poor at representing glossy or partially reflecting surfaces. Only when surfaces are perfect mirrors do the reflections look identical to the scene they are reflecting. More often surfaces are glossy and reflect a blurred image of the scene. This is due to the light scattering properties of the surface. Reflections in traditional ray tracing are always sharp, even partial reflections.

Glossy surfaces are generated in distributed ray tracing by randomly distributing rays reflected by a surface. Instead of casting a single ray out in the reflecting direction, a packet of rays are sent out around the reflecting direction. The actual value of reflectance can be found by taking the statistical mean of the values returned by each of these rays.

This method can also be used to generate specular highlights by using area light sources. If rays that reflect off a surface hit a light source, they will add to the specular component of the surface illumination. This can replace the specular component of the Phong model.

## Translucency

The analytic function for translucency is similar to the analytic function for shading, but a transmission function is used instead of a reflectance function, and the light is gathered from the other side of the surface.

Traditional ray tracing is good at representing perfectly transparent surfaces, but poor at representing translucent surfaces. Real surfaces that are translucent generally transmit a blurred image of the scene behind them. Distributed ray tracing achieves this type of translucent surface by casting randomly distributed rays in the general direction of the transmitted ray from traditional ray tracing. The value computed from each of these rays is then averaged to form the true translucent component.

Shadows in traditional ray tracing are discrete. When shading a point, each light source is checked to see if it is visible. If the source is visible it has a contribution to the shading of the point, otherwise it does not. The light source itself is modeled by a single point, which is fairly accurate for sources that are a great distance away, but a poor representation for large sources or sources that are close. The result of this discrete decision making is that the edges of shadows are very sharp. There is a distinct transition from when points are visible to the light source to when they are not. Shadows in the real world are much softer. The transition from fully shadowed to partially shadowed is gradual. This is due to the finite area of real light sources, and scattering of light of other surfaces.

Distributed ray tracing attempts to approximate soft shadows by modeling light sources as spheres. When a point is tested to see if it is in shadow, a set of rays are cast about the projected area of the light source. The amount of light transmitted from the source to the point can be approximated by the ratio of the number of rays that hit the source to the number of rays cast. This ratio can be used in the standard Phong lighting calculations to scale the amount of light that hits a surface.

## Depth of Field

Both the human eye and cameras have a finite lens aperture, and therefore have a finite depth of field. Objects that are two far away or two close will appear unfocused and blurry. Almost all computer graphics rendering techniques use a pinhole camera model. In this model all objects are in perfect focus regardless of distance. In many ways this is advantageous, blurring due to lack of focus is often unwanted in images. However, simulating depth of field can lead to more realistic looking images because it more accurately models true optical systems.

Distributed ray tracing creates depth of field by placing an artificial lens in front of the view plane. Randomly distributed rays are used once again to simulate the blurring of depth of field. The first ray cast is not modified by the lens. It is assumed that the focal point of the lens is at a fixed distance along this ray. The rest of the rays sent out for the same pixel will be scattered about the surface of the lens. At the point of the lens they will be bent to pass through the focal point. Points in the scene that are close to the focal point of the lens will be in sharp focus. Points closer or further away will be blurred.

## Motion Blur

Animation in computer graphics is produced by generating a sequence of still images and then playing them back in order. This is yet another sampling process, but it is temporal rather than spatial. In movie cameras, each frame represents an average of the scene during the time that the camera shutter is open. If objects in the scene are in motion relative to the camera, then they will appear blurred on the film.

Distributed ray tracing can simulate this blurring by distributing rays temporally as well as spatially. Before each ray is cast, objects are translated or rotated to their correct position for that frame. The rays are then averaged afterwards to give the actual value. Objects with the most motion will have the most blurring in the rendered image.

## Conclusions

Distributed ray tracing provides a method of reducing aliasing artifacts in rendered images. This anti-aliasing is done by casting additional rays (oversampling) and then averaging the computed values. When a number of different parameters are being sampled (i.e. spatial and temporal) the rays may be distributed simultaneously through all the attributes rather than distributing each separately.

It was found in the implementation of distributed ray tracing that the number of rays generated can explode exponentially. If N rays are cast initially and then those rays reflect off a glossy surface and each generate N more rays, and each of those hit an object that has to be checked for shadow by casting N more rays, etc. then the computation time of distributed ray tracing can quickly become unmanageable. A mechanism that can cap the number of rays generated without greatly diminishing the quality of the rendered image would be worth studying.

# Examples

The following are examples of some of features that distributed ray tracing provides. Each example provides an image demonstrating a feature with an blow-up of the area of interest. Enlarged versions of each of the images may be obtained by following the link at the beginning of each example. The distributed ray tracing algorithm used is based on [COOK84].

The following images demonstrate the soft shadow capabilities of distributed ray tracing.

Example 1 - This example shows a hard shadow produced by a traditional (non-distributed) ray tracer. Notice the discrete boundary between points that are in shadow and points that are not.

Example 2 - This example shows a technique for generating soft shadows that is not based on distributed ray tracing. This technique is based on uniformly sampling an area light source. Although the penumbra and umbra of the shadow are clearly visible, the variation between them is rigid.

Example 3 - This example shows a soft shadow generated by distributed ray tracing. The light source was sampled using 10 rays.

Example 4 - This example shows a soft shadow generated by distributed ray tracing. The light source was sampled using 20 rays.

Example 5 - This example shows a soft shadow generated by distributed ray tracing. The light source was sampled using 50 rays.

## Glossy Reflections

The following images demonstrate the glossy reflection capabilities of distributed ray tracing.

Example 6 - This example shows a perfect reflection produced by a traditional (non-distributed) ray tracer. Notice that the edges of the reflection are very sharp.

Example 7 - This example shows a glossy reflection generated by distributed ray tracing. The reflection was generated by distributing 10 rays.

Example 8 - This example shows a glossy reflection generated by distributed ray tracing. The reflection was generated by distributing 20 rays.

Example 9 - This example shows a glossy reflection generated by distributed ray tracing. The reflection was generated by distributing 50 rays.

## Fuzzy Translucency

The following images demonstrate the fuzzy translucency capabilities of distributed ray tracing.

Example 10 - This example shows a perfectly translucent surface produced by a traditional (non-distributed) ray tracer. Notice that the edges of the sphere visible through the translucent pane are very sharp.

Example 11 - This example shows a fuzzy translucent surface generated by distributed ray tracing. The surface was generated by distributing 10 rays.

Example 12 - This example shows a fuzzy translucent surface generated by distributed ray tracing. The surface was generated by distributing 20 rays.

## References

[COOK84]
R. L. Cook, T. Porter, and L. Carpenter, "Distributed Ray Tracing", Computer Graphics, vol. 18, no. 3, pp 137-145, 1984.

Allen Martin / amartin@cs.wpi.edu