In this recipe, we'll see several kinds of textures available in Cycles, and learn how to use them with the shaders.
Similar to Blender Internal, we can use both procedural textures and image textures in Cycles. However, the Cycles procedural textures are not exactly the same as in Blender Internal. Some textures are missing because they have been replaced by an improved version (for example, the Clouds procedural texture has been replaced by particular settings of the Noise procedural texture), and a few textures are new and exclusive to Cycles.
We have already seen a simple construction of a basic Cycles material by mixing the diffuse and the glossy (specular) components of a surface. Now let's take a look at the textures we can use in Cycles to further refine a material.
Because Cycles has a node-based system for materials, textures are not added in their slot under a tab as they are in Blender Internal. They get added in the Node Editor window, and are directly connected to the input socket of the shaders or other kinds of nodes. This gives a lot more flexibility to the material creation process because a texture can be used to drive several options inside the material network.
Let's see how they work:
start_01.blend
blend file, where we already set a simple scene with a Cube on a Plane and a basic material, select the Cube and go to the Object modifiers window inside the Properties panel to the right of the UI.4
for both View and Render, and check the Optimal Display item.0.800
, 0.233
, and 0.388
, respectively). Note that only the glossy reflection part on the Spheroid is now purple, whereas the rest of the surface, which is the diffuse component, is still greenish.start_02.blend
. The effect visible in the real-time Rendered preview is as follows:The Rendered preview of the effect of two differently colored Diffuse and Glossy components on the Spheroid
Perform the following steps to add a procedural texture to the object:
The Rendered preview of the effect of a Wave texture assigned as color to the diffuse component of the material
8.500
, Distortion to 12.000
, Detail to a maximum value of 16.000
, and the Detail Scale value to 6.000
.The effect of the Wave Texture assigned as color to the Glossy component of the material
The effect of the Wave Texture assigned as Roughness factor to the Glossy component of the material
0.300
. Here is a screenshot showing the effect of the Wave Texture node as bump:The effect of the Wave Texture Fac output as Bump for both the components of the material
The effect of a Checker Texture used as bump and especially as blending factor to mix the two components of the material
start_03.blend
.From step 1 to 3, the changes are immediately visible in the Rendered viewport. At the moment, the Wave Texture node color output is connected to the color input of the Diffuse BSDF shader node, and the Spheroid looks as if it's painted in a series of black and white bands. Actually, the black and white bands of the texture node override the green color of the diffuse component of the shader, while keeping the material's pink glossy component unaltered.
In step 5, we did exactly the opposite. We disconnected the texture output from the Diffuse shader to connect it to the Glossy shader color input. Now we have the diffuse greenish color back and the pink has been overridden, while the reflection component is visible only inside the white bands of the wave texture.
In step 6, in addition to the color output, every texture node also has a Fac (factor) output socket, outputting gray-scale linear values. When connected to the Roughness input socket of the Glossy shader, the texture output works as a factor for its reflectivity. The Spheroid keeps its colors and gets the specular component only in the white areas on the surface (that is, white bands represent total reflection and black bands represent no reflection).
In step 10, the Checker Texture node's Fac output connected to the Fac input socket of the Mix Shader node works as a mask, or a stencil, based on the black and white values of the output. The numeric slider for the mixing factor on the Mix Shader node has disappeared because now we are using the black and white linear values of the Checker Texture output as a factor to mixing the Diffuse and Glossy components. Therefore, these components appear on the Spheroid surface according to the black and white quads of the checker.
Every texture node has several setting options. All of them have in common the Scale value to set the size of the procedural. The other settings change according to the type of texture.
The Fac output of the texture node can be used to feed the Height input socket of the Bump node (actually, the Color output also works quite well here). Hence, the Normal output of the Bump node can be connected to the Normal input sockets of each shader node, giving a per node bump effect. So, the bump can have an effect only on the diffuse component, or only on the glossy component, or on both, and so on.
Let's create an example of Wave and Voronoi textures:
start_02.blend
file.0.650
and the Voronoi scale to 6.000
.start_02bis.blend
.Two different procedural textures, a Wave and a Voronoi, used as bumps for the two components to have a per shader effect
In this case, we have two different bump types, affecting the diffuse and the glossy components independently, and building an effect of a layered bump.
At this point, you could wonder: "Okay, we just mapped textures on the Spheroid, but what's the projection mode of these mappings?"
Good question! By default, if the projection mode is not specified and if the object doesn't have any UV coordinates, the mapping is Generated, which is the equivalent of the Original Coordinates mode (now renamed Generated as well) in Blender Internal.
But what if you want to specify a mapping method? Then follow these steps:
The Object output of the Texture Coordinate node connected to the Vector input of the Texture node
By the way, I'd like to point your attention to the UV coordinates output. Connect the link to the texture's vector socket, and you will see the mapping on the Spheroid disappear. Why is this so? Because we haven't assigned any UV coordinates to our Spheroid yet.
Go to the UV Maps tab in the Object data window, under the Properties panel on the right, and click on the + sign. This just adds a one-to-one Reset UV projection UV layer to the object, which means that every face of the mesh is covering the whole area of the UV/Image Editor window. Remember that although the Cube looks like a Spheroid now, this is only due to the effect of the assigned Subdivision Surface modifier. The UV coordinates work at the lowest level of subdivision, which is still a six-faced Cube.
A second option is to place the proper seams on the Cube's edges and directly unwrap the object in the UV/Image Editor window, as demonstrated in the following steps:
The Texture Coordinate node is not mandatory to map an image texture on an unwrapped object; in such a case, Cycles will automatically use the (first) available UV coordinates to map the image map anyway.
Often, the only Texture Coordinate node is not enough. What we need now is a way to offset, rotate, and scale this texture on the surface:
The Mapping node pasted between Texture Coordinate and the Texture nodes
45°
, set the X Scale value to 2.000
, and then slide the X Location value, while seeing, in the Rendered viewport, how the texture changes orientation and dimension and actually slide along the x axis.start_04.blend
.The Min and Max buttons on the bottom of the Mapping node are used to clip the extension of the texture mapping. Check both Min and Max to prevent the texture from being repeated n times on the surface, and it will be shown only once. A minimum value of 0.000
and a maximum value of 1.000
give a correspondence of one-to-one to the mapped image. You can tweak these values to limit or extend the clipping. This is useful to map decals, logos, or labels, for example, on an object and avoid repetition.
In Cycles, it is possible to use normal maps by adding the Normal Map node (by navigating to Add | Vector | Normal Map) and connecting its output to the Normal input socket of the shader nodes.
To see an example of a
Normal Map node used in a Cycles material, go to Chapter 8, Creating Organic Materials, of this cookbook and look at the bark_seamless
material of the Creating trees shaders – the bark recipe.
Here is a link to the official documentation talking about the Normal Map node:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/More