fbe University of New South Wales Sydney Australia UNSW
Faculty of the Built Environment search

4 - Light Sources

4.1 Light Source Types
4.2 Shadows


The lighting in a scene is determined by the number, type, and nature of the light sources defined in the input file. Available light sources range from simple directional sources to more realistic but computationally costly quadrilateral area light sources. Typically, you will want to use point or directional light sources while developing images. When final renderings are made, these simple light sources may be replaced by the more complex ones.

No matter what kind of light source you use, you will need to specify its intensity. In this chapter, an Intensity is either a red-green-blue triple indicating the color of the light source, or a single value that is interpreted as the intensity of a "white" light. In the current version of rayshade, the intensity of a light does not decrease as one moves farther from it.

If you do not define a light source, rayshade will create a directional light source of intensity 1.0 defined by the vector (1., -1., 1.). This default light source is designed to work well when default viewing parameters and surface values are being used.

You may define any number of light sources, but keep in mind that it will require more time to render images that include many light sources. It should also be noted that the light sources themselves will not appear in the image, even if they are placed in frame.


4.1 Light Source Types

The amount of ambient light present in a scene is controlled by a pseudo light source of type ambient.

light Intensity ambient
Define the amount of ambient light present in the entire scene. There is only one ambient light source; its default intensity is 1, 1, 1. If more than one ambient light source is defined, only the last instance is used. A surface's ambient color is multiplied by the intensity of the ambient source to give the total ambient light reflected from the surface.

Directional sources are described by a direction alone, and are useful for modeling light sources that are effectively infinitely far away from the objects they illuminate.

light Intensity directional direction»
Define a light source with the given intensity that is defined to be in the given direction from every point it illuminates. The direction need not be normalized.

Point sources are defined as a single point in space. They produce shadows with sharp edges and are a good replacement for extended and other computationally expensive light sources.

light Intensity point pos»
Place a point light source with the given intensity at the given position.

Spotlights are useful for creating dramatic localized lighting effects. They are defined by their position, the direction in which they are pointing, and the width of the beam of light they produce.

light Intensity spot pos» to» a [Øin Øout]
Place a spotlight at pos, oriented as to be pointing at to». The intensity of the light falls off as (cosine Ø)a, where Ø is the angle between the spotlight's main axis and the vector from the spotlight to the point being illuminated. Øin and Øout may be used to control the radius of the cone of light produced by the spotlight.

Øin is the angle at which the light source begins to be attenuated. At Øout, the spotlight intensity is zero. This affords control over how "fuzzy" the edges of the spotlight are. If neither angle is given, they both are effectively set to 180 degrees.

Extended sources are meant to model spherical light sources. Unlike point sources, extended sources actually possess a radius, and as such are capable or producing shadows with fuzzy edges (penumbrae). If you do not specifically desire penumbrae in your image, use a point source instead.

light Intensity extended radius pos»
Create an extended light source at the given position and with the given radius. The shadows cast by extended sources are modeled by taking samples of the source at different locations on its surface. When the source is partially hidden from a given point in space, that point is in partial shadow with respect to the extended source, and the sampling process is usually able to determine this fact.

Quadrilateral light sources are computationally more expensive than extended light sources, but are more flexible and produce more realistic results. This is due to the fact that an area source is approximated by a number of point sources whose positions are jittered to reduce aliasing. Because each of these point sources has shading calculations performed individually, area sources may be placed relatively close to the objects it illuminates, and a reasonable image will result.

light Intensity area p1» p2» usamp p3» vsamp
Create a quadrilateral area light source. The u axis is defined by the vector from p1» to p2». Along this axis a total of usamp samples will be taken. The v axis of the light source is defined by the vector from p1» to p3». Along this axis a total of vsamp samples will be taken.

The values of usamp and vsamp are usually chosen to be proportional to the lengths of the u and v axes. Choosing a relatively high number of samples will result in a good approximation to a "real" quadrilateral source. However, because complete lighting calculations are performed for each sample, the computational cost is directly proportional to the product of usamp and vsamp.


4.2 Shadows

In order to determine the color of a point on the surface of any object, it is necessary to determine if that point is in shadow with respect to each defined light source. If the point is totally in with respect to a light source, then the light source makes no contribution to the point's final color.

This shadowing determination is made by tracing rays from the point of intersection to each light source. These "shadow feeler" rays can add substantially to the overall rendering time. This is especially true if extended or area light sources are used. If at any point you wish to disable shadow determination on a global scale, there is a command-line option (-n) that allows you to do so. It is also possible to disable the casting of shadows onto given objects through the use of the noshadow keyword in surface descriptions. In addition, the noshadow keyword may be given following the definition of a light source, causing the light source to cast no shadows onto any surface.

Determining if a point is in shadow with respect to a light source is relatively simple if all the objects in a scene are opaque. In this case, one simply traces a ray from the point to the light source. If the ray hits an object before it reaches the light source, then the point is in shadow.

Shadow determination becomes more complicated if there are one or more objects with non-zero transparency between the point and the light source. Transparent objects may not completely block the light from a source, but merely attenuate it. In such cases, it is necessary to compute the amount of attenuation at each intersection and to continue the shadow ray until it either reaches the light source or until the light is completely attenuated.

By default, rayshade computes shadow attenuation by assuming that the index of refraction of the transparent object is the same as that of the medium through which the ray is travelling. To disable partial shadowing due to transparent objects, the shadowtransp keyword should be given somewhere in the input file.

shadowtransp
The intensity of light striking a point is not affected by intervening transparent objects. If you enclose an object behind a transparent surface, and you wish the inner object to be illuminated, you must not use the shadowtransp keyword or the -o option.


Go to the next section Object Definition
Go to the Contents