Light Function Lab

What's Happening

The goal of this lab is to demonstrate how the Web Driver's light function affects the attenuation (fall-off of intensity over distance) of a WTLight object.

The attenuation of a light is described by the inverse quadratic equation pictured here. In code, you have the freedom to specify the three factors that go into the equation, Constant, Linear, and Quadratic. The intensity of the light decreases over distance (D) using the equation below.

The method WTLight::setRange() allows you to specify at what distance in world units the light intensity will be forced to zero.

In the scene above, you have control over the color of the light and the function constants. Tweak these parameters to your heart's content and then press Refresh to view the light function plots. You also have control of the plot's range and the color of the plot.

The plots shown are broken down into the red, green, and blue components of the light. They show how the intensity of each of these components varies with distance from the light. Drag the flashing bar to see how the values of these components change with distance. (shown at the bottom of the scene in world units). The background of the scene is a representaion of the light's actual color. You may need to adjust the plot range or plot color if you are having a hard time seeing the fall-off.

To get comfortable with the effects that the different values will create, try these steps:
  1. Make the light white by entering Red=255, Green=255, and Blue=255. Enter Constant=1, Linear=.01, and Quadratic=.01. Enter setRange( 50 ), Plot Range 50, and Green for the Plot Color. Click Refresh.
  2. Raise the Linear coefficient to .1 (and Refresh), then to .5 (and Refresh). Notice how an increased Linear value speeds the fall-off of the light. When you're finished, put Linear back to .01 (and Refresh).
  3. Raise the Quadratic coefficient to .1 (and Refresh), then to .5 (and Refresh). Notice that an increased Quadratic value also speeds the fall-off of the light, but more dramatically (steeper) because it is proportional to the distance from the light squared. When you're finished, put Quadratic back to .01 (and Refresh).
  4. Now try setRange( 7 ) and you'll see how this method can be used to completely cut off light at a certain distance. To zoom in, try setting the Plot Range to 10.

Key Methods Used for Light Functions

WTLight::setConstantAttenuation, WTLight::setLinearAttenuation, WTLight::setQuadraticAttenuation, WTLight::getConstantAttenuation, WTLight::getLinearAttenuation, WTLight::getQuadraticAttenuation, WTLight::setRange, WTLight::getRange

Points to Remember