You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As the title suggests, I'm trying to output the roughness and metallic images from a .glb file using BlenderProc, but the results seem incorrect or unexpected. I followed the suggested method from Issue #1131.
Minimal code example
Below is a code snippet I’m using (for metallic/roughness):
importblenderprocasbprocimportargparseimportipdb# blenderproc run examples/datasets/abo/main.py resources\abo-3dmodels\3dmodels\original\8\B07TC2NYX8.glb examples/datasets/abo/output2parser=argparse.ArgumentParser()
parser.add_argument('path', help="Path to the downloaded .blend file")
parser.add_argument('output_dir', nargs='?', default="examples/datasets/abo/output", help="Path to where the final files will be saved")
args=parser.parse_args()
# Initialize BlenderProcbproc.init()
# Load the .glb objectglb_path=args.path# Use the path argument from command lineobjs=bproc.loader.load_obj(glb_path)
# define a light and set its location and energy levellight=bproc.types.Light()
light.set_type("POINT")
light.set_location([5, -5, 5])
light.set_energy(1000)
# Find point of interest, all cam poses should look towards itpoi=bproc.object.compute_poi(bproc.filter.all_with_type(objs, bproc.types.MeshObject))
# Sample three camera posesforiinrange(3):
# Sample random camera location around the objectslocation=bproc.sampler.part_sphere([0, 0, 0], radius=2.5, part_sphere_dir_vector=[1, 0, 0], mode="SURFACE")
# Compute rotation based on vector going from location towards poirotation_matrix=bproc.camera.rotation_from_forward_vec(poi-location)
# Add homog cam pose based on location an rotationcam2world_matrix=bproc.math.build_transformation_mat(location, rotation_matrix)
bproc.camera.add_camera_pose(cam2world_matrix)
# activate normal and depth renderingbproc.renderer.enable_normals_output()
bproc.renderer.enable_depth_output(activate_antialiasing=False)
bproc.renderer.enable_diffuse_color_output() # diffuse color# enable segmentation,roughness,metallic masks (per class and per instance)fromblenderproc.python.types.MeshObjectUtilityimportget_all_mesh_objects, MeshObjectobjects=get_all_mesh_objects()
forobjinobjects:
print("removing invalid normals")
materials=obj.get_materials()
formaterialinmaterials:
material.set_principled_shader_value("Normal", [1,1,1])
principled_bsdf=material.get_the_one_node_with_type("BsdfPrincipled")
print(principled_bsdf)
forkeyin ["Roughness", "Metallic"]:
print(key, principled_bsdf.inputs[key].default_value)
obj.set_cp("cp_"+key.lower(), principled_bsdf.inputs[key].default_value)
bproc.renderer.enable_segmentation_output(map_by=["cp_roughness", "cp_metallic", "instance"], \
default_values={'cp_roughness': None, 'cp_metallic': None, 'cp_specular': None})
# Set max samples for quick renderingbproc.renderer.set_max_amount_of_samples(5) # 5 samples per pixel# render the whole pipeline data=bproc.renderer.render()
# write the data to a .hdf5 containerbproc.writer.write_hdf5(args.output_dir, data)
Files required to run the code
The objects being rendered are as follows. (I found that I am unable to upload this model. If you need it, you can leave your email address and I will send it to you.)
Expected behavior
The correct result is as shown in the first line. The erroneous result rendered by the code above is as shown in the second line.
BlenderProc version
v.2.7.0
The text was updated successfully, but these errors were encountered:
Describe the issue
As the title suggests, I'm trying to output the roughness and metallic images from a .glb file using BlenderProc, but the results seem incorrect or unexpected. I followed the suggested method from Issue #1131.
Minimal code example
Below is a code snippet I’m using (for metallic/roughness):
Files required to run the code
The objects being rendered are as follows. (I found that I am unable to upload this model. If you need it, you can leave your email address and I will send it to you.)
Expected behavior
The correct result is as shown in the first line. The erroneous result rendered by the code above is as shown in the second line.
BlenderProc version
v.2.7.0
The text was updated successfully, but these errors were encountered: