Creating cloth materials with procedurals

In this recipe, we will create a generic cloth material, as shown in the following screenshot:

Creating cloth materials with procedurals

The cloth material as it appears in the final rendering

Getting ready

Before we start creating the material, let's set up the scene by performing the following steps:

  1. Start Blender and load the 9931OS_cloth_start.blend file. In the scene, there is already a cloth simulation.
  2. Click on the Play animation button in the Timeline toolbar (or press Alt + A) to see the simulation running and being cached in real time. It consists of a Plane (our fabric) draped on a UV Sphere leaning on a bigger Plane (the floor).
  3. After the simulation has been totally cached (a total of 100 frames), in the Physics window (the last tab to the right) under the Cloth Cache tab, press the Current Cache to Bake button to save the simulation. The 100-frame simulation is now cached and saved inside a folder (unless differently specified), named as a blend file, and stored on your hard drive in the same directory as the blend file.

From now on, there is no need to perform calculations about the simulation anymore. Blender will read the simulation data from that cache folder, so it will be possible to quickly scroll through the Timeline bar and immediately reach any frame inside the cached range.

Getting ready

The cloth simulation scene with the Cloth Cache subpanel to the right

How to do it...

Now we are going to create the material on the fabric Plane, which has been first unwrapped by assigning a basic UV layer (Object data | UV Maps) and later subdivided by the Specials menu. This is done before the cloth simulation by performing the following steps:

  1. Go to the 100 frame.
  2. Make sure you have the fabric Plane selected. Click on New in the Material window under the main Properties panel or in the Node Editor window. Rename the new material cloth_generic.
  3. In the Material window, switch the Diffuse BSDF node with a Mix Shader node. In the first Shader slot, select a Diffuse BSDF node, and in the second Shader slot, select a Glossy BSDF shader node.
  4. Set the Diffuse BSDF node's Roughness value to 1.000. Set the Glossy BSDF node's Roughness value to 0.500. Change the Glossy BSDF node's Color values of R to 0.800, G to 0.730, and B to 0.369. Set the Fac value of the Mix Shader node to 0.160.
  5. Add one Texture Coordinate node (press Shift + A and navigate to Input | Texture Coordinate) and two Mapping nodes (press Shift + A and navigate to Vector | Mapping). In the Properties panel (press N) of the Node Editor window, label the two Mapping nodes as Mapping1 and Mapping2. Then connect the UV output of the Texture Coordinate node to the Vector input sockets of both the Mapping nodes.
  6. Now add two Wave Texture nodes (press Shift + A and navigate to Texture | Wave Texture) and a Noise Texture node (press Shift + A and navigate to Texture | Noise Texture). Label the first two nodes as Wave Texture1 and Wave Texture2. Connect the output of the Mapping1 node to the Vector input sockets of the Wave Texture1 node and the Noise Texture node. Connect the output of the Mapping2 node to the Vector input of the Wave Texture2 node.
  7. Add three Math nodes (press Shift + A and navigate to Converter | Math), one for each texture node. Set their Operation mode to Multiply and label them as Multiply1, Multiply2 and Multiply3. Then connect the Fac output of the Wave Texture1 node to the first Value input socket of the Multiply1 node, the Wave Texture2 node to the Multiply2 node, and the Noise Texture node to the Multiply3 node. Set the second Value input socket of the Multiply1 and Multiply2 nodes to 1.000, and leave the Multiply3 node as 0.500.
  8. Go to the Mapping2 node and set the Rotation value of Y to 90°. Go to the Wave Texture nodes, and for both of them, set the Scale value to 100.000, Distortion to 2.000, and Detail Scale to 2.000. For the Noise Texture node, set the Scale value to 80.000 and the Distortion value to 5.000.
  9. Add a new Math node (press Shift + A and navigate to Converter | Math) and set Operation to Subtract. Connect the output of the Multiply1 and Multiply2 nodes to the first and the second Value input sockets, respectively.
  10. Press Shift + D to duplicate the last Math node. Set the Operation mode to Add. Connect the output of the Subtract node to its first Value socket and the output of the Multiply3 node to the second Value input socket.
  11. Press Shift + D to duplicate a Multiply node, label it as Multiply4, and connect the output of the Add node to the first Value input socket. Set the second Value input socket to 0.050. Connect the last Multiply node's output to the Displacement input socket of the Material Output node.
  12. Add a Frame (press Shift + A and navigate to Layout | Frame). Press Shift and select the two Mapping nodes, the three textures, all the Math nodes, and then the Frame. Press Ctrl + P to parent them. Label the frame as BUMP, as shown in the following screenshot:
    How to do it...

    The shader and the network for the fabric bump pattern

  13. Add two new Mapping nodes (press Shift + A and navigate to Vector | Mapping). Label them as Mapping3 and Mapping4. Then add two Wave Texture nodes (press Shift + A and navigate to Texture | Wave Texture). Label them as Wave Texture3 and Wave Texture4. As before, connect the UV output of the Texture Coordinate node to both the Mapping3 and Mapping4 nodes, and the output sockets of the latter to the new Wave Texture nodes.
  14. Go to the Mapping3 node. Set the Rotation value of Z to -45° and the Scale value of Y to 2.000. In the Mapping4 node, set the Rotation value of Z to 45° and the Scale value of X to 2.000. Go to the two Wave Texture nodes to set the Scale value to 10.900 and the Detail value to 0.000.
  15. Add two ColorRamp nodes (press Shift + A and navigate to Converter | ColorRamp) and label them as ColorRamp1 and ColorRamp2. Connect the Fac output of the Wave Texture3 to the Fac input socket of the ColorRamp1 node, and the Fac output of the Wave Texture4 node to the Fac input socket of the ColorRamp2 node.
  16. Add a MixRGB node (press Shift + A and navigate to Color | MixRGB). Connect the Color output of the two ColorRamp nodes to the Color1 and Color2 input sockets of the MixRGB node. Set Blend Type to Multiply and the Fac value to 1.000.
  17. Connect the Color output of the Multiply-MixRGB node to the Color input socket of the Diffuse BSDF shader node.
  18. Add a Frame (press Shift + A and navigate to Layout | Frame). Press Shift and select the new nodes and then the Frame. Press Ctrl + P to parent them. Rename the Frame COLOR, as shown in the following screenshot:
    How to do it...

    The COLOR frame

  19. At this point, we can change the colors inside the two ColorRamp gradients to obtain colored patterns. In my example, I set the ColorRamp1 colors ranging from pure white going to a light blue, and violet for the ColorRamp2 node.

How it works...

  • From steps 1 to 3, we just made the basic shader by mixing a rough Diffues BSDF shader (Roughness to 1.000) with a light glossy shader (the low Fac value of the Mix Shader node shows a lot more of the diffuse component than the glossy component)
  • From steps 4 to 10, we built the bump texture of the fabric by mixing two Wave Texture nodes in different orientations and by adding a bit of noise
  • From steps 11 to 18, we built a simple cross-color pattern

There's more...

A lot of variations can be obtained by setting different values for the bump and using different texture nodes and combinations for the color pattern, as shown in the following screenshot:

There's more...

Different color patterns of the cloth material

Tip

All of these examples are included in the 9931OS_06_cloth.blend file provided with this module.

See also

To learn more about Blender cloth simulation, you can take a look at the online Blender documentation at http://wiki.blender.org/index.php/Doc:2.6/Manual/Physics/Cloth.

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

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