import bpy import os import re def main(): bpy.context.scene.cycles.samples = 1024 bpy.context.scene.cycles.use_denoising = True bpy.context.scene.cycles.sample_clamp_direct = 5 bpy.context.scene.cycles.sample_clamp_indirect = 5 bpy.context.scene.cycles.caustics_reflective = False bpy.context.scene.cycles.caustics_refractive = False bpy.context.scene.render.resolution_x = 1920 bpy.context.scene.render.resolution_y = 1080 bpy.context.scene.render.resolution_percentage = 50 bpy.context.scene.render.pixel_aspect_x = 1 bpy.context.scene.render.pixel_aspect_y = 1 bpy.context.scene.render.fps = 25 bpy.context.scene.render.fps_base = 1 bpy.context.scene.render.image_settings.file_format = 'OPEN_EXR_MULTILAYER' bpy.context.scene.render.image_settings.color_mode = 'RGBA' bpy.context.scene.view_layers["ViewLayer"].use_pass_cryptomatte_object = True bpy.context.scene.view_layers["ViewLayer"].use_pass_cryptomatte_material = True bpy.context.scene.view_layers["ViewLayer"].use_pass_cryptomatte_asset = True C = bpy.context scn = C.scene # Get the environment node tree of the current scene node_tree = scn.world.node_tree tree_nodes = node_tree.nodes # Clear all nodes tree_nodes.clear() # Add Background node node_background = tree_nodes.new(type='ShaderNodeBackground') # Add Environment Texture node #node_environment = tree_nodes.new('ShaderNodeTexEnvironment') # Load and assign the image to the node property #node_environment.image = bpy.data.images.load("/mnt/drive_a/spritefright/pro/lib/renderpreset/kloofendal_48d_partly_cloudy_4k.exr") # Relative path #node_environment.location = -300,0 # Add Output node node_output = tree_nodes.new(type='ShaderNodeOutputWorld') node_output.location = 200,0 # Link all nodes links = node_tree.links #link = links.new(node_environment.outputs["Color"], node_background.inputs["Color"]) link = links.new(node_background.outputs["Background"], node_output.inputs["Surface"]) main()