Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Blender Cycles: Lighting and Rendering Cookbook

You're reading from   Blender Cycles: Lighting and Rendering Cookbook If you're already au fait with Blender, this book gives extra power to your artist's elbow with a fantastic grounding in Cycles. Packed with tips and recipes, it makes light work of the toughest concepts.

Arrow left icon
Product type Paperback
Published in Dec 2013
Publisher Packt
ISBN-13 9781782164609
Length 274 pages
Edition 2nd Edition
Languages
Tools
Concepts
Arrow right icon
Toc

Table of Contents (13) Chapters Close

Preface Introduction FREE CHAPTER 1. Key Holder and Wallet Studio Shot 2. Creating Different Glass Materials in Cycles 3. Creating an Interior Scene 4. Creating an Exterior Scene 5. Creating a Cartoonish Scene 6. Creating a Toy Movie Scene 7. Car Rendering in Cycles 8. Creating a Car Animation 9. Creating an Iceberg Scene 10. Creating Food Materials in Cycles Index

Knowing your ingredients

Using nodes mainly means one thing: mixing different elements such as shaders, images, colors, and values. What makes nodes so powerful is that we can balance the mix of these elements as we like. We can use a simple value, images, colors, or even complex mathematical operations to decide how much of either value we want to see in our final material. The good thing is that we can repeat this process as many times as we want. However, we cannot mix things randomly. Nodes are powerful, but we need to follow a certain logic in order to make them work properly. To better understand the philosophy behind nodes, I have given an example that I hope will help.

Let's think of a node this way: nodes are like food processors. I am talking about blenders, mixers, and machines to make tomato sauce; ovens and stoves to make pasta, and so on. To use a food processor, you put in some ingredients and it does its work. Then, you take what the food processor has produced and use it in a different food processor until you get the final meal ready. Of course, you cannot put tomatoes directly in the oven to make a pizza. You have to first put them in the tomato sauce machine and only when you have the sauce, can you put it on the pizza.

Well, nodes work exactly the same way. Each node is like a different food processor specialized for doing different things. We will put in some information to the left as inputs and the node will give us an output to the right. When we think that our meal is ready, we will put the result of the nodes' work inside the output node and get our final material.

As I am sure you are eager to start, let's jump straight into Blender! Blender Internal is still the default engine in Blender, so we will first need to select Cycles from the render menu. Now open up a node editor in a separate window and with the default cube selected, select the Use Nodes checkbox by clicking on it in the materials menu.

Knowing your ingredients

Here you have them... nodes! What you see there is a diffuse node and an output node. The output node is quite important as it will always be the last node of a material but is also quite self-explanatory. So, now let's focus on the Diffuse BSDF node for a moment. As you can see, we have some small colorful circles on the left-hand side (inputs) and some on the right-hand side (outputs). You may also notice that these inputs and outputs have different colors. Just as with the food example, we can't just plug any node anywhere. We need to adhere to certain rules. Colors will help us distinguish between the various ingredients in order to mix them in the correct way. Here we have the following types of inputs:

  • Color (the yellow circle)
  • Roughness (the grey circle)
  • Normal (the blue circle)

On the right-hand side, we have the output values. In this case, there's only one: a shader (the green circle). We are using the Diffuse BSDF node as an example, but each node has a different combination of inputs and outputs. In Cycles, you will find only these four aforementioned kinds of nodes.

As a general rule, we should always connect nodes by following their colors. Green with green, yellow with yellow, and so on. We will see, however, that it is possible to convert some of these values from where it comes from in order to use them inside an input of a different kind.

Knowing your ingredients

Now let's see what kind of ingredients we can find inside each color group:

  • The yellow circle: Here, we have the color information. This means RGB inputs (plain color) or images from files (textures). Cycles' procedural textures can also generate color information.
  • The gray circle: These are numeric values. However, black and white images can also be used as numeric values, black being 0 and white being 1. The same thing is true for alpha values. Keep in mind that in many situations 1 will be the maximum and 0 the minimum value. This means that, for example, if we want to mix two shaders, the mixing factor will lie in the range of 0 to 1. At these extremes, only one of the two shaders will actually be visible. Of course, numbers inbetween are endless.
  • The blue circle: Under this group, we can find vector information. Vectors mainly are information about the position and orientation of points and surfaces in space. So, for instance, we can use this vector info for normal maps or bump maps in order to tell Cycles what the surface of a certain object must look like.
  • The green circle: This is the shader group and contains the information about how surfaces react to light.

As we will see in our recipes, these groups are not completely separate from each other, but there are many ways to convert the information in order to use them for our needs.

Now, let's have a look at the concept of the sequence that a material node tree should usually follow. In the rest of this chapter, we have to picture a node setup. Let's analyze it to better understand what's going on.

We always start from the left-hand side. The first node you see in the following screenshot is a Texture Coordinate node, and it is needed to tell Cycles what kind of texture coordinates we want to use for the textures of the material we are creating. This node belongs to the input nodes group. These kinds of nodes (inputs), as the name says, are used to generate some kind of input (values, colors, and so on); so, they only have output sockets. They are used to provide information about the object on which we want to apply the material we are creating.

Proceeding to the right, we can see that there is a Wave Texture node. This is a procedural texture built in into Cycles. It receives the information about the vector from the Texture Coordinate node. Looking at the node, we can see that there are several empty sockets on the left-hand side. We can change the values manually, but each of these sockets can also receive information from other nodes just as we are doing for the Vector socket.

From the right-hand side of the node, you can see that we are plugging the Wave Texture node's Color output into the Color input of a diffuse shader and a Bump node. The Bump node will convert the color information of the Color output of the Wave Texture node into vector information, which is used to give a bump effect to the surface of our object.

Moving further to the right, we find two shaders. As we saw earlier, the Diffuse BSDF node takes the Color input from Wave Texture, while the glossy shader has a plain white color. Note that more input sockets are left empty so that we can manually change the values instead of using other nodes as input information.

These two shaders are then mixed using a Mix Shader node with a factor of 0.2. This means that the output of this mix node will take 80 percent of the information from the upper input socket (in this case, the diffuse) and 20 percent from the lower one (the glossy).

Lastly, the result is plugged into a Material Output node. As said before, this is always the last node of a material.

Looking at the node setup, we can see that each output has the same color as the input into which it is plugged, with the exception of the Bump node. This node takes the values from the color information (the node automatically converts any color information into a black and white format) and converts it into vector information.

This simple material setup is helpful in understanding a correct sequence of nodes:

Knowing your ingredients
You have been reading a chapter from
Blender Cycles: Lighting and Rendering Cookbook - Second Edition
Published in: Dec 2013
Publisher: Packt
ISBN-13: 9781782164609
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime