ImageBasedLight Class |
Namespace: DigitalRune.Graphics
The ImageBasedLight type exposes the following members.
Name | Description | |
---|---|---|
ImageBasedLight |
Initializes a new instance of the ImageBasedLight class.
| |
ImageBasedLight(TextureCube) |
Initializes a new instance of the ImageBasedLight class.
|
Name | Description | |
---|---|---|
Clone |
Creates a new Light that is a clone (deep copy) of the current instance.
(Inherited from Light.) | |
CloneCore |
Makes the instance a clone (deep copy) of the specified Light.
(Overrides LightCloneCore(Light).) | |
CreateInstanceCore |
When implemented in a derived class, creates a new instance of the
Light derived class.
(Overrides LightCreateInstanceCore.) | |
Equals | (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetIntensity |
Gets the (approximated) light intensity at the given distance.
(Overrides LightGetIntensity(Single).) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
BlendMode |
Gets or sets the blend mode for the diffuse light contribution.
| |
Color |
Gets or sets the RGB color of the light.
| |
DiffuseIntensity |
Gets or sets the diffuse intensity of the light.
| |
EnableLocalizedReflection |
Gets or sets a value indicating whether the cube map reflection is localized.
| |
Encoding |
Gets or sets the color encoding used by the cube map texture.
| |
FalloffRange |
Gets or sets the relative distance over which light effect falls off.
| |
HdrScale |
Gets or sets the HDR scale of the light.
| |
LocalizedReflectionBox |
Gets or sets the axis-aligned bounding box used to localize the cube map reflection when
EnableLocalizedReflection is set.
| |
Name |
Gets or sets the name of the light.
(Inherited from Light.) | |
Shape |
Gets or sets the bounding shape of the light volume.
| |
SpecularIntensity |
Gets or sets the specular intensity of the light.
| |
Texture |
Gets or sets the cube map texture.
|
Image-based lighting (IBL) uses a cube map of the environment to define the lighting in a scene.
The property Texture defines the used environment map. This property must be set to valid cube map- otherwise, the ImageBasedLight is disabled. The texture can be a normal sRGB texture or an RGBM encoded HDR texture; see Encoding. The cube map must contain mipmaps.
When a mesh is shaded, the normal vector is used to look up a color value in the environment map to use for diffuse lighting. Reflection vectors are used to look up color values for specular lighting. This allows a mesh to reflect the environment, like a mirror. The mipmap levels are used to create reflections on materials with different glossiness. Materials with a high SpecularPower, like mirrors, use high resolution mipmap levels. Diffuse lighting and dull materials use low resolution mipmap levels.
ImageBasedLights have a Shape, which can be Infinite or a BoxShape. Lights with an infinite shape cover the whole scene. Usually a level contains only one image-based light with an infinite shape. Lights with a box shape cover only the volume inside the box. This allows to set different image-based lights for different rooms or zones of a level.
A LightNode must be used to add an ImageBasedLight to a scene. The LightNode is also used to define the position and the orientation of the light.The BlendMode determines if the diffuse light contribution of an image-based light is added to the scene (additive blending, BlendMode = 0) or replaces the ambient lighting and other image-based lights (alpha blending, BlendMode = 1). The default is BlendMode = 1, which means that an diffuse light replaces the ambient lighting and other image-based lights.
Note: Image-based lights are usually applied after the ambient light of the scene and before the other lights of the scene. Image-based lights never replace other lights, like directional lights or point lights.
The property FalloffRange can be used to let an image-based light fade out to create smooth blending between different image-based lights or between an image-based light and an area which contains no image-based lights. (Only relevant for box-shaped lights. Infinite lights never fade out.)
Image-based lights have color and intensity, which are used to tint and scale the colors of the environment map. The color of the Texture, the Color, DiffuseIntensity/SpecularIntensity and HdrScale are multiplied to get the final diffuse and specular light intensities which can be used in the lighting equations.
Diffuse only: The SpecularIntensity can be set to NaN to disable the specular light contribution. This creates a pure diffuse light. As mentioned above, the BlendMode determines whether the diffuse light is added to the scene (BlendMode = 0) or replaces the ambient light and other image-based lights (BlendMode = 1).
Specular only: The DiffuseIntensity can be set to NaN to disable the diffuse light contribution. This creates a pure specular light, which can be used for reflections only.
Localized reflections:Usually, environment maps are treated as if the scene in the environment map is infinitely far away. If an image-based light is used to create reflection of a box-shaped room, the reflections will not properly align with the walls of the room. To correct the reflections, EnableLocalizedReflection can be set to . In this case the reflections are computed to fit a given box. This box is either equal to the BoxShape of the light (property Shape) or to an axis-aligned box defined by LocalizedReflectionBox. The box is always aligned with the local space of the LightNode.
Cloning:When the ImageBasedLight is cloned the Encoding and the Texture are not duplicated. These properties are copied by reference.
Usage tips: