Setting the World material

In this recipe, we'll see the properties and the settings of the World in Cycles.

The main characteristic of the Cycles World is that it can emit light, so it practically behaves as a light source. Actually, its effect is the famous Global Illumination effect.

As in Blender Internal, the World is considered as a virtual dome at a large distance from the camera, never touching the scene's objects. Nothing in the 3D scene can affect the World. Actually, only the World can emit light on the scene and the objects.

Getting ready

  1. Open the start_04.blend file and go to the World window under the Properties panel to the right of the screen. This is where we see the usual Use Nodes button under the Surface tab.
  2. Although no node system for the World window is set by default, the World window already has a dark, medium gray color slightly lighting the scene. Delete the default Lamp or put it in a different and disabled layer to see that the Spheroid in the scene is dark but still visible in the rendered 3D viewport.
  3. It's already possible to change this gray color to some other color by clicking on the Color button right under Use Nodes (the color at the horizon). This brings up the same color wheel that we saw for the shader colors. Set the color to R 0.179, G 0.152, and B 0.047, and save the file as start_05.blend.

Note that both the intensity and the general color graduation of the World are driven by this color. To have more light, just move the Value slider (the vertical slider) to a whiter hue. To give a general color mood to the scene, pick a color from inside the wheel. This will affect all of the scene's illumination but will show the effect mainly in the shadows, as shown in the following screenshot:

Getting ready

To the right is the color wheel to set the World's color, inside the World window, under the main Properties panel

How to do it...

However, to get access to all the options for the World, we have to initialize it as a node system, which is shown in the following steps:

  1. Look at the bottom header of the Node Editor window. On the left-hand side of the material data block, there are two little icons: a little cube and a little world. The cube icon is used to create materials, while the world icon is for the World. At the moment, because we were working on the Spheroid material, the cube icon is the one selected.
  2. Click on the little world icon. The material's node disappears, and the Node Editor window is empty now because we entered the World mode. Check the little Use Nodes box on the right of the data block to make a default world material appear. Alternatively, go to the World window under the Properties panel and click on the Use Nodes button under the Surface tab. This is shown in the following screenshot:
    How to do it...

    The World button to be switched in the Node Editor toolbar

Just like the materials, the default material for the World is simply made up of two nodes. A Background node is connected to a World Output node. In the Background node, there are two setting options: the Color box and the Strength slider. Both of them are quite self-explanatory. Now, perform the following steps:

  1. Go to the World window under the Properties panel, and click on the little square with a dot to the right side of the Color slot.
  2. From the resulting menu, select the Sky Texture node item. This replicates a physical sky model with two Sky types, an atmospheric Turbidity value slider, a Ground Albedo value slider, and a Strength slider, as shown in this screenshot:
    How to do it...

    The Sky Texture node with options connected as Color to the Background node

