Click or drag to resize
DigitalRuneEnvironment Map Reflections
Caution note Caution

The EnvironmentLightSample is outdated. Image-based lighting (IBL) is now an integrated part of DigitalRune Graphics. See IBL examples for more information.

The EnvironmentLightSample (see Samples) shows how to implement a new light type which adds environment map reflections to all materials in the scene. This article provides additional background information and explanations.

This topic contains the following sections:

Screenshot

Here are some screenshots from the new EnvironmentLightSample. Several objects show reflections. (The reflected environment map is the same as the sky box.)

Environment Light
Screenshot: The spheres, cubes, ground and armor of the dude reflect the environment map.
Traditional approach: Environment mapping using new materials

The usual method to add environment mapping is:

  1. Create a new HLSL effect which implements environment mapping.
  2. Assign this effect to a mesh. In the DigitalRune Engine, you do this by editing the DigitalRune material file (*.drmat) of a model.

This is approach is cumbersome because you need to create many variants of the effect (env map, env map + skinned, env map + normal map + alpha test, ...) and manually assign the effect to meshes.

Deferred lighting allows a more efficient solution because lighting and shading are decoupled.

Deferred lighting approach: Environment mapping using a new light type

Deferred rendering allows us to use a more practical method. The EnvironmentLightSample shows how to implement a new light type and a renderer for the light. The new light type adds environment map reflections to all deferred materials. Even glossy reflections can be created using the mipmaps of the environment map. For this approach you need to understand a few basic observations:

  • Deferred lighting decouples light accumulation and material rendering: In a deferred rendering pipeline we can create new light types without changing material shaders (except forward rendered, alpha-blended materials). To add a custom light type, you only need to write a new Light class and a SceneNodeRenderer which handles LightNodes with the custom Light type.

  • Reflections = indirect specular lighting: An environment map basically captures the light that falls onto an object from all directions. This light does not only affect special, user-selected materials - all materials reflect this light! The specular color of a material defines how much of this light should be reflected and whether the reflected light is tinted.

  • Mipmap levels can be used to create glossy reflections. The specular power (a.k.a. specular exponent, roughness, smoothness, glossiness, shininess, etc.) of a material defines how sharp the reflected image should be. Mirror-like materials have a very high specular power. Dull, diffuse materials have a low specular power. The mipmap levels of the environment map contain increasingly blurred versions of the original image. To create glossy (blurry) reflections, we can sample higher mipmap levels of the environment map. McGuire et al.[1] have recently shown how to compute the required mipmap level for a given specular power.

References