Sub topic 1
Creating and Assigning Materials
Prerequisites
You should know basic Blender navigation, how to select objects, and how to switch editors. You should also be comfortable opening the Properties editor. This chapter assumes you can add a mesh object such as a cube to the scene.
Creating and assigning materials
A material is a set of instructions that tells Blender how a surface looks. You create one in the Material Properties tab for the selected object. Each object can hold several material slots, and each slot points to one material. Assigned materials show up in the viewport once you switch the viewport to Material Preview or Rendered mode.
Shader nodes, sockets and the Material Output
Blender builds materials from shader nodes. A node is a box that performs one job. A socket is a connection point on a node. Lines between sockets pass values and colors from one node to the next. The Shader Editor shows this network.
Every material ends at a Material Output node. This node receives the final surface result and sends it to the renderer. If the Material Output has no input connected, the object renders as default gray or black.
What a BSDF is
A BSDF (Bidirectional Scattering Distribution Function) is a mathematical description of how light interacts with a surface. It defines how much light is reflected, absorbed, or transmitted, and in which directions. You do not need the equations. You only need to know that a BSDF node is the component that determines what the surface looks like.
A tour of the Principled BSDF
The Principled BSDF is a single node that combines the most common surface properties. Its main inputs include:
- Base Color: the main color of the surface.
- Metallic: how much the surface behaves like metal.
- Roughness: how blurry or sharp the reflections look.
- IOR: the index of refraction, which controls how light bends through transparent materials.
New materials created with use_nodes include a Principled BSDF connected to the Material Output.
Base Color
Base Color sets the color that the surface shows under white light. You can set it with the color picker in the Properties editor or by connecting a node to the socket. The following script creates a red plastic material and assigns it to the active object.
import bpy
mat = bpy.data.materials.new(name="RedPlastic")
mat.use_nodes = True
bsdf = mat.node_tree.nodes.get("Principled BSDF")
bsdf.inputs["Base Color"].default_value = (0.8, 0.05, 0.05, 1.0)
obj = bpy.context.active_object
if obj is not None and obj.type == 'MESH':
obj.data.materials.append(mat)Exercise
In the script above, what changes if you set the Base Color to (0.05, 0.3, 0.8, 1.0)?
Show answer
The material becomes a blue plastic. The first three numbers are red, green and blue, and the fourth number is alpha, which stays at 1.0 for an opaque surface.