xxlong0 / Wonder3D

Single Image to 3D using Cross-Domain Diffusion for 3D Generation
https://www.xxlong.site/Wonder3D/
GNU Affero General Public License v3.0
4.71k stars 373 forks source link

How to render a object with roughness/metallic textures and output roughness/metallic images? #184

Open bbbbubble opened 2 months ago

bbbbubble commented 2 months ago

@xxlong0 Thanks for this wonderful project! The released render_codes only provides rgb/normal/depth rendering results. How to output roughness/metallic images? I wrote this piece of code, it can output roughness/metallic images with default values of roughness/metallic.

# some objects' normals are affected by textures
mesh_objects = convert_to_meshes([obj for obj in scene_meshes()])
for obj in mesh_objects:
    print("removing invalid normals")
    for mat in obj.get_materials():
        mat.set_principled_shader_value("Normal", [1,1,1])
        principled_bsdf = mat.get_the_one_node_with_type("BsdfPrincipled")
        for key in ["Roughness", "Metallic", "Specular"]:
            obj.set_cp("cp_"+ key.lower(),  principled_bsdf.inputs[key].default_value)

...

bproc.renderer.enable_segmentation_output(map_by=["cp_roughness", "cp_metallic", "cp_specular", 'instance'],default_values={'cp_roughness': None, 'cp_metallic': None, 'cp_specular': None} )

However, if we have objects with roughness/metallic textures, the results are wrong: image Any solutions? Thanks!