From BlenderWiki

Jump to: navigation, search
Note: This is an archived version of the Blender Developer Wiki. The Blender User Manual has moved to a new location.

Introduction

In this tutorial I'll try to show you how to use two different conventional materials and apply them to different parts of the same object. A control-"texture" is used to define where each material shows up.

  • Conventional materials in Blender define how an object looks by laying several (up to 8) image-layers with different functions over each other onto the surface of the object.
  • Node Materials go one step further and use these conventional materials (and some additional functions) to make even more complex (or in quite some cases simpler) materials.

This tutorial is heavily inspired by the following tutorial:

Another link to a thread in the blenderartist forum shows the same technique, but more complex:

Prepare the Scene to use Node Materials

The initial scene with a split window for the Node Editor.

The first thing to do is to split the main window so it has a similar layout as pictured in the image. This means you need one window showing the button area, one with the 3D View and one with the Node editor

Read a more detailed version on how to activate node materials in Manual/Node Materials.

The scene after activation of the Use Nodes toggle.

The next thing is to make sure you have the object selected (RMB Template-RMB.png) that should use the mixed node material in the future.

Now we press the Nodes toggle next to the MA:Material field. The MA: field should now show something like NT:Material instead and the Node Editor window should now be filled with two little widgets (in Blender referred to as Nodes).

I suggest to rename the NT:Material to something like NT:mixed to indicate that this node material will later be a combined material.

Adding a second material to the node-tree.

Currently there should be two nodes in the Node editor. One Material input node and one Output node.

Since we want to mix two materials we now add a second material node by pressing ⇧ ShiftA -> Input -> Material

Create two conventional materials

For this tutorial we will create two very basic materials that get combined later on because it's faster and easier to explain. When you finished this tutorial you could try to replace them with others (maybe from a material library) and see what you can achieve.

Create the first material.

In the first material node is a red button labled Add New. Press it.

The node should now show a plain grey material, as well as the Button area below.

Set the name & color of the a first material.

We now select a color (i'm using red) by clicking on the grey field next to Col.

I also suggest to change the material name by either clicking into the MA: field in the material node or the MA: in the Button area (marked in the image) and entering the new name.

Create the second material.

Select the second material node and repeat the steps from the first one.

Set the name & color of the a second material.

Repeat the steps from the red material, but with another color (I'll use blue here)

Note
When you select one of the material nodes in the node editor (LMB Template-LMB.png or RMB Template-RMB.png) the display in the Buttons area changes as well, always showing the settings of the selected material.


Use the magic of Nodes to mix the Materials

A newly added Mix node.

We can finally start to combine our two created conventional materials via the material mode editor.

For this we add a Mix node by pressing ⇧ ShiftA -> Color -> Mix.

The connected Mix node.

Now we connect the output sockets (Color) of the two materials to the input sockets (Color1 and Color2) of the Mix node and the output socket of the Mix node to the input socket (Color) of the Output node. This is shown with the yellow arrows in The connected Mix node.

To do this just click LMB Template-LMB.png and drag the output sockets (small colored circles) to the input sockets with the mouse.

You should get a result as shown in The connected Mix node.. Now you may ask "Why is it violet? I want it to be part red, part blue." The explanation is simple. We haven't defined the correct factor Fac: for the mix yet.

The Mix node mixes the colors like this:

Fac: 0.0 
The first color is displayed. The second one is basically ignored.
Fac: 0.5 
The 1. and 2. colors are mixed 1:1 for each rendered point. In out case a mix of red and blue produces violet.
Fac: 1.0 
The second color is displayed. The fist one is basically ignored.
Grayscale input linked to Fac: 
A grayscale (value-map) map is used as a factor for the mixing of the input colors. For each point a value is taken from this map (0.0 - 1.0) and produces a result like the 3 cases above, but limited to this point only.
Mix node
Read more about the Mix node here: TODO: link


Adding a Texture input node.

This leads us directly to the next step: Adding a texture map to be used as a grayscale input for the Mix factor.

To do this press ⇧ ShiftA -> Input -> Texture.

Adding a Texture

The next step is unnecessarily complicated (in Blender 2.42a and if I didn't miss anything) since we cannot load a texture from the Nodes Editor window. A texture is loaded by adding it to an existing material and then unlinking it for the texture node to use.

For this we temporarily switch the Buttons Area to the Texture buttons by pressing F6 until the Texture panel appears in the area.

There should be a lot of empty rows there. They all belong to the Material that is currently selected (or which was last selected).

Now press the Add New button in the Texture panel and rename the texture from TE:Tex... to something like TE:mask.

Unlink the Texture from the material.

Important: We now unlink this texture from the material by clicking on the small X next to TE:mask. If you don't do this the texture will later show up in the material itself, and not only as a mask for the node.

Use the created texture in the Texture node.

We now select the created texture in the Texture node by clicking on the small arrow icon (dropdown) and select it by name (in my case mask).

Use the created texture in the Texture node.

We now select the texture node in the node editor. The Buttons area (still in Texture buttons mode) should now display a single dropdown menu labled Texture Type.

Select it and choose Blend from the list. A black-to-white gradient should show up in the preview panel and the Texture node.

Connected Texture node.

As a final step we connect the Color output socket (not Value output socket, image is incorrect) of the Texture node with the Fac: input socket of the Mix node.

Download the .blend file here: Tutorial-Mixing Materials Nodes.blend

Advanced steps

Using different Texture Types

TODO

Using colorbands for the texture

TODO

Changing the mapping of the texture

TODO: My knowledge of the mapping nodes is somewhat lacking. maybe s/b wants to jump in here? text-descriptions would be enough. I'll provide screens if needed.