blender www.blender.nl
this document is online at http://www.blender.nl/showitem.php?id=100
ALT
 EnvMaps Intermediate  Learn how to use environment maps
2000 12 06 
  Predrag Kurtovic  id100 
Introduction
Blender uses environment mapping to make reflecting surfaces. Since there are many questions about "how to make reflections" on the Blender website, I decided to write a small tutorial about reflections. I will describe a way to make reflection on a single and/or more objects. So lets start.

Download:
 intro.blend

Reflection in a plane
The plane is the default object in the Blender scene. Making a Plane reflective is simple. You need: two lights, Plane, Camera and some object above the Plane(text,sphere, ... ). Add materials to all object but not to the Plane. Go to the side view , select the Camera and press the button. You will get x, y and z location for the Camera. The Z location is the most important here - remember it.

Now add an Empty and place it under the Camera. Select the Empty and press . For X and Y coordinate use the same as for Camera. The Z coordinate value must be same as for the Camera but negative. The Plane should be in the middle (z=0).


Next, add a new material to the Plane. Create a texture for it and select ENVMAP as the texture type. In the "Ob" field enter "Empty" (this is the Object name of the empty - you can see it in the header of the Edit Buttons window - ). Set the material's mapping type to 'Refl'.

If you now render the scene you will not get a reflection at all; you will get black floor. Why?

This is simple: Blender calculates the reflection by placing a virtual camera at the Empty's location and the Plane blocks the view of the Empty. To solve the mystery I move the Plane to the second layer. Select the Plane and press , . In the Environment Map settings, use the option "Don't render layer" and press second button (this disables rendering of layer 2). Finally enable both layers by pressing in the 3D window. Now when you render you will get a reflective floor (don't forget to press 'Free Data' first - see below).

Download:
 plane.blend

!
Environment maps can be of the types 'Static' and 'Anim'. The first means that Blender will calculate the environment map only once per animation; this is useful for scenes in which only the camera position changes - it saves a lot of time.

The second one means that the environment maps are recalculated for each frame of your animation.

If you use 'Static' maps and you have changed something in your scene, select 'Free Data' to force Blender to recalculate the environment map the next time you render.


Reflection in a sphere
If only one object (in our case Sphere) in the scene has a mirroring surface our job is very easy. Make a scene and add texture to all objects. Now add our main actor - a Reflective Sphere.

Add a mesh sphere. Go to the Edit Buttons window and press "Set Smooth". This way our sphere will have a smooth surface. Apply a new material to the sphere and use the ENVMAP option in Texture options. In the field "Ob" enter the name of your main object, (in our case "Sphere"; again you can see the object's name in the header of the Edit Buttons window - ). Like above, Blender places a virtual camera at the center of the sphere and uses the resulting image to simulate the reflection.

The button "CubeRes" is used to make reflection sharper by changing the resolution. If value of this button is higher then our reflection will be more sharper but need to more time to render.


Switch back to the Material Buttons window and select "Refl" as the mapping type. Only with this settings reflection will be correct. You must also use buttons "Csp"and "Cmir" to add specularity color information to our reflection. If you don't do this our reflection will be too dark.

Download:
 sphere.blend

Multiple reflections
Using the tutorial above when two or more reflective objects are on the same scene will not give a correct result. By the law of the physic two reflective surfaces have n-1 reflections. Blender (in the present time) cannot calculate n-1 reflections. If you have three reflective spheres you need to render each EnvMap twice. Why?

When the first sphere create its own environment map it take six snapshots of the scene. The environment maps of the other spheres have not been calculated yet, so the first sphere sees the other spheres without mapping. When the second sphere takes its own six snapshots then our first sphere has a "reflective" but not true reflective surface. Only the third sphere has a true reflective surface but with incorrect texures.This is the reason why you must also rerender third sphere's environment map.


Lets start with a clean scene.Press to erase everything and load the default scene. Add one sphere and without moving the cursor add an Empty. Place the cursor somewhere else and repeat this twice. Now you have three spheres on different locations. All spheres have an Empty in their centre. Add Lights and move them together with the Plane, Camera and all other (nonreflective) objects to the fourth layer by selecting all () and pressing and . Add a texture to the Plane.

You can also add some "clouds" by opening the World Buttons window and adding some texture. Be sure to set World to "Real". In other case you will have weird reflections in your objects. On the first three layers you have just spheres. On the fourth layer you have all Emptys (from spheres) and camera light and other objects.


Creating true reflection
Now add a new material to the first Sphere in the Material Buttons window (), and add a texture. Set it to a "Static" EnvMap. In the object button write "Empty". Press first button in "Don`t render layer". Repeat these steps for the second and the third Sphere but change the names of Empties (use the header in the Edit Buttons window to find out the correct name, or press 'Name' in the Edit Buttons window to display the name of the Empty in the 3D window). Press the second button in "Don't render layer" for sphere two, and the third button for sphere three.


Press and rendering starts. Now select first sphere, go to Texture menu and erase EnvMap with FreeData button. Press . Blender render EnvMap from first Sphere.Now select second Sphere and repeat procedure-erase EnvMap for second sphere and render it agian . Erase EnvMapfrom third sphere.For the last time press.Blender calculate third sphere EnvMap.Now all spheres have a true reflective texture.


Animate it!
EnvMaps are nothing more then snapshots of current scene. Because of that you can move the Camera (but only the Camera) on the scene, and all reflections will be correctly rendered. If you move any object, the reflections will not be correct because the EnvMaps are static.

Download:
 reflect.blend

This little animation show the result of animating a scene with a static EnvMap on an object. Remember you can only move the camera not the objects

Download:
 reflec.mpg
Conclusion/final words/....
At the end of the tutorial, I hope that you have clear picture "how to " make reflection in Blender. Of course you can always ask me if you have trouble using mine tutorial. E-mail is pkurtovic@inet.hr . All parts or tutorial have blend files, and you just need to press F12 to see result. What ever to say then - Happy blendering.