Blender Cycles:Lighting and Rendering Cookbook
上QQ阅读APP看书,第一时间看更新

Learning environment lighting

Even if we already set up a proper three-point light system, a real studio shot usually has some more elements around the scene that will contribute to the reflections on the object.

Getting ready

To recreate the environment that will contribute to the lighting and the reflections, it won't be necessary to model a whole scene. Instead, we can use an image to fake the environment around the scene and give our objects something to reflect.

How to do it...

To create the environment lighting, we will be following these steps:

  1. Let's go to the World node editor and add the following three nodes:
    • Texture Coordinate
    • Environment Texture (Add | Texture)
    • Mapping (Add | Vector)
  2. The environment texture is the kind of texture that we always have to use for a World BSDF (Bidirectional Scattering Distribution Function). The Mapping node is really useful. It allows us to move, rotate, and scale an image on a surface or, as for this situation, on the environment. Let's plug the Generated output socket of the Texture Coordinate node in the Vector input of the Mapping node and the output of the latter in the Vector input of the Environment Texture node. Finally, as we would do for a normal shader, let's plug the texture in the Color input of the Background node.
  3. Now the sky will have a purple color. That's because we still haven't loaded any image in the Texture node. Let's do it now, and from the browser, load the studio019.hdr file. Here we go! Now the environment will resemble the look of a real photographic studio. You can move around in the scene in the perspective mode, or look through the camera and the picture will move accordingly.
  4. All we have to do now is to set the Z rotation in the Mapping node to -90 degrees in order to place the image accordingly to our scene. Finally, let's set the intensity of the Background node to 0.6.

To see the final effect, remember to activate the layer with the lights and deactivate the Clay material overwrite option from the Render menu.

Here is how the World node setup should looks like:

How to do it...

How it works...

Let's have a brief look at the environment lighting system built in Cycles in a more general way. As for the materials, we have two ways of setting it up. We can use the menu as it works for Blender Internal (BI) or we can use the node editor.

Of course, the node editor will give us more versatility for the creation of the environment. Anyway, before we can use it, there is one thing to do. Let's go to the World menu and on the Surface panel click on the Use Nodes button. Now we are ready to move to the node editor and start playing with the environment.

In the lower header of the node editor, click on the World icon (it is the same icon of the World menu). What you should see is a Background node plugged inside a World Output node. The concept behind the environment is exactly the same as for the Shader node system. Here, things are a bit more straightforward as the only shader node which we have to worry about is the Background one. For the rest, it works exactly in the same way.

To familiarize with the environment lighting, let's switch off the layer with the mesh lights for a moment. Also, to speed up the scene rendering, we will use a clay material for the whole scene. Don't worry, we won't be changing materials one after another. It is enough to go to the Render menu, and from the Layers panel, select the material Clay inside the material space. This is just a gray diffuse material that I included in the file. All the materials we created are still where we left them, but for now every object of the scene will render with the Clay material. To come back to the original situation, it will be enough to erase the material from where we just placed it.

Now, let's activate the real-time viewport. Remember that Cycles have Global Illumination (GI). This means that the environment will always influence the scene. Of course we also have the possibility to deactivate it, but this is an important concept to keep in mind. If we set the color to pure black, as there are no lights, the scene will look pitch black. As we make the color lighter, we will start to see things in our scene. As it is now, which is a plain color, the environment works as a constant source of light which is uniformly distributed around our scene. It will not cast shadows, but we will be able to see the occlusion of the objects. In a moment, we will see that it is possible to make the environment non-uniform, in order to resemble the different kind of places or lighting or whatever we want, without physically having them in the scene.

In the World menu, right below the Surface panel, there is the Ambient Occlusion panel. In Cycles, the ambient occlusion works only in the Add mode. By activating it, you will see that the occluded areas of the scene look much brighter. We can adjust the intensity and the distance at which the AO affects the objects of the scene. For this particular scene, we will not be using the AO, so switch it off for now.

Even below the Settings panel there is the Multiple Importance Sample checkbox. I quote from the Cycles manual:

"By default, lighting from the world is computed solely with indirect light sampling. However for more complex environment maps this can be too noisy, as sampling the BSDF may not easily find the highlights in the environment map image. By enabling this option, the world background will be sampled as a lamp, with lighter parts automatically given more samples."

So, this option will help us reduce the noise when dealing with complex images used as environments. The map resolution will increase the accuracy of the MIS, but also increase the render times and memory used.

There's more...

At the beginning of this chapter, we talked about Bidirectional Scattering Distribution Function (BSDF from now on). We will have a lot to do with this from the next recipe, so it is time to have a better understanding of what it is. Said in a really simple way, it represents a big part of the shaders present in Cycles. As the name suggests, it is the function used by Cycles to distribute the light when a surface is lit. So, when we apply a BSDF to an object, the light will be distributed following the function of the BSDF we used, depending on the one we use. As we will see, there are several BSDFs, such as Diffuse, Glossy, Glass, and others. Each one of these is a different light distribution function, which imitates real-life materials. With each chapter of the book, we will see in depth each BSDF present in Cycles and learn to use it at its best.

It is important to say that there is also a second kind of scattering function called Bidirectional Surface Scattering Reflectance Distribution Function (BSSRDF). This is another kind of function which is used for some particular shader, for example, the subsurface scattering which we will see for the first time in Chapter 3, Creating an Interior Scene.

See also