Lights |
This topic contains the following sections:
DigitalRune Graphics supports the following types of light sources (which are derived from the base class Light):
The light types define the properties of a light source, but not its position or direction. Lights are positioned within a scene by creating a LightNode.
// Add an ambient light. var ambientLight = new AmbientLight { Color = new Vector3F(0.9f, 0.9f, 1f), Intensity = 0.15f }; var ambientLightNode = new LightNode(ambientLight) { Name = "Ambient" }; scene.Children.Add(ambientLightNode); // Add a directional light. var sunLight = new DirectionalLight { Color = new Vector3F(1, 0.9607844f, 0.9078432f), DiffuseIntensity = 0.4f, SpecularIntensity = 0.4f }; var sunLightNode = new LightNode(sunLight) { Name = "Sun", PoseWorld = new Pose(QuaternionF.CreateRotation(Vector3F.Forward, new Vector3F(-0.5265408f, -0.5735765f, -0.6275069f))), Shadow = new CascadedShadow() }; scene.Children.Add(sunLightNode);
Lights have a shape (see property Shape). The shape defines the space that is lit by the light source. The shape depends on the type of light. For example, a point light has a SphereShape where the radius of the sphere matches the range of the light. Some light types, such as the ambient light, can have a custom (user-defined) shape. The shape is used as a bounding shape for culling and other internal optimizations. It is not used to clip the light: If the bounding shape of a mesh touches the bounding shape of the light, then the whole mesh is lit - not only the overlapping parts!
The Clip property of a LightNode can be used to define a clip volume. A clip geometry is an IGeometricObject (e.g. a GeometricObject or another SceneNode) which defines the volume that can be lit by this light. Objects outside the clip geometry are not lit. This property can be used, for example, to avoid that a light inside a room illuminates objects in the neighbor room, without using shadow mapping.
Color and Intensity of a light are separate properties, so the values can be adjusted independently. HdrScale is an additional factor. This factors is applied to color and intensity when high dynamic range (HDR) lighting is enabled.
If the scene is going to be presented with a LDR renderer and a HDR renderer, it is recommended to first adjust Color and Intensity for LDR output - leave HdrScale at 1. Then the HDR scale can be adjusted for HDR output.