Sub topic 1
Creating and Assigning Materials
A material in Blender is a data block that describes how a surface looks when rendered. This chapter covers how materials relate to objects, how material slots work, and how to open a material in the Shader Editor. Later chapters build on this to explain the nodes inside.
Prerequisites
This chapter assumes you can:
- Navigate the 3D Viewport and select objects.
- Switch editors and workspaces, and find the Properties editor.
- Add a mesh object (for example a cube or a UV sphere) to a scene.
You do not need to know shader nodes yet. The optional Python section at the end assumes you can run a script from the Scripting workspace.
What a material is
A material is a named data block, like a mesh or an image. It stores a node tree (a graph of shader nodes) plus a few settings, such as viewport display color. A material does nothing until an object uses it.
Two facts shape everything else in this chapter:
- Materials are separate from objects. One material can be used by many objects, and editing it changes all of them.
- Materials are usually linked to the object's mesh data, not to the object itself. Two objects that share a mesh also share its materials.
Material slots
An object does not hold a material directly. It holds a list of material slots. Each slot points to one material. Each face of a mesh stores a slot index, which tells Blender which slot's material to use for that face.
This lets one mesh carry several materials. A chair might use slot 0 for wood and slot 1 for metal, with each face assigned to one of them.
A slot can be empty. Faces that point to an empty slot render with Blender's default gray surface.
Creating and assigning a material in the interface
- Select a mesh object in the 3D Viewport.
- Open the Material Properties tab in the Properties editor. It shows a sphere icon.
- Click New.
Blender does several things in this one click:
- It adds a slot to the object, if none exists.
- It creates a material named
Material(orMaterial.001if that name is taken). - It turns on nodes and adds a Principled BSDF node connected to a Material Output node.
The Properties editor now shows the material's Surface panel. The Principled BSDF inputs appear there as a list. You can edit them without opening the node editor.
Managing slots
The slot list at the top of the Material tab has these controls:
- + adds an empty slot.
- − removes the selected slot.
- The browse button (a sphere icon with a drop-down arrow) lists existing materials so you can reuse one.
- The number next to the material name shows how many users the material has. Click the shield icon to set a fake user, which keeps an unused material in the file when you save.
In Edit Mode, the slot list gains Assign, Select and Deselect buttons:
- Select the faces you want to change.
- Click the target slot in the list.
- Click Assign.
Select selects all faces that use the active slot. This is the quickest way to check which faces use which material.
Object link versus Data link
Each slot has a Link setting with two values:
| Link value | Where the material is stored | Effect |
|---|---|---|
| Data | On the mesh data block | Every object using that mesh shows the same material (default) |
| Object | On the object | This object can use a different material even if the mesh is shared |
Use Object when you have linked duplicates (created with Alt+D) and want each copy to have its own look. Switching the link type does not delete the other value. A slot can hold one material on the data and a different one on the object, and the Link setting decides which is shown.
Using the Shader Editor
The Properties editor is fine for small changes. To build node graphs, use the Shader Editor.
- Switch to the Shading workspace, which includes a Shader Editor, a viewport in Material Preview mode, and a file browser.
- Or change any editor to Shader Editor from its editor-type menu.
The Shader Editor shows the active material of the active object. Its header has these controls:
- Object / World toggle: shows the material of the selected object or the scene's world shader.
- Slot drop-down: picks which slot of the object you are editing.
- Material name field: shows the material, its user count and the fake user button.
Check the Slot drop-down first when the editor looks wrong. A common confusion is editing slot 0 while the faces you are looking at use slot 1.
Duplicating, sharing and naming
- Sharing: pick an existing material from the browse list. Both objects now use one data block, and the user count rises.
- Duplicating: click the duplicate icon next to the name. Blender creates a copy such as
Material.001. Edits to the copy do not change the original. - Single user: if a number appears beside the name, clicking it makes a unique copy for this object.
- Naming: double-click the name to rename. Use descriptive names (
Brushed_Steel, notMaterial.004). Names matter when you append materials from other files or script them.
Materials with zero users are removed when you save and reopen the file, unless they have a fake user.
Viewport display versus render
Each material also has a Viewport Display panel with Color, Metallic and Roughness values. These affect only Solid mode in the viewport and do not change renders. Setting them helps you tell objects apart while modeling. They are separate from the node values.
Creating a material with Python
The same steps can be scripted. This example is the one from the Python chapter, shown here to connect the interface actions to the data model. It creates a material, sets three Principled BSDF inputs, and appends it to the active mesh's material list, which creates a new slot.
import bpy
# Create a new material that uses nodes
mat = bpy.data.materials.new(name="RedPlastic")
mat.use_nodes = True
# A new node-based material comes with a Principled BSDF
bsdf = mat.node_tree.nodes.get("Principled BSDF")
bsdf.inputs["Base Color"].default_value = (0.8, 0.05, 0.05, 1.0)
bsdf.inputs["Metallic"].default_value = 0.0
bsdf.inputs["Roughness"].default_value = 0.35
# Assign the material to the active object
obj = bpy.context.active_object
if obj is not None and obj.type == 'MESH':
obj.data.materials.append(mat)The line obj.data.materials.append(mat) works on the mesh data, so it matches the Data link setting. Calling bpy.data.materials.new alone creates a material with zero users. Without a slot or a fake user, it disappears when the file is saved and reopened.
Common errors
- Material changes appear on other objects. The material is shared. Click the user count to make a single-user copy.
- The Shader Editor is empty. The object has no material, or no object is active. Click New.
- The new material has no nodes. The material has Use Nodes off. Turn it on in the Surface panel (older files, or materials made by script in older versions of Blender).
- Only part of the object changes. The faces use different slots. In Edit Mode, use Select on each slot to see the split.
- A deleted material comes back or vanishes. Materials are removed only when no user remains and the file is saved and reloaded. Check the Outliner's Blender File view for orphan data.
Exercise
You duplicate a cube with Alt+D, so both cubes share one mesh. You give the first cube a red material, and the second cube turns red too. How do you give the second cube a blue material without changing the first, and without making a new mesh?
Show answer
Select the second cube, open the Material tab, and change the slot's Link setting from Data to Object. Then assign a new blue material to that slot. The Object link stores the material on the second object only, so the shared mesh data, and the first cube, keep the red material.
Exercise
A mesh has two slots. Slot 0 holds "Wood" and slot 1 is empty. Some faces render gray. What is the cause, and how do you fix it in Edit Mode?
Show answer
The gray faces use slot 1, which has no material. In Edit Mode, select slot 1 and click Select to see those faces. Then either assign a material to slot 1, or select the faces, click slot 0 and click Assign.