Using Cycles volume materials

In all the recipes we have seen so far, Cycles used the Surface input socket and (very rarely) the Displacement input socket for the bump effects of the Material Output node to make the renderings. Assigning colors or textures to the surface of an object clearly means that interaction between a ray of light and an object happens only at the surface level of the object, and until this surface doesn't show what should be inside, that's OK. The surface attribute is enough for a realistic rendering.

Things get more complex when there is a need to show what's inside an object, for example, water inside a glass container, smoke and clouds in a thick atmosphere, and so on.

Usually, these are effects that require the use of the volume attribute more than the surface attribute to be effectively rendered.

So, in the first recipes of this chapter, we are going to see the use of the Volume input socket of the Material Output node. Rather than covering a specific material, this recipe is more of a "tour" to show the possibilities related to the Volume shader assigned to a mesh object. Have a look at the following screenshot:

Using Cycles volume materials

A glass Suzanne containing some kind of liquid

Getting ready

Start Blender and open the 9931OS_09_start.blend file, with the usual Suzanne object leaning on a Plane, a mesh-light Emitter, and the Camera.

  1. Go to the Render window, and under the Sampling subpanel, set Samples for Preview to 50 and for Render to 100. Switch Pattern from Sobol to Correlated Multy-Jitter.
  2. Still in the Render window, go to the Volume Sampling subpanel, and under the Heterogeneous item, set the Step Size value to 0.25. The default value is 0.10. Increasing this will make the rendering of volumes less accurate but faster, and lowering it will result in the opposite.

How to do it...

First, let's see the Volume applied to our usual Suzanne mesh primitive by performing the following steps:

  1. Move the mouse to the Camera view and press Shift + Z to switch the Viewport Shading mode to Rendered.
  2. Make sure that you have the Suzanne_unwrapped object selected, and click on the New button in the Node Editor toolbar, or in the Material window under the main Properties panel.
  3. In the Node Editor window, press Ctrl and click and drag a line onto the link connecting the Diffuse BSDF shader to the Material Output node to cut it away. Because nothing is connected to the Material Output node sockets, in the Camera view, the Suzanne object turns pitch black as shown in the following screenshot:
    How to do it...

    The Diffuse shader connected and disconnected from the Material Output node

  4. Select and delete the Diffuse BSDF shader node. Still in the Node Editor window, add a Volume Scatter node (press Shift + A and navigate to Shader | Volume Scatter) and connect its output to the Volume input socket of the Material Output node.
    How to do it...

    Different effects of the Volume Scatter node obtained by changing density and color

  5. Try to increase the Density value to 10.000, either in the node interface in the Node Editor window, or in the slot under the Volume subpanel in the main Properties panel. Suzanne's volume looks more solid, as shown in the middle of the preceding screenshot.
  6. Change the Density value back to the default 1.000 and change the Color values of the Volume Scatter node for R to 1.000, G to 0.000, and B to 0.000 (a red color). The Suzanne object now appears as complementary colored smoke (on the right side of the preceding screenshot) because light is scattered (note that the shadow on the Plane gets the same color).
  7. Add a Glass BSDF shader (press Shift + A and navigate to Shader | Glass BSDF) and connect its output to the Surface input socket of the Material Output node. Set the IOR value to 1.440 and the Roughness value to 0.100.
    How to do it...

    Adding a glassy envelope to the bluish, scattered glassy volume

  8. Now you have to temporarily remove the connection of the Glass BSDF shader node to the Surface input socket of the Material Output node, take back the RGB value and set it to 0.800 for the Color of the Volume Scatter node.
  9. Add a Texture Coordinate node (press Shift + A and navigate to Input | Texture Coordinate), a Voronoi Texture node (press Shift + A and navigate to Texture | Voronoi Texture), and a Math node (press Shift + A and navigate to Converter | Math).
  10. Connect the Object output of the Texture Coordinate node to the Vector input socket of the Voronoi Texture node, and the Fac output of this node to the first Value input socket of the Math node. Set the second Value to 10.000, set Operation to Multiply, and connect its output to the Density input socket of the Volume Scatter node as shown in the following screenshot:
    How to do it...

    The Density value of the Volume Scatter node driven by a Voronoi texture output

  11. Add a ColorRamp node (press Shift + A and go to | Converter | ColorRamp) and paste it between the Voronoi Texture and the Math nodes. Move the black color stop to position 0.195 and the white color stop to position 0.100 as shown in the following screenshot:
    How to do it...

    Enhancing the contrast of the texture output

  12. Set the Voronoi Texture node's Scale value to 11.500, and reconnect the Glass BSDF shader node output to the Surface input socket of the Material Output node. Change the Color values of the Volume Scatter node for R to 1.000, G to 0.000, and B to 0.000 as shown in the following screenshot:
    How to do it...

    The previously cloudy volume covered with a glass surface

  13. Rename the material as Bubbles and save the file by naming it 9931OS_09_volume.blend. Have a look at the following screenshot:
    How to do it...

    The overall network for the combined surface and volume material

    So, for the previous material named Bubbles, we used the Volume Scatter node. What about the Volume Absorption node?

  14. In the Node Editor toolbar, enable fake user for the Bubbles material, and click on the X icon button to delink the datablock. Then click on the New button.
  15. Delete the Diffuse BSDF shader node and add a Volume Absorption node (press Shift + A and navigate to Shader | Volume Absorption). Then connect it to the Volume input socket of the Material Output node.
  16. To make a comparison with the Volume Scatter node, raise the Density value of the Volume Absorption node to 10.000 and set the Color values for R to 1.000, G to 0.000, and B to 0.000. Have a look at the following screenshot:
    How to do it...

    Different effects of the Volume Absorption node

  17. Add a Texture Coordinate node (press Shift + A and navigate to Input | Texture Coordinate), a Voronoi Texture node (press Shift + A and navigate to Texture | Voronoi Texture), two Math nodes (press Shift + A and navigate to Converter | Math), and a Glass BSDF shader (press Shift + A and navigate to Shader | Glass BSDF).
  18. Connect the Object output of the Texture Coordinate node to the Vector input socket of the Voronoi Texture node, and the Fac output of this node to the first Value input socket of the first Math node. Set the second Value to 0.100, set Operation to Less Than, and connect its output to the first Value input socket of the second Math node. Set the second Value to 12.800 and the Operation to Multiply.
  19. Connect the output of this Multiply-Math node to the Density input socket of the Volume Absorption node, and rename the material as algae. Here is a screenshot for your reference:
    How to do it...

    The density of the Volume Absorption node driven by the Voronoi Texture output

  20. Set the Scale value of the Voronoi Texture node to 3.500, change the Color of the Volume Absorption node for R 0.045, G 0.800, and B 0.113, and connect the output of the Glass BSDF shader node to the Surface input socket of the Material Output node. Set the IOR value to 1.440 and the Roughness value to 0.100 as shown in the following screenshot:
    How to do it...

    Different colors and a glass cover for the absorption volumetric material

  21. In the Node Editor toolbar, enable fake user for the algae material, and then click on the 2 icon (Display number of users for this data) to create a duplicate of the material, named algae.001.
  22. Rename the material as emitting_volume and substitute the Volume Absorption node with an Emission node (press Shift + A and go to | Shader | Emission). Connect the output of the Multiply-Math node to the Color input socket, and set the Strength value to 0.050.
  23. Disable the visibility of the sixth scene layer to hide the Emitter mesh-light, and go to the Render window. In the Light Paths subpanel, enable both the Reflective Caustics and Refractive Caustics items. Here is a screenshot for your reference:
    How to do it...

    Substituting the Volume Absorption node with an Emission node as the volume material

  24. Enable fake user for the emitting_volume material and save the file.

How it works...

In this tour recipe, we saw the three shaders used for the volumetric attribute of a material in Cycles, that is, the Volume Scatter, Volume Absorption, and Emission shaders (we have already seen the Emission shader the previous chapters, and it is commonly used in Lamps and mesh-lights).

The Volume Scatter and Absorption shaders do exactly what their names say, as we saw in the examples. If we give them a color other than black, gray, or white, the Volume Scatter shader returns a complementary hue, while the Volume Absorption shader returns the same hue we set up.

About the Density value, remember that the higher the value, the more particles inside the volume. This allows for simulation of very light and rarefied vapors or very dense clouds of smoke, where the material looks almost solid.

There's more...

A Volume can be associated not only with objects but also with the World. This allows for several effects, for example, mist, or the famous God's rays. They are obtained by simply scattering light in the air of a Spot lamp.

The setup is really simple and intuitive: a Volume Scatter node connected to the Volume input socket of the World Output node. Have a look at the following screenshot:

There's more...

The cone of a Spot lamp visible through the ambient volume material

The Density value of the Volume Scatter node in this case is set very low (0.010) to allow the light of the Spot lamp to shine through.

Open the 9931OS_09_volume_ambient.blend file to have a look.

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

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