def render_image(): """The method invoked by blender cli that renders the output image """ # Args output_file_path = str(sys.argv[sys.argv.index('--') + 1]) resolution_percentage = int(sys.argv[sys.argv.index('--') + 2]) num_samples = int(sys.argv[sys.argv.index('--') + 3]) color = int(sys.argv[sys.argv.index('--') + 4]) pose_string = sys.argv[sys.argv.index('--') + 5] pose = np.array(json.loads(pose_string)) # Parameters hdri_path = "./assets/HDRIs/green_point_park_2k.hdr" # Scene Building scene = bpy.data.scenes["Scene"] world = scene.world # Reset utils.clean_objects() # Objects focus_target = set_scene_objects(pose) # Camera bpy.ops.object.camera_add(location=(0.0, -8.0, 2.0)) camera_object = bpy.context.object utils.add_track_to_constraint(camera_object, focus_target) utils.set_camera_params(camera_object.data, focus_target, lens=85, fstop=0.5) # Background utils.build_rgb_background(world, rgb=(1.0, 1.0, 1.0, 1.0)) # Render Setting # TODO get as arg res_x, res_y = 1080, 1080 utils.set_output_properties(scene, resolution_percentage, output_file_path, res_x, res_y) utils.set_cycles_renderer(scene, camera_object, num_samples, use_transparent_bg=True)
# Parameters hdri_path = "./assets/HDRIs/green_point_park_2k.hdr" # Scene Building scene = bpy.data.scenes["Scene"] world = scene.world ## Reset utils.clean_objects() ## Suzannes focus_target = set_scene_objects() ## Camera bpy.ops.object.camera_add(location=(0.0, -16.0, 2.0)) camera_object = bpy.context.object utils.add_track_to_constraint(camera_object, focus_target) utils.set_camera_params(camera_object.data, focus_target, lens=85, fstop=0.5) ## Lights utils.build_environment_texture_background(world, hdri_path) ## Composition build_scene_composition(scene) # Render Setting utils.set_output_properties(scene, resolution_percentage, output_file_path) utils.set_cycles_renderer(scene, camera_object, num_samples)
num_samples = int(sys.argv[sys.argv.index('--') + 3]) # Scene Building scene = bpy.data.scenes["Scene"] world = scene.world ## Reset utils.clean_objects() ## Object focus_target_object = set_scene_objects() ## Camera camera_object = utils.create_camera(location=(0.0, -10.0, 2.2)) utils.add_track_to_constraint(camera_object, focus_target_object) utils.set_camera_params(camera_object.data, focus_target_object, lens=180.0, fstop=2.4) ## Background utils.build_rgb_background(world, rgb=(0.0, 0.0, 0.0, 1.0)) ## Composition utils.build_scene_composition(scene, dispersion=0.0) # Render Setting utils.set_output_properties(scene, resolution_percentage, output_file_path) utils.set_cycles_renderer(scene, camera_object, num_samples)
## Reset utils.clean_objects() # Animation Setting utils.set_animation(scene, fps=24, frame_start=1, frame_end=40) # frame_end will be overriden later ## Scene focus_target_object = build_scene(scene, input_bvh_path) ## Camera camera_object = utils.create_camera(location=(0.0, -10.0, 1.0)) utils.add_copy_location_constraint(copy_to_object=camera_object, copy_from_object=focus_target_object, use_x=True, use_y=False, use_z=False) utils.add_track_to_constraint(camera_object, focus_target_object) utils.set_camera_params(camera_object.data, focus_target_object) ## Lights utils.build_environment_texture_background(world, hdri_path) ## Composition utils.build_scene_composition(scene) # Render Setting utils.set_output_properties(scene, resolution_percentage, output_file_path) utils.set_cycles_renderer(scene, camera_object, num_samples, use_motion_blur=True)
# Args output_file_path = str(sys.argv[sys.argv.index('--') + 1]) resolution_percentage = int(sys.argv[sys.argv.index('--') + 2]) num_samples = int(sys.argv[sys.argv.index('--') + 3]) # Scene Building ## Reset utils.clean_objects() ## Suzannes center_suzanne = set_scene_objects() ## Camera camera_object = utils.create_camera(location=(10.0, -7.0, 0.0)) utils.add_track_to_constraint(camera_object, center_suzanne) utils.set_camera_params(camera_object.data, center_suzanne, lens=50.0) ## Lights utils.create_sun_light(rotation=(0.0, math.pi * 0.5, -math.pi * 0.1)) # Render Setting scene = bpy.data.scenes["Scene"] utils.set_cycles_renderer(scene, resolution_percentage, output_file_path, camera_object, num_samples) # Rendering bpy.ops.render.render(animation=False, write_still=True)
# Scene Building scene = bpy.data.scenes["Scene"] world = scene.world ## Reset utils.clean_objects() ## Object focus_target = set_scene_objects() ## Camera bpy.ops.object.camera_add(location=(0.0, -12.0, 0.0)) camera = bpy.context.object utils.add_track_to_constraint(camera, focus_target) utils.set_camera_params(camera, focus_target, lens=72, fstop=128.0) ## Background utils.build_rgb_background(world, rgb=(0.89, 0.93, 1.00, 1.00)) ## Composition def build_scene_composition(scene): scene.use_nodes = True utils.clean_nodes(scene.node_tree.nodes) render_layer_node = scene.node_tree.nodes.new(type="CompositorNodeRLayers") filter_node = scene.node_tree.nodes.new(type="CompositorNodeFilter") filter_node.filter_type = "SHARPEN" filter_node.inputs["Fac"].default_value = 0.1
output_file_path = str(sys.argv[sys.argv.index('--') + 1]) resolution_percentage = int(sys.argv[sys.argv.index('--') + 2]) num_samples = int(sys.argv[sys.argv.index('--') + 3]) # Parameters hdri_path = "./assets/HDRIs/green_point_park_2k.hdr" # Scene Building scene = bpy.data.scenes["Scene"] world = scene.world ## Reset utils.clean_objects() ## Suzannes center_suzanne = set_scene_objects() ## Camera bpy.ops.object.camera_add(location=(5.0, -10.0, 2.0)) camera_object = bpy.context.object utils.add_track_to_constraint(camera_object, center_suzanne) utils.set_camera_params(camera_object.data, center_suzanne, lens=50, fstop=0.2) ## Lights utils.build_environment_texture_background(world, hdri_path) # Render Setting utils.set_output_properties(scene, resolution_percentage, output_file_path) utils.set_cycles_renderer(scene, camera_object, num_samples)
utils.set_animation(scene, fps=24, frame_start=1, frame_end=40) # frame_end will be overriden later ## Scene focus_target = build_scene(scene, input_bvh_path) ## Camera bpy.ops.object.camera_add(location=(0.0, -10.0, 1.0)) camera = bpy.context.object utils.add_copy_location_constraint(copy_to_object=camera, copy_from_object=focus_target, use_x=True, use_y=False, use_z=False) utils.add_track_to_constraint(camera, focus_target) utils.set_camera_params(camera, focus_target) ## Lights utils.build_environment_texture_background(world, hdri_path) ## Composition utils.build_scene_composition(scene) # Render Setting utils.set_cycles_renderer(scene, resolution_percentage, output_file_path, camera, num_samples, use_denoising=True, use_motion_blur=True)
# Args output_file_path = str(sys.argv[sys.argv.index('--') + 1]) resolution_percentage = int(sys.argv[sys.argv.index('--') + 2]) num_samples = int(sys.argv[sys.argv.index('--') + 3]) # Scene Building ## Reset utils.clean_objects() ## Suzannes center_suzanne = set_scene_objects() ## Camera bpy.ops.object.camera_add(location=(10.0, -7.0, 0.0)) camera = bpy.context.object utils.add_track_to_constraint(camera, center_suzanne) utils.set_camera_params(camera, center_suzanne, lens=50) ## Lights utils.create_sun_light(rotation=(0.0, math.pi * 0.5, -math.pi * 0.1)) # Render Setting scene = bpy.data.scenes["Scene"] utils.set_cycles_renderer(scene, resolution_percentage, output_file_path, camera, num_samples) # Rendering bpy.ops.render.render(animation=False, write_still=True)