diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_material.cc b/source/blender/nodes/geometry/nodes/node_geo_set_material.cc index 30510c3570c..0e30522296f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_material.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_material.cc @@ -40,6 +40,12 @@ static void node_declare(NodeDeclarationBuilder &b) static void assign_material_to_faces(Mesh &mesh, const IndexMask selection, Material *material) { + if (selection.size() != mesh.totpoly) { + /* If the entire mesh isn't selected, and there is no material slot yet, add an empty + * slot so that the faces that aren't selected can still refer to the default material. */ + BKE_id_material_eval_ensure_default_slot(&mesh.id); + } + int new_material_index = -1; for (const int i : IndexRange(mesh.totcol)) { Material *other_material = mesh.mat[i];