owl-project / NVISII

Apache License 2.0
327 stars 28 forks source link

Need help material setting #122

Closed ctxqlxs closed 3 years ago

ctxqlxs commented 3 years ago

how to code to achieve this effect (blender): image image I have tried some code, but it doesn't work.

mesh = visii.mesh.create_from_file(opt.entity, opt.model)
# creates visii entity using loaded mesh
obj_entity = visii.entity.create(
    name=opt.entity + "_entity",
    mesh=mesh,
    transform=visii.transform.create(opt.entity + "_entity"),
    material=visii.material.create(opt.entity + "_entity"),
)

obj_entity.get_material().set_base_color((0.847, 0.831, 0.651))
obj_entity.get_material().set_subsurface_color((0.847, 0.831, 0.651))
obj_entity.get_material().set_subsurface_radius((1.0, 0.2, 0.1))
obj_entity.get_material().set_ior(0.55)
obj_entity.get_material().set_roughness(0)
obj_entity.get_material().set_metallic(0)
natevm commented 3 years ago

We don’t support mixing multiple materials together like you’re doing in blender. We do support mixing texture inputs, just not materials.

The modern way to achieve simpler materials like this is in Blender 2.8 and on is to use the principled BRDF node. The material component in nvisii is designed to roughly follow that principled BRDF node.

Note that come material properties like subsurface scattering are not entirely supported in nvisii.

I’m not entirely clear about what you mean by “doesn’t work”. Could you be more specific?

TontonTremblay commented 3 years ago

The easiest way to understand material is to load your mesh in this example. https://github.com/owl-project/NVISII/blob/master/examples/17.materials_visii_interactive.py Then use the GUI to make the mesh the material you want. You can easily print the values you used.

If you mesh is composed of different materials, you can mix them as follow in this example, https://github.com/owl-project/NVISII/blob/master/examples/18.materials.py.