|
|
|
|
@ -86,8 +86,9 @@ def rander_image_and_check(args):
@@ -86,8 +86,9 @@ def rander_image_and_check(args):
|
|
|
|
|
"""渲染图片""" |
|
|
|
|
# 列出obj列表 |
|
|
|
|
pid = args.pid |
|
|
|
|
pid_file_dir = os.path.join(args.input,pid) |
|
|
|
|
pid_file_dir = os.path.join(args.input) |
|
|
|
|
if not os.path.exists(pid_file_dir): |
|
|
|
|
print(f"{pid_file_dir} 文件夹不存在") |
|
|
|
|
return |
|
|
|
|
obj_file_list = [aa for aa in os.listdir(pid_file_dir) if aa.endswith(".obj")] |
|
|
|
|
if len(obj_file_list)==0: |
|
|
|
|
@ -103,6 +104,7 @@ def rander_image_and_check(args):
@@ -103,6 +104,7 @@ def rander_image_and_check(args):
|
|
|
|
|
is_rander = False |
|
|
|
|
# 根据obj表渲染图片 |
|
|
|
|
for obj_file in sorted_obj_file_list: |
|
|
|
|
print(f"开始执行blender渲染--{obj_file}") |
|
|
|
|
start = time.time() |
|
|
|
|
# 初始化blender环境 |
|
|
|
|
bpy.ops.wm.read_homefile() |
|
|
|
|
@ -124,10 +126,10 @@ def rander_image_and_check(args):
@@ -124,10 +126,10 @@ def rander_image_and_check(args):
|
|
|
|
|
start_import = time.time() |
|
|
|
|
print("===============", os.path.join(args.input, pid, obj_file)) |
|
|
|
|
with stdout_redirected(to=os.devnull): |
|
|
|
|
bpy.ops.import_scene.obj(filepath=os.path.join(args.input, pid, obj_file)) |
|
|
|
|
bpy.ops.import_scene.obj(filepath=os.path.join(args.input,obj_file)) |
|
|
|
|
print( |
|
|
|
|
f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())}: import pid: {pid} done in {time.time() - start_import:.2f}s') |
|
|
|
|
texture_path = os.path.join(args.input, pid, texture_file) |
|
|
|
|
texture_path = os.path.join(args.input,texture_file) |
|
|
|
|
materials = bpy.data.materials |
|
|
|
|
for material in materials: |
|
|
|
|
# 确保材质使用节点树 |
|
|
|
|
@ -221,10 +223,8 @@ def rander_image_and_check(args):
@@ -221,10 +223,8 @@ def rander_image_and_check(args):
|
|
|
|
|
os.makedirs(os.path.join(args.output, args.len_type, |
|
|
|
|
f'{pid}_{args.resolution_x}x{args.resolution_y}_{args.ps_column}', camera_id), |
|
|
|
|
exist_ok=True) |
|
|
|
|
png_name = f"{pid}_{column + 1}.png" |
|
|
|
|
png_out_path = os.path.join(args.output, args.len_type, |
|
|
|
|
f'{pid}_{args.resolution_x}x{args.resolution_y}_{args.ps_column}', |
|
|
|
|
camera_id, png_name) |
|
|
|
|
png_name = f"{pid}_pic.png" |
|
|
|
|
png_out_path = os.path.join(args.output,png_name) |
|
|
|
|
bpy.context.scene.render.filepath = png_out_path |
|
|
|
|
bpy.context.scene.render.image_settings.file_format = 'PNG' |
|
|
|
|
|
|
|
|
|
@ -258,7 +258,7 @@ def get_args():
@@ -258,7 +258,7 @@ def get_args():
|
|
|
|
|
argparser.add_argument('-r_x', '--resolution_x', type=int, default='768', help='render resolution_x') |
|
|
|
|
argparser.add_argument('-r_y', '--resolution_y', type=int, default='1024', help='render resolution_y') |
|
|
|
|
argparser.add_argument('-s', '--sample', type=int, default='512', help='render sample') |
|
|
|
|
argparser.add_argument('-e', '--Env_Texture_path', type=str, default='./hdrs/studio_small_08_2k.exr', |
|
|
|
|
argparser.add_argument('-e', '--Env_Texture_path', type=str, default='D://make2/tools/pic_for_obj/hdrs/studio_small_08_2k.exr', |
|
|
|
|
help='enviroment texture path') |
|
|
|
|
args = argparser.parse_args() |
|
|
|
|
|
|
|
|
|
@ -285,6 +285,7 @@ def rander_image_run(args):
@@ -285,6 +285,7 @@ def rander_image_run(args):
|
|
|
|
|
if not os.path.exists(args.output): |
|
|
|
|
os.makedirs(args.output) |
|
|
|
|
try: |
|
|
|
|
print("进入渲染") |
|
|
|
|
rander_image_and_check(args) |
|
|
|
|
except : |
|
|
|
|
print("图片渲染错误",args.pid) |
|
|
|
|
|