fix normal

This commit is contained in:
hofee
2024-10-19 18:23:34 +08:00
parent 1f8c017a01
commit 7d25777983
11 changed files with 147 additions and 48 deletions

View File

@@ -66,7 +66,7 @@ class BlenderUtils:
@staticmethod
def setup_scene(init_light_and_camera_config, table_model_path, binocular_vision):
bpy.context.scene.render.engine = "BLENDER_EEVEE_NEXT"
bpy.context.scene.render.engine = "BLENDER_EEVEE"
bpy.context.scene.display.shading.show_xray = False
bpy.context.scene.display.shading.use_dof = False
bpy.context.scene.display.render_aa = "OFF"
@@ -198,6 +198,8 @@ class BlenderUtils:
def render_normal_and_depth(
output_dir, file_name, binocular_vision=False, target_object=None
):
# use pass z
bpy.context.scene.view_layers["ViewLayer"].use_pass_z = True
target_cameras = [BlenderUtils.CAMERA_NAME]
if binocular_vision:
target_cameras.append(BlenderUtils.CAMERA_RIGHT_NAME)
@@ -213,9 +215,14 @@ class BlenderUtils:
os.makedirs(mask_dir)
scene.render.filepath = os.path.join(
output_dir, mask_dir, f"{file_name}_{cam_suffix}.png"
)
scene.render.image_settings.color_depth = "8"
output_dir, mask_dir, f"{file_name}_{cam_suffix}.exr"
)
scene.render.image_settings.file_format = "OPEN_EXR"
scene.render.image_settings.color_mode = "RGB"
bpy.context.scene.view_settings.view_transform = "Raw"
scene.render.image_settings.color_depth = "16"
bpy.context.scene.render.filter_size = 1.5
scene.render.resolution_percentage = 100
scene.render.use_overwrite = False
scene.render.use_file_extension = False
@@ -258,8 +265,7 @@ class BlenderUtils:
target_cameras = [BlenderUtils.CAMERA_NAME]
if binocular_vision:
target_cameras.append(BlenderUtils.CAMERA_RIGHT_NAME)
# use pass z
bpy.context.scene.view_layers["ViewLayer"].use_pass_z = True
for cam_name in target_cameras:
bpy.context.scene.camera = BlenderUtils.get_obj(cam_name)
cam_suffix = "L" if cam_name == BlenderUtils.CAMERA_NAME else "R"
@@ -388,4 +394,9 @@ class BlenderUtils:
scene_info["target_name"] = target_name
scene_info_path = os.path.join(scene_root_dir, "scene_info.json")
with open(scene_info_path, "w") as outfile:
json.dump(scene_info, outfile)
json.dump(scene_info, outfile)
@staticmethod
def save_blend(scene_root_dir):
blend_path = os.path.join(scene_root_dir, "scene.blend")
bpy.ops.wm.save_as_mainfile(filepath=blend_path)