Community › Forum › ArtWork › Work in Progress › studi e curiosità › Rispondi a: studi e curiosità 27 Febbraio 2024 alle 19:05 #883983 fenixPartecipante @fenix64 ( import bpy import os # Clear existing scene objects bpy.ops.object.select_all(action=’DESELECT’) bpy.ops.object.select_by_type(type=’MESH’) bpy.ops.object.delete() # Add HDRi environment lighting bpy.context.scene.world.use_nodes = True # Clear existing world nodes except for the output node world_nodes = bpy.context.scene.world.node_tree.nodes for node in world_nodes: if node.type != ‘OUTPUT_WORLD’: world_nodes.remove(node) # Add Background node bg_node = world_nodes.new(‘ShaderNodeBackground’) bg_node.location = -200, 0 bg_node.inputs[1].default_value = 1.0 # Strength # Set the path to your HDRi image hdri_path = “/Users/Shared/Lightpack01_360HDR/image.hdr” # Check if the file exists if os.path.exists(hdri_path): env_tex = bpy.data.images.load(hdri_path) tex_environment = bpy.context.scene.world.node_tree.nodes.new(‘ShaderNodeTexEnvironment’) tex_environment.location = -400, 0 tex_environment.image = env_tex bpy.context.scene.world.node_tree.links.new(tex_environment.outputs[0], bg_node.inputs[0]) else: print(“Error: HDRi image file not found!”) # Add UV Sphere bpy.ops.mesh.primitive_uv_sphere_add(radius=1, location=(0, 0, 0)) # Get the newly added sphere object sphere = bpy.context.active_object # Increase the number of subdivisions for a smoother sphere subdivision_levels = 3 # Change this value to adjust the level of subdivisions # Add Subdivision Surface modifier subsurf_modifier = sphere.modifiers.new(name=”Subdivision”, type=’SUBSURF’) subsurf_modifier.levels = subdivision_levels # Create a new material gold_material = bpy.data.materials.new(name=”Gold Material”) gold_material.use_nodes = True nodes = gold_material.node_tree.nodes principled = nodes.get(“Principled BSDF”) principled.inputs[‘Base Color’].default_value = (1, 0.843, 0, 1) # RGB values for gold color principled.inputs[‘Metallic’].default_value = 1.0 # Set metallic value to 1 # Assign the material to the sphere if sphere.data.materials: # Assign to 1st material slot sphere.data.materials[0] = gold_material else: # No slots, append new material sphere.data.materials.append(gold_material) # Add output node output_node = world_nodes.new(‘ShaderNodeOutputWorld’) output_node.location = 400, 0 # Connect background node to output node bpy.context.scene.world.node_tree.links.new(bg_node.outputs[0], output_node.inputs[0]) ) questo è il codice che fa questo Effettuare il login per mettere i like