Setting image based lighting (IBL)

The image based lighting technique is almost essential in computer graphics nowadays; as the name itself says, it's a technique to light a scene based on the pixel color information of an image, usually an hdr image (High Dynamic Range image); other image formats can also work, although not so well.

In Blender it's possible to obtain IBL both in BI and in Cycles, although with different modalities.

Start Blender and load the previously saved Gidiosaurus_3D_layout.blend file; save it as Gidiosaurus_IBL.blend.

We can divide this recipe into two parts: IBL in Cycles and in Blender Internal.

Let's start with the Cycles Render engine:

  1. First, split the 3D window vertically into two windows, then change the upper one into a Node Editor window. In the toolbar, click on the World icon button to the right side of the Object icon button (selected by default; it's the one enabled for building the objects' shaders). Check the Use Nodes checkbox (or, click on the Use Nodes button inside the Surface subpanel in the World window); a Background node connected to a World Output node will appear in the Node Editor window.
    Image based lighting in Cycles

    Enabling the World nodes in the Node Editor window

  2. Click on the dotted button to the right side of the Color slot in the Surface subpanel under the World window, to call the pop-up menu and select an Environment Texture node, which is automatically added and correctly connected to the Color input socket of the Environment node; then, click on the double arrows to the left side of the Open button (both in the Node Editor or in the World window) and select the L Ice_Lake_Ref.hdr item.
    Image based lighting in Cycles

    Adding an Environment node to the World and loading the hdr image

  3. In the World window or in the Node Editor window, set the Color Space to Non-Color Data.
  4. In order to gain some feedback, start the Rendered preview in the bottom Camera view, then go back to the Node Editor and add a Texture Coordinate node (Shift + A | Input | Texture Coordinate) and a Mapping node (Shift + A | Vector | Mapping).
  5. Connect the Generated output of the Texture Coordinate node to the Vector input socket of the Mapping node and the output of this latter node to the Vector input socket of the Environment Texture node; set the Rotation Z value of the Mapping node to -235.
    Image based lighting in Cycles

    Rotating the hdr image to match the position of the Lamp

  6. Now add a Math node (Shift + A | Converter | Math) and a MixRGB node (Shift + A | Color | MixRGB); connect the Color output of the Environment Texture node to the first Value input socket of the Math node, set the Operation of this latter node to Multiply and the second Value to 10.000.
  7. Connect the output of the Multiply-Math node to the Color1 input socket of the MixRGB node and set the Color2 to pure white; connect the Color output of the MixRGB node to the Strength input socket of the Background node:
    Image based lighting in Cycles

    Adding nodes to the World

  8. Press Shift + D to duplicate both the Math and the MixRGB nodes: paste the duplicated MixRGB node between the first MixRGB and the Background nodes; set the Operation of the duplicated Math node to Add.
  9. Add a Light Path node (Shift + A | Input | Light Path); connect its Is Camera Ray output to the first Value input socket of the duplicated Add-Math node and the Is Glossy Ray output to the second Value input socket; connect the Value output of the Add-Math node to the Fac input socket of the second MixRGB node and enable the Clamp item:
    Image based lighting in Cycles

    The completed IBL World setup for the Cycles render engine

  10. Go to the Settings subpanel and enable the Multiple Importance item, then click on the World datablock to change the name in World_Cycles.
  11. Go to the Render window and in the Film subpanel enable the Transparent item.
    Image based lighting in Cycles

    Renaming the World and some more settings in the main window

  12. Save the file.

In Cycles: at steps 6 and 7 we added nodes to increase the source light intensity of the hdr image; because this also increased the contrast of the image, at steps 8 and 9 we made it less contrasted again but kept the same light intensity, thanks to the Light Path node. The light rays shoot from the Camera position and directly hit a surface (Is Camera Ray) or any glossy surface (Is Glossy Ray) and have value = 1.000, hence corresponding to the Color2 socket of the second MixRGB node, therefore giving a pure white (1.000) value to the Background node's Strength; any other ray (transmitted, shadows, reflected, transparent, and so on) has the high contrast Strength values we established at steps 6 and 7.

We used the Mapping node for the sole reason of matching (visually and thanks to the World Background item enabled in the Display subpanel under the N side Properties panel) the source light direction of the image with the position of the Lamp in the 3D scene: that's why we rotated the hdr image to negative 235 degrees on the z (vertical) axis.

In Blender Internal: we can't rotate the image, so instead we offset it on the x axis to (almost perfectly) match the position it has in Cycles.

The Approximate gathering method is the one developed during the production of the short open movie Big Buck Bunny (https://peach.blender.org/) to have faster rendering and absence of noise in Ambient Occlusion, inevitable with the default Raytrace method (that still remains the more accurate, by the way).

Note that, in both the render engines, we didn't load a brand new Ice_Lake_Ref.hdr image from the textures folder, but we instead used the linked one coming from the materials of the character, as indicated by the L in front of the name and by the name itself and all the settings grayed in the image datablock subpanel.

The free sIBL addon currently, only works with Cycles materials but it can read the .ibl file provided with the free hdr images at the sIBL Archive (link provided further) and therefore, in one click, it can create the complete nodes setup to provide image based lighting in Blender.