Note that you can also modify the incoming direction of the light, that is, the location of the sun, by rotating the sphere icon inside the node interface. This control isn't that much precise, by the way, and will hopefully improve in the future. The next steps are as follows:

  1. Save the file as start_06.blend.
  2. Click on the Color button, which is now labeled Sky Texture, under the Surface tab in the Properties panel, and select the Environment Texture node to replace it, as shown in the following screenshot:
    How to do it...

    The pink warning effect of a missing texture in the Environment Texture node of the World setting

  3. Look in the Rendered view. You'll see that the general lighting has changed to a pink color. This is to show that the World material is now using an image texture to light the scene, but that there is no texture yet.
  4. Click on the Open button in the World window, either under the Properties panel or in the recently added node inside the Node Editor window. Browse to the textures folder and load the Barce_Rooftop_C_3k.hdr image (a free, High-dynamic-range (HDR) image licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License from the sIBL Archive, at http://www.hdrlabs.com/sibl/archive.html).
  5. To appreciate the effect, click on the little eye icon on the side of the Lamp item in the Outliner to disable its lighting. The Spheroid is now exclusively lit by the HDR image assigned to the World material. Actually, you can see the image as a background in the Rendered preview. You can also rotate the viewport and watch the background texture, pinned to the World coordinates, rotate accordingly in real time.
  6. As for the object's materials, the mapping of any texture you are going to use for the World can be driven by the usual Mapping and Texture Coordinates nodes we have already seen. Generally, for the World materials, only the Generated coordinates output should be used, and actually, the Generated coordinates output is used by default if no mapping method is specified. Add the Mapping and Texture Coordinates nodes and connect them to the Vector input socket of the Environment Texture node, as shown in the following screenshot:
    How to do it...

    The Rendered preview of an HDR image assigned as a background to the World through the Environment Texture node

  7. Save the file as start_07.blend.

Now let's imagine a case in which we want to assign a texture to the World material and use it for the general lighting of the scene, but we don't want it to show in the background of the render. In other words, we are using the HDR image to light the Spheroid and the Plane, but we want the two objects rendered on a uniform blue background; so how do we do it? This is how:

  1. One way is to go to the Render window and check the Transparent option under the Film tab. This will show our Spheroid and Plane rendered in both the 3D viewport and the effective final rendered image on a transparent background, with a premultiplied alpha channel, as shown in the following screenshot:
    How to do it...

    The previous World setting rendered with a transparent background

  2. Now we can compose the rendered image with a blue background, both in external image editing software (such as GIMP, to stay inside FOSS) or directly in the Blender compositor.

A different way to render the two objects on a uniform blue background is to use a Light Path node:

  1. If this is the case, deselect the Transparent item checkbox in the Render window to restore the sky background in the preview and in the rendering.
  2. Click on the World Output node in the Node Editor window, press G, and move it to the right.
  3. Add a Mix Shader node (press Shift + A and navigate to Shader |Mix Shader) and move it to the link connecting the Background node to the World Output node, to paste it automatically between the two nodes.
  4. Select the Background node in the Node Editor window. Press Shift + D to duplicate it and move it down.
  5. Connect its output to the second input socket of the Mix Shader node. Click on its Color box to change the color to R 0.023, G 0.083, and B 0.179.
  6. Now, add a Light Path node (press Shift + A and navigate to Input | Light Path).
  7. Connect the Is Camera Ray output of the Light Path node to the Fac input socket of the Mix Shader node, and voilà! The objects in the scene are lit by the HDR image connected to the first Background node, but they appear in a sky that is colored as set in the Color box of the second Background node. This is shown in the following screenshot:
    How to do it...

    The use of the Path Light node as a factor to have a different background than the HDR image still illuminating the scene

  8. Save the file as start_08.blend.

How it works...

To explain this trick better, let's say we just created two different world materials: the first material with the texture and the second material with a plain blue color (this is not literally true; actually, the material is just one, containing the nodes of two ideally different worlds).

We mixed these two materials using the Mix Shader node. The upper green socket of the Mix Shader node is considered equal to a value of 0.000, while the bottom green socket is considered equal to a value of 1.000. As the name suggests, the Light Path node can set the path for the rays of light that are shot from the camera, if you remember. Is Camera Ray means that only the rays directly shot from the camera have a value of 1.000, that is, not the reflected ones, or the transmitted ones, or whatever, which have a value of 0.000.

Thus, because the textured world is connected to a socket equal to the value of 0.000, we don't see it directly as a background, but only see its effect on the objects lit from the reflected light or from the HDR image. The World of the blue sky, which is connected to the input socket of value 1.000 instead, is seen as a background because the light rays shot from the camera directly hit the sky.

There's more...

Just after the Surface subpanel, in the World window, there is the Ambient Occlusion subpanel. Ambient occlusion is a lighting method used to emphasize the shapes or the details of a surface, based on how much a point on that surface is occluded by the nearby surfaces. Ambient occlusion can replace the Global Illumination effect in some cases, though not the same. For example, to render interiors with fast and noise-free results, ambient occlusion is a cheap way to get an effect that looks a bit like indirect lighting.

There is a checkbox to enable Ambient Occlusion, along with the following sliders:

  • Factor: This is used for the strength of the ambient occlusion. A value of 1.00 is equivalent to a white World.
  • Distance: This is the distance from a shading point to the trace rays. A shorter distance emphasizes nearby features, while a longer distance takes into account objects that are further away.

The Ambient Occlusion feature is only applied to the Diffuse BSDF component of a material. The Glossy or Transmission BSDF components are not affected. Instead, the transparency of a surface is taken into account. For example, a half-transparent surface will only half-occlude other surfaces.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.46.76