A Cycles material is basically made up of distinct components named shaders. They can be combined to build even more complex surface or volume shaders.
In this recipe, we'll have a look at the basic, necessary steps required to build a basic surface Cycles material, to activate the rendered preview in the 3D window, and to finally render a simple scene.
In the description of the following steps, I'll assume that you are using Blender with the default factory settings. If you aren't, start Blender and just click on the File menu item in the top main header bar to select Load Factory Settings from the pop-up menu, as shown in the following screenshot:
Now perform the following steps:
Let's learn more by performing the following steps:
100.000
by default, and start increasing the value. As the intensity of the Lamp increases, you will see the Cube and the Plane rendered in the viewport getting brighter, as shown in the following screenshot:Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
We just prepared the scene and took the first look at one of the more appreciated features of Cycles since its first inclusion in Blender—the real-time-rendered preview (which, by the way, is now also available in Blender Internal but seems to work faster in Cycles).
Now let's start with the object's materials:
0.430
, 0.800
, and 0.499
, respectively.Note that although we just switched a shader node with a different node, the color we set in the former has been kept in the new one. Actually, this happens for all the values that can be kept from a node to a different one.
Now, because a material having a 100 percent matte or reflective surface could hardly exist in the real world, a more accurate basic Cycles material should be made by mixing the Diffuse BSDF and the Glossy BSDF shaders, blended together by a Mix Shader node, which in turn is connected to the Material Output node:
0.500
, the two shader components, Diffuse and Glossy, are now showing on the Cube's surface in equal parts, that is, each component at 50 percent. Click on the Fac slider with the mouse and slide it to 0.000
. The Cube's surface now shows only the Diffuse component because the Diffuse BSDF shader is connected to the first Shader input socket, which is corresponding to a value of 0
.1.000
and the surface now shows only the Glossy BSDF shader component, which is, in fact, connected to the second Shader input socket corresponding to a value of 1
.0.800
(keep Ctrl pressed while you are sliding the Fac value to constrain it to 0.100
intervals). The Cube is now reflecting the white Plane on its sides, even though it is blurred, because we have a material that is reflective at 80 percent and matte at 20 percent (the white noise you see in the rendered preview is due to the low sampling we are using at the moment. You will learn more about this later). This is shown in the following screenshot:In its minimal form, a Cycles material is made by any one of the node shaders connected to the Surface or the Volume input sockets of the Material Output node. For a new material, the node shader is Diffuse BSDF by default, with the RGB color set to 0.800
and connected to the Surface socket, and the result is a matte whitish material (with the Roughness value at 0.000
, actually corresponding to a Lambert shader).
Then the Diffuse BSDF node can be replaced by any other node of the available shader list, for example, by the Glossy BSDF shader as in the former Cube scene, which produced a totally mirrored surface material.
As we have seen, the Node Editor window is not the only way to build the materials. In the Properties panel on the right-hand side of the UI, we have access to the Material window, which is usually divided as follows:
The Material window not only reflects what we do in the Node Editor window and changes accordingly (and vice versa), but can also be used to change the values to easily switch the shaders themselves, and to some extent, to connect them to the other nodes.
The Material and the Node Editor windows are so mutual that there is no prevalence in which window to use to build a material. Both can be used individually or combined, depending on preferences or practical utility. In some cases, it can be very handy to switch a shader from the Surface tab under Material on the right (or a texture from the Texture window as well, but we'll see textures later), leaving all the settings and the links in the node's network untouched.
There is no question, by the way, that the Material window can become pretty complex and confusing as a material network grows more and more in complexity, while the graphic appearance of the Node Editor window shows the same network in a clearer and much more readable way.
Looking at the Rendered viewport, you'll notice that the image is now quite noisy and that there are white dots in certain areas of the image. These are the infamous fireflies, caused mainly by transparent, luminescent, or glossy surfaces. Actually, they have been introduced in the rendering of our Cube by the glossy component.
Here is one way to eliminate the fireflies:
Therefore, a different approach is as follows:
100
for both Preview and Render (they are set to 10
by default).1.00
(they are set to 0.00
by default).1.00
.start_01.blend
.10
by default are obviously not enough to give a noiseless image, but are good for a fast preview. We could also let the Preview samples remain at the default value and increase only the Render value, to have longer rendering times but a clean image only for the final render (which can be started, as in Blender Internal, by pressing the F12 key).Using the Clamp value, we can reduce the energy of the light. Internally, Blender converts the image color space to linear, which is from 0
to 1
, and then reconverts it to RGB, which is from 0
to 255
, for the output. A value of 1.00
in linear space means that all the image values are now included inside a range starting from 0
and arriving to a maximum value of 1
, and that values greater than 1
are not possible, thus avoiding the fireflies problem in most cases. Be aware that Clamp values higher than 1.00
might also lower the general lighting intensity of the scene.
The Filter Glossy value is exactly what the name says, a filter that blurs the glossy reflections on the surface to reduce noise.
Remember that even with the same samples, the Rendered preview does not always have a total correspondence to the final render with regards to both noise and the fireflies. This is mainly due to the fact that the preview-rendered 3D window and the final rendered image usually have very different sizes, and artifacts visible in the final rendered image may not show in a smaller preview-rendered window.
As you have seen, the several nodes that can be used to build Cycles shaders have both input and output sockets to the left and to the right of the node interface, respectively, and the color of these sockets is actually indicative of their purpose; green sockets are for shaders, yellow sockets are for colors, gray sockets for values, and blue sockets for vectors.
Each color output socket of one node should be connected with the same color input socket of another node. By the way, connecting differently colored sockets also works quite often; for example, a yellow color output can be connected to a gray value input socket and to a blue vector input.
A general overview of all the Cycles nodes can be found at http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes.
18.225.92.116