Python: Create default node tree for new materials and worlds

The motivation is to keep backward compatibility after deprecating
 `material.use_nodes()` and `world.use_nodes`. For example the
following script would behave the same way in 4.5 and 5.0:
```python
mat = bpy.data.materials.new("My new mat")
mat.use_nodes = True
```

Pull Request: https://projects.blender.org/blender/blender/pulls/147052
This commit is contained in:
Habib Gahbiche
2025-10-01 15:05:16 +02:00
parent 3f6ef965b9
commit fb7818e55e
15 changed files with 22 additions and 19 deletions

View File

@@ -934,6 +934,7 @@ def render_output(scene, bounds, filepath):
scene.render.filepath = filepath
world = bpy.data.worlds.new(name_gen)
world.node_tree.nodes.clear()
output = world.node_tree.nodes.new("ShaderNodeOutputWorld")
background = world.node_tree.nodes.new("ShaderNodeBackground")
world.node_tree.links.new(output.outputs["Surface"], background.outputs["Surface"])