Ejemplo n.º 1
0
def build_scene(scene: bpy.types.Scene, input_bvh_path: str) -> bpy.types.Object:
    loader.build_pbr_textured_nodes_from_name("Concrete07", scale=(0.25, 0.25, 0.25))

    mat = utils.add_material("BlueMetal", use_nodes=True, make_node_tree_empty=True)
    output_node = mat.node_tree.nodes.new(type='ShaderNodeOutputMaterial')
    principled_node = mat.node_tree.nodes.new(type='ShaderNodeBsdfPrincipled')
    principled_node.inputs['Base Color'].default_value = (0.1, 0.2, 0.7, 1.0)
    principled_node.inputs['Metallic'].default_value = 0.9
    principled_node.inputs['Roughness'].default_value = 0.1
    mat.node_tree.links.new(principled_node.outputs['BSDF'], output_node.inputs['Surface'])
    utils.arrange_nodes(mat.node_tree)

    armature = create_armature_from_bvh(bvh_path=input_bvh_path)
    armature_mesh = utils.create_armature_mesh(scene, armature, 'Mesh')
    armature_mesh.data.materials.append(mat)

    current_object = utils.create_plane(size=16.0, name="Floor")
    current_object.data.materials.append(bpy.data.materials["Concrete07"])

    current_object = utils.create_plane(size=16.0, name="Wall")
    current_object.data.materials.append(bpy.data.materials["Concrete07"])
    current_object.location = (0.0, 6.0, 0.0)
    current_object.rotation_euler = (0.5 * math.pi, 0.0, 0.0)

    bpy.ops.object.empty_add(location=(0.0, 0.0, 0.8))
    focus_target = bpy.context.object
    utils.add_copy_location_constraint(copy_to_object=focus_target,
                                       copy_from_object=armature,
                                       use_x=True,
                                       use_y=True,
                                       use_z=False,
                                       bone_name='Hips')

    return focus_target
def build_scene(scene, input_bvh_path):
    mat = bpy.data.materials.new("BlueMetal")
    mat.use_nodes = True
    utils.clean_nodes(mat.node_tree.nodes)
    output_node = mat.node_tree.nodes.new(type='ShaderNodeOutputMaterial')
    principled_node = mat.node_tree.nodes.new(type='ShaderNodeBsdfPrincipled')
    principled_node.inputs['Base Color'].default_value = (0.1, 0.2, 0.7, 1.0)
    principled_node.inputs['Metallic'].default_value = 0.9
    principled_node.inputs['Roughness'].default_value = 0.1
    mat.node_tree.links.new(principled_node.outputs['BSDF'],
                            output_node.inputs['Surface'])
    utils.arrange_nodes(mat.node_tree)

    armature = create_armature_from_bvh(scene, bvh_path=input_bvh_path)
    armature_mesh = utils.create_armature_mesh(scene, armature, 'Mesh')
    armature_mesh.data.materials.append(mat)

    mat = bpy.data.materials.new("Concrete07")
    mat.use_nodes = True
    utils.clean_nodes(mat.node_tree.nodes)
    utils.build_pbr_textured_nodes(
        mat.node_tree,
        color_texture_path=
        "./assets/textures/[2K]Concrete07/Concrete07_col.jpg",
        roughness_texture_path=
        "./assets/textures/[2K]Concrete07/Concrete07_rgh.jpg",
        normal_texture_path=
        "./assets/textures/[2K]Concrete07/Concrete07_nrm.jpg",
        displacement_texture_path=
        "./assets/textures/[2K]Concrete07/Concrete07_disp.jpg",
        ambient_occlusion_texture_path=
        "./assets/textures/[2K]Concrete07/Concrete07_AO.jpg",
        scale=(0.25, 0.25, 0.25))

    bpy.ops.mesh.primitive_plane_add(radius=8.0, calc_uvs=True)
    current_object = bpy.context.object
    current_object.name = "Floor"
    current_object.data.materials.append(mat)

    bpy.ops.mesh.primitive_plane_add(radius=8.0, calc_uvs=True)
    current_object = bpy.context.object
    current_object.name = "Wall"
    current_object.data.materials.append(mat)
    current_object.location = (0.0, 6.0, 0.0)
    current_object.rotation_euler = (0.5 * math.pi, 0.0, 0.0)

    bpy.ops.object.empty_add(location=(0.0, 0.0, 0.8))
    focus_target = bpy.context.object
    utils.add_copy_location_constraint(copy_to_object=focus_target,
                                       copy_from_object=armature,
                                       use_x=True,
                                       use_y=True,
                                       use_z=False,
                                       bone_name='Hips')

    return focus_target
Ejemplo n.º 3
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)