Nodes: Remove "Use Nodes" in Shader Editor for World

Part of https://projects.blender.org/blender/blender/pulls/141278

Blend files compatibility:
If a World exists and "Use Nodes" is disabled, we add new nodes to the
existing node tree (or create one if it doesn't) that emulates the
behavior of a world without a node tree. This ensures backward and
forward compatibility.

Python API compatibility:
- `world.use_nodes` was removed from Python API => **Breaking change**
- `world.color` is still being used by Workbench, so it stays there,
although it has no effect anymore when using Cycles or EEVEE.

Python API changes:
Creating a World using `bpy.data.worlds.new()` now creates a World with
 an empty (embedded) node tree. This was necessary to enable Python
scripts to add nodes without having to create a node tree (which is
currently not possible, because World node trees are embedded).

Pull Request: https://projects.blender.org/blender/blender/pulls/142342
This commit is contained in:
Habib Gahbiche
2025-07-28 14:06:08 +02:00
parent 272178d001
commit 445eceb02a
23 changed files with 184 additions and 192 deletions

View File

@@ -16,7 +16,7 @@ class WORLD_OT_convert_volume_to_mesh(bpy.types.Operator):
@classmethod
def poll(cls, context):
world = cls._world_get(context)
if not world or not world.use_nodes:
if not world:
return False
ntree = world.node_tree

View File

@@ -120,25 +120,21 @@ class EEVEE_WORLD_PT_surface(WorldButtonsPanel, Panel):
world = context.world
layout.prop(world, "use_nodes", icon='NODETREE')
layout.separator()
layout.use_property_split = True
if world.use_nodes:
ntree = world.node_tree
node = ntree.get_output_node('EEVEE')
ntree = world.node_tree
node = ntree.get_output_node('EEVEE')
if node:
input = find_node_input(node, "Surface")
if input:
layout.template_node_view(ntree, node, input)
else:
layout.label(text="Incompatible output node")
if node:
input = find_node_input(node, "Surface")
if input:
layout.template_node_view(ntree, node, input)
else:
layout.label(text="No output node")
layout.label(text="Incompatible output node")
else:
layout.prop(world, "color")
layout.label(text="No output node")
class EEVEE_WORLD_PT_volume(WorldButtonsPanel, Panel):
@@ -151,7 +147,7 @@ class EEVEE_WORLD_PT_volume(WorldButtonsPanel, Panel):
def poll(cls, context):
engine = context.engine
world = context.world
return world and world.use_nodes and (engine in cls.COMPAT_ENGINES)
return world and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout

View File

@@ -99,7 +99,8 @@ class NODE_HT_header(Header):
if snode_id:
row = layout.row()
row.prop(snode_id, "use_nodes")
if snode.shader_type != 'WORLD':
row.prop(snode_id, "use_nodes")
if world and world.use_eevee_finite_volume:
row.operator("world.convert_volume_to_mesh", emboss=False, icon='WORLD', text="Convert Volume")