I'm trying to fix:

bpy.context.scene.world.light_settings.use_environment_light = True
bpy.context.scene.world.light_settings.environment_energy = energy
bpy.context.scene.world.light_settings.environment_color = 'PLAIN'

to make them work in blender 2.8. I read Setting up a Sky: bpy.context.world = None, but my bpy.context.scene.world.node_tree is None. How would I set up a node tree and add the Background node?

It seems like the correct code should be something like bpy.context.scene.world.node_tree.nodes['Background'].inputs['Strength'].default_value = energy, but I can't figure out how to make the node_tree.

Any help would be greatly appreciated!

  • 2
    $\begingroup$ Can you please explain what you actually want to do? Setting up a custom environment using a hdri or just a plain color and up the strength? $\endgroup$ – brockmann Feb 24 '20 at 9:15
  • 1
    $\begingroup$ Once the world is created, just add something like: world.use_nodes = True This will create the node tree. $\endgroup$ – lemon Feb 24 '20 at 9:33
  • $\begingroup$ Related: blender.stackexchange.com/questions/132271/… $\endgroup$ – batFINGER Feb 24 '20 at 11:11
  • $\begingroup$ @brockmann i am trying to convert a neural net script, so i am not really sure what its supposed to do exactly - i just want to convert these lines as close to the original as possible $\endgroup$ – prbodas Feb 25 '20 at 4:18
  • $\begingroup$ @lemon thank you so much! that worked! $\endgroup$ – prbodas Feb 25 '20 at 4:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.