Environment Maps

The shiny surfaces Blender generates show specular highlights. The ironic thing about these specular shaders is that they are like mirrors that show you things you ordinarily can't see, but none of what you ordinarily can see. What I mean by this is that specular shader's surfaces show you a bright spot as a mirror-like reflection of a lamp. This makes sense, except that if you turn the camera directly toward the lamp, you won't see it! The camera sees this light only if it is being reflected by a specular shader, not directly. On the other hand, objects that appear very bright in your scene (i.e.: they reflect a lot of light to the camera) don't show up in these highlights. This looks especially strange when some of the bright objects should throw more light than some of lamps, but in the specular highlights only the lamps are visible. It is easy enough to make a lamp which is directly visible to the camera by placing some renderable object in the scene which looks like some appropriate sort of lamp fixture, flame, sun, etc. However, wide light sources should appear as wide highlights when reflected, but the shinier the specular shader is, the smaller the specular highlight will be.

In a word, we lack reflections. This is the sort of problem we will address using the technique of environment mapping.

Just as we render what light is reaching the viewing plane using the camera to define a viewpoint, we can render what light is reaching the surface of an object (and hence, what light might ultimately be reflected to the camera). Blender's environment mapping renders a cubic image map of the scene in the six cardinal directions from any point. When the six tiles of the image are mapped onto an object using the Refl input coordinates, they create the visual complexity that the eye expects to see from shiny reflections. It's useful to remember here that the true goal of this technique is believability, not accuracy. The eye doesn't need a physically accurate simulation of the light's travel; it just needs to be lulled into acceptance by seeing the complexity it expects. The most unbelievable thing about most rendered images is the sterility, not the inaccuracy.

The first step for creating an environment map is to define the viewpoint for the map. Add an empty to the scene and place it in the specular position of the camera with respect to the reflecting surface. This is possible, strictly speaking, only for planar reflecting surfaces.

Ideally, the location of the empty would mirror the location of the camera across the plane of the polygon onto which it is being mapped. It would be ridiculously difficult to create a separate environment map for every polygon of a detailed mesh, so we take advantage of the fact that the human eye is very gullible.

In particular, for relatively small and complex objects, we can get away with simply placing the empty near the center. Name the empty env so we can refer to it by name in the environment map settings.

We will handle a reflective sphere over a reflective plane. The set up is depicted in Figure 48.

Figure 48. Environment Map utilization example

Note the 'env' Empty exactly below the camera and at a distance from the reflecting plane equal to 3 blender units, that is the height of the camera over the same plane.

Let's place some lights, leave the sphere without a given material, and move the plane to a different layer. Say that everything is on layer 1 except the plane which is in layer 2.

Give to the plane a low Ref and Spec material and add a texture on channel two with the parameters in Figure 49.

Figure 49. Reflecting plane material.

Note both the Refl mapping and the Cmir effect. We use channel 2 and not 1 because we will need channel 1 later on in the example.

Figure 50. Reflecting plane EnvMap settings.

Now define the newly assigned texture as an EnvMap in the Texture Buttons (F7) Figure 50. Note the Ob: field containing the name of the Empty with respect to which we compute the EnvMap. Note also the resolution of the cube on which the EnvMap will be computed and, most important, the Don't render layer: buttons.

The EnvMap is computed from the Empty location, hence there must be an unobstructed vision from it of the scene. The reflecting plane would completely hide the sphere, hence it is mandatory that the reflecting plane be on a layer of its own and that that layer be marked as 'Not rendable' for the EnvMap calculation.

By hitting F12 the rendering process will start. First 6 different square images comprising the EnvMap will be computed, then the final image, with the sphere being reflected over the plane.

Figure 51. Sphere on a reflecting surface.

To add more visual appeal to the scene, add a big sphere encompassing the whole scene and map a sky image on to it. This will fake a real, cloudy world. Then add a new Empty in the centre of the Sphere and move the Sphere to Layer 3. Give the sphere an EnvMap exactly as you did for the plane (but this time it is layer 3 which must not be rendered!)

Add some cylinders, to make the environment even more interesting, and, before hitting F12 go back to the plane's texture and hit the Free Data button. This will force Blender to recalculate the EnvMap for the new, different, environment.

This time in the rendering process twelve images, 6 for each EnvMap, will be computed. The result is in Figure 52. The sphere is shiner than the plane due to slightly different settings in the materials.

Figure 52. Reflecting sphere on a reflecting surface.

There is a problem! The Sphere reflects the Plane, but the Plane reflects a dull grey Sphere! This is due to the fact that the Plane EnvMap is computed before the sphere EnvMap, hence when it is computed the sphere is still dull grey, while when the Sphere EnvMap is computed the plane already has its Reflection.

NEW in 2.29 You can force recursive computation of EnvMaps to fix this Figure 53.

Figure 53. Reflecting sphere on a reflecting surface with multiple reflections.

Now, if you are still wondering why the first texture channel of the Plane material was kept empty...

Add a new texture to the first channel of the plane material. Make it Glob, affecting the Nor with a 0.25 intensity (Figure 54).

Figure 54. Additional texture set-up for BumpMapping.

This new texture should be of Stucci type, tune the Noise Size down to 0.15 or so.

If you now render the image the plane will look like rippled water (Figure 55).

Figure 55. Reflecting sphere on a reflecting water with multiple reflections.

It is mandatory to have the BumpMap on a channel preceding the EnvMap because textures are applied in sequence, and, the other way around, the reflection would not have been 'broken' by waves.

You can save EnvMaps for later use, and of course load them with the pertinent buttons in the Texture Buttons. You can also build your own envmap. The standard is to place the six images mapped on the cube on two rows of three images each, as in Figure 56.

Figure 56. The EnvMap as it is stored.

Blender allows three types of environment maps, as you can see in Figure 50:

Note that you can animate the water of the previous example by setting an IPO for the ofsX and ofsY values of the texture placement in the Material Buttons.

Rendering the animation will show the ripples of the surface moving, and the reflections changing accordingly!

Please note that the EnvMap of the Plane needs to be computed only once at the beginning if Nothing else moves! Hence it can be static. The Envmap on the sphere is another matter, since it won't reflect the changes in the reflections in the water unless it is computed at every time. Hence it should be of type Anim

If the camera is the only moving object and you have a reflecting plane, the Empty must move too and you must use Anim EnvMaps. If the object is small and the Empty is in its centre then the EnvMap can be Static, even if the object itself rotates! If, on the other hand, it translates the Empty should follow and the EnvMap be of Anim type.

Other settings are: