Is there a way for a panel slider to control both an object’s material node and a world node at the same time?
I currently have the slider controlling the mix factor of a material that is assigned to a background plane and would like it to also control the mix factor of the world environment textures.
obj = bpy.data.objects["Sky_Sunset"]
mat = obj.active_material
if not mat:
layout.label("Create a material")
return
nodes = mat.node_tree.nodes
# Define the specific node
sky_colour = nodes["SkyMix"]
layout.prop(sky_colour.inputs["Fac"], "default_value", text="Sky Colour")
I have tried a different direction in that I selected the Mix Node for the World and added a driver to the slider, I then selected the target to be the slider of the Mix Node on the Material, however on re-opening of the Blend file the connection breaks.
Below is my hatchet job at understanding the code but obviously it doesn’t work and I wouldn’t know if I am a million miles away from getting it right.
#Vehicle Scene Sky setup
obj = bpy.data.objects["Sky_Sunset"]
world = bpy.types.NodeTree["Van World"]
mat = obj.active_material
if not mat:
layout.label("Create a material")
return
worldmat = world.active_world
nodes = mat.node_tree.nodes
nodes2 = worldmat.node_tree.nodes
# Define the specific node
sky_colour = nodes["SkyMix"]
sky_colour_world = nodes2["WorldSkyMix"]
layout.prop(sky_colour.inputs["Fac"], skycolour_world.inputs["Fac"], "default_value", text="Sky Colour (Sunset 0 - Blue Sky 1)")
Any help would be greatly appreciated.
Tom