The term light sources refers to several different kinds of objects in your scene that emit light, including sky lights, point lights, spot lights, etc.
You can also make a material give off light by setting the color and scale of its emissive channel. This approach is typically best for modeling large, dim light sources. Smaller, more intense lights are better represented using the point, area and spot lights described on this page, to avoid noise in the final rendering.
All light sources share a basic set of properties, including those listed below.
The matrix transform determines the translation, rotation and scaling of the light in the world space of the scene. Different types of light sources interpret these values differently. For instance, point lights emit light equally in all directions, so their orientation does not have any effect. Similarly, directional lights are intended to be so distant from a scene that their translation is not taken into account, only their orientation. Scaling values are used by area lights and window lights to set the rectangular dimensions, and are used by point lights and spot lights to set up the size of a color ramp.
This value is mandatory for all light sources; it is set when you create the light source. You can change it at any time by calling ILBSetLightTransform().
Each light source has an RGB color value, which determines the color of the light rays it emits. This value is mandatory for all light sources; it is set when you create the light source. You can change it at any time by calling ILBSetLightColor().
Each light source also has an intensity value, which scales the amount of light the light source emits. You can change it at any time by calling ILBSetLightIntensity().
All lights can cast shadows. By default, shadow casting is disabled for all lights. You can toggle shadow casting on and off by calling ILBSetCastShadows(). Different types of light sources may also offer additional controls over the way they generate shadows; for details, see Creating Light Sources below.
Each light offers separate scale controls for its direct light and its indirect light. You can use these scales to control the contribution of each type of light relative to each other, or relative to the other light sources in your scene. Both of these scale values are set through a call to ILBSetIntensityScale().
For example, a common use of these scales is to create lightmaps that contain only the indirect light contribution from the light source, while all direct lighting is calculated at runtime instead. This allows the game to combine the benefits of real-time dynamic shadowing with the benefits of baked indirect lighting: color bleeding, high performance, etc.
Some types of lights (including point lights, area lights, spot lights and window lights) cast light rays that get weaker with distance. The relationship between the attenuation of the light and the distance from the source is called the falloff. Beast offers three types of falloff:
falloff = ( 1 / (Constant + Linear * r + Quadratic * r 2 ))
Light stats determine whether or not a light source is taken into account during different types of rendering and lighting calculations. For example, you can specify for each light source whether or not it should be visible in reflections and refractions, etc. The full set of controls are listed in the ILBLightStats enumeration.
To customize the light stats for a light source, call the ILBSetLightStats() function. You provide this function with:
ILBSetLightStats(lightSource, ILB_LS_VISIBLE_FOR_REFLECTIONS | ILB_LS_VISIBLE_FOR_GI, ILB_LSOP_DISABLE);
Beast supports several different types of light sources to model different models of light emission. Each type of light source has its own characteristics and properties that can be controlled using the functions listed in the following sections.
At the time you create the light source, you determine its type. Each type of light source is created by a different API function. You can change the type of the light source at any time after its creation by calling ILBChangeLightType(). The only properties preserved during the change are the transform matrix and color. All other properties of the old light source type are discarded; all properties of the new light source type are set to default values.
A point light, sometimes called an omni light, is a point in 3D space that emits light equally in all directions.
To create a point light, use the ILBCreatePointLight() function.
In addition to the controls described under Creating Light Sources above, you can set the following properties for point lights:
A spot light is a point in 3D space that emits light only within a defined cone.
By default, spot lights are oriented to point in the negative direction of the Y axis; you can control this by setting a rotation in the matrix transform you apply to the light. See also The Beast Coordinate System.
To create a spot light, use the ILBCreateSpotLight() function.
In addition to the controls described under Creating Light Sources above, you can set the following properties for spot lights:
A directional light, or sun light, is a distant light source whose rays light the scene at a constant angle with no falloff.
By default, directional lights are oriented to point in the negative direction of the Y axis; you can control this by setting a rotation in the matrix transform you apply to the light. See also The Beast Coordinate System.
To create a directional light, use the ILBCreateDirectionalLight() function.
In addition to the controls described under Creating Light Sources above, you can set the following properties for directional lights:
Directional lights have no falloff; therefore, their rays do not diminish in brightness as they propagate through space.
An area light is a planar rectangle that emits light from one face.
By default, area lights are oriented to point in the negative direction of the Y axis; you can control this by setting a rotation in the matrix transform you apply to the light. See also The Beast Coordinate System.
To create an area light, use the ILBCreateAreaLight() function. The size of the rectangle is set by the scaling values you set in the transform matrix you provide to this function. By default, it extends from (-1, -1) to (1, 1).
A window light simulates a beam of directional light coming through a rectangular window.
By default, window lights are oriented to point in the negative direction of the Y axis; you can control this by setting a rotation in the matrix transform you apply to the light. See also The Beast Coordinate System.
To create a window light, use the ILBCreateWindowLight() function. The size of the rectangle is set by the scaling values you set in the transform matrix you provide to this function. By default, it extends from (-1, -1) to (1, 1).
In addition to the controls described under Creating Light Sources above, you can set the following properties for window lights:
A sky light is a light source that can surround the entire scene or a defined volume within the scene. It can light the scene with a constant color, or colors derived from a texture.
To create a sky light, use the ILBCreateSkyLight() function.
In addition to the controls described under Creating Light Sources above, you can set the following properties for sky lights:
Sky lights have no falloff; therefore, their rays do not diminish in brightness as they propagate through space.
An ambient light is a light source that applies equally to all surfaces in the scene, regardless of their orientation or occlusion.
To create an ambient light, use the ILBCreateAmbientLight() function.
In addition to the controls described under Creating Light Sources above, you can set the following properties for ambient lights:
Ambient lights have no falloff; therefore, their rays do not diminish in brightness as they propagate through space.
You can only set up a light source in the context of setting up a scene. See also Creating a Scene.
You do not have to close or finalize a light source in order to use it in a rendering pass.
For example, the following code sets up a point light with a yellow color:
ILBLightHandle lh; ILBCreatePointLight(scene, _T("Light"), matrix, ILBColorRGB(3.2f, 3.0f, 0.2f), &lh); // Set a soft shadow ILBSetCastShadows(lh, true); ILBSetShadowRadius(lh, 1.0f); ILBSetShadowSamples(lh, 32); // not needed for physical materials, only for "classic" materials // Set a falloff ILBSetFalloff(lh, ILB_FO_EXPONENT, 2.0f, 20.0f, true);
When you run a live eRnsT session, you can delete a light source from your scene by calling ILBDeleteLightSource().
API functions related to the creation and setup of light sources are declared in the beastlightsource.h file.