Пример #1
0
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)
Пример #2
0
# 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)
## Reset
utils.clean_objects()

## Object
focus_target_object = set_scene_objects()

## Camera
camera_object = utils.create_camera(location=(0.0, -10.0, 0.0))

utils.add_track_to_constraint(camera_object, focus_target_object)
utils.set_camera_params(camera_object.data,
                        focus_target_object,
                        lens=72,
                        fstop=0.5)

## Lights
utils.build_environment_texture_background(world, hdri_path)

# Render Setting
utils.set_cycles_renderer(scene,
                          resolution_percentage,
                          output_file_path,
                          camera_object,
                          num_samples,
                          use_denoising=True,
                          use_transparent_bg=True)

# Render
bpy.ops.render.render(animation=False, write_still=True)
Пример #4
0
## 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)
                         "assets/HDRIs/green_point_park_2k.hdr")

# 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, 0.0))

utils.add_track_to_constraint(camera_object, focus_target_object)
utils.set_camera_params(camera_object.data,
                        focus_target_object,
                        lens=72,
                        fstop=0.5)

## 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,
                          use_transparent_bg=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)
Пример #7
0
    color_correction_node.master_gain = 1.20
    color_correction_node.midtones_gain = 1.20
    color_correction_node.shadows_gain = 1.50

    split_tone_node = utils.create_split_tone_node(scene.node_tree)
    split_tone_node.inputs["ShadowsHue"].default_value = 0.6
    split_tone_node.inputs["ShadowsSaturation"].default_value = 0.1

    composite_node = scene.node_tree.nodes.new(type="CompositorNodeComposite")

    scene.node_tree.links.new(render_layer_node.outputs['Image'],
                              filter_node.inputs['Image'])
    scene.node_tree.links.new(filter_node.outputs['Image'],
                              color_correction_node.inputs['Image'])
    scene.node_tree.links.new(color_correction_node.outputs['Image'],
                              split_tone_node.inputs['Image'])
    scene.node_tree.links.new(split_tone_node.outputs['Image'],
                              composite_node.inputs['Image'])

    utils.arrange_nodes(scene.node_tree)


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_denoising=False)
## Suzannes
focus_target = set_scene_objects()

## Camera
bpy.ops.object.camera_add(view_align=False, location=[0.0, -12.0, 2.0])
camera = bpy.context.object

utils.add_track_to_constraint(camera, focus_target)
set_camera_params(camera, focus_target)

## Lights
utils.build_environmental_light(world, hdri_path)

## Composition
utils.build_scene_composition(scene)

# Animation Setting
utils.set_animation(scene, fps=24, frame_start=1, frame_end=40)

# Render Setting
utils.set_cycles_renderer(scene,
                          resolution_percentage,
                          output_file_path,
                          camera,
                          num_samples,
                          use_denoising=True,
                          use_motion_blur=True)

# Render
bpy.ops.render.render(animation=True)
Пример #9
0
    bpy.ops.object.empty_add(location=(0.0, 0, 0.0))
    focus_target = bpy.context.object
    bpy.ops.object.select_all(action='DESELECT')
    default_camera_object.select_set(True)
    focus_target.select_set(True)
    bpy.ops.object.parent_set()
    focus_target.rotation_mode = 'XYZ'
    focus_target.rotation_euler = (0, 0, 0)
    focus_target.keyframe_insert(data_path='rotation_euler', frame=1)
    focus_target.rotation_euler = (0, 0, math.pi * 2)
    focus_target.keyframe_insert(data_path='rotation_euler', frame=120)

    for k in focus_target.animation_data.action.fcurves.find(
            'rotation_euler', index=2).keyframe_points:
        k.interpolation = 'LINEAR'

    num_samples = 32

    utils.set_animation(default_scene, fps=60, frame_start=1, frame_end=120)

    utils.set_cycles_renderer(default_scene,
                              resolution_percentage,
                              output_file_path,
                              default_camera_object,
                              num_samples,
                              use_denoising=True)

    # Rendering
    bpy.ops.render.render(animation=True, write_still=True)