diff --git a/bindings/blender_init.py b/bindings/blender_init.py index cc809bc1..3d138ac9 100644 --- a/bindings/blender_init.py +++ b/bindings/blender_init.py @@ -402,8 +402,8 @@ def partial_update(self, depsgraph): # Kind of annoying that seemingly every update has 'type', except if it's an # update in the Scene datablock. I'm sure there is a good reason for this though. if not hasattr(update.id, 'type'): - if update.id.id_type == 'MATERIAL': - update_matname = update.id.name + if update.id.id_type == 'WORLD': + self.cr_scene.set_background(convert_background(update.id.node_tree)) else: match update.id.type: case 'MESH': diff --git a/bindings/blender_ui.py b/bindings/blender_ui.py index 00584045..c23f757f 100644 --- a/bindings/blender_ui.py +++ b/bindings/blender_ui.py @@ -1,5 +1,6 @@ import bpy from bpy.types import Panel +from bpy_extras.node_utils import find_node_input # Most of this is just a carbon-copy of the Cycles UI boilerplate @@ -198,6 +199,34 @@ def draw(self, context): sub.active = dof.focus_object is None sub.prop(dof, "focus_distance", text="Distance") +def panel_node_draw(layout, id_data, output_type, input_name): + ntree = id_data.node_tree + node = ntree.get_output_node('CYCLES') + if node: + input = find_node_input(node, input_name) + if input: + layout.template_node_view(ntree, node, input) + else: + layout.label(text="Incompatible output node") + else: + layout.label(text="No output node") + return True + +class C_RAY_WORLD_PT_surface(CrayButtonsPanel, Panel): + bl_label = "Surface" + bl_context = "world" + + @classmethod + def poll(cls, context): + return context.world and CrayButtonsPanel.poll(context) + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + world = context.world + if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'): + layout.prop(world, "color") + class C_RAY_CAMERA_PT_dof_aperture(CrayButtonsPanel, Panel): bl_label = "Aperture" bl_parent_id = "C_RAY_CAMERA_PT_dof" @@ -245,6 +274,7 @@ def get_panels(): C_RAY_MATERIAL_PT_preview, C_RAY_CAMERA_PT_dof, C_RAY_CAMERA_PT_dof_aperture, + C_RAY_WORLD_PT_surface, ) def register():