Skip to main content
added options
Source Link
Dale Cieslak
  • 2.8k
  • 16
  • 16

Try this:

import bpy

sky_texture = bpy.context.scene.world.node_tree.nodes.new("ShaderNodeTexSky")
bg = bpy.context.scene.world.node_tree.nodes["Background"]
bpy.context.scene.world.node_tree.links.new(bg.inputs["Color"], sky_texture.outputs["Color"])

You can then tweak the options like this:

sky_texture.sky_type = 'HOSEK_WILKIE' # or 'PREETHAM'
sky_texture.turbidity = 2.0
sky_texture.ground_albedo = 0.4
sky_texture.sun_direction = mathutils.Vector((1.0, 0.0, 1.0))  # add `import mathutils` at the beginning of the script 

Try this:

import bpy

sky_texture = bpy.context.scene.world.node_tree.nodes.new("ShaderNodeTexSky")
bg = bpy.context.scene.world.node_tree.nodes["Background"]
bpy.context.scene.world.node_tree.links.new(bg.inputs["Color"], sky_texture.outputs["Color"])

Try this:

import bpy

sky_texture = bpy.context.scene.world.node_tree.nodes.new("ShaderNodeTexSky")
bg = bpy.context.scene.world.node_tree.nodes["Background"]
bpy.context.scene.world.node_tree.links.new(bg.inputs["Color"], sky_texture.outputs["Color"])

You can then tweak the options like this:

sky_texture.sky_type = 'HOSEK_WILKIE' # or 'PREETHAM'
sky_texture.turbidity = 2.0
sky_texture.ground_albedo = 0.4
sky_texture.sun_direction = mathutils.Vector((1.0, 0.0, 1.0))  # add `import mathutils` at the beginning of the script 
Source Link
Dale Cieslak
  • 2.8k
  • 16
  • 16

Try this:

import bpy

sky_texture = bpy.context.scene.world.node_tree.nodes.new("ShaderNodeTexSky")
bg = bpy.context.scene.world.node_tree.nodes["Background"]
bpy.context.scene.world.node_tree.links.new(bg.inputs["Color"], sky_texture.outputs["Color"])