Soft Shadows

Soft shadows were added by allowing area lights to be defined in the input. The particular command available in our ray tracer is applicable to creating square lights.

area center_x center_y center_z corner_x corner_y corner_z norm_x norm_y norm_z color_r color_g color_b

The above command takes 12 scalars as arguments, which represent four 3-vectors. The first vector defines the location in world space of the center of the area light, while second defines the location in world space of one of the four corners of the square area light. With the third vector representing the normal of the area light, the geometry of the square in world space is fully constrained. The color is associated with the light, just as with point lights.

With this available, it is possible to calculate visibility as a floating-point value rather than a boolean. In the general ray-tracing algorithm, interaction with a surface is followed by iteration over the scene’s lights. In this step, one shadow ray is spawned to check the visibility of point or directional lights. For area light, however, a parametrizable number of shadow rays are spawned. The “destination” of each shadow ray is a random point on the area light; this Monte Carlo sampling prevents aliasing in soft shadows. The number of shadow rays spawned is set for the entire image using the following command:

softshadowrays n

Where n is the desired number. The fraction of shadow rays not intersecting any geometry along the way to the light is then the visibility and is used as a weight on the light color, along with the attenuation. This distributed ray tracing method considerably lengthened computation time.

No soft shadows, no AA

No soft shadows, no AA

This image has a single large area light, which results in a large penumbra.

Soft shadows (256 sample rays) and no AA

Soft shadows (256 sample rays) and no AA

Soft shadows (256 sample rays) and 4x uniform AA

Soft shadows (256 sample rays) and 4x uniform AA