Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTov committed Oct 8, 2023
1 parent 01d33f6 commit 224db7a
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
69 changes: 69 additions & 0 deletions examples/rendering.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import open3d as o3d
import mitsuba as mi


def render_mesh(mesh, mesh_center):
scene = mi.load_dict({
'type': 'scene',
'integrator': {
'type': 'path'
},
'light': {
'type': 'constant',
'radiance': {
'type': 'rgb',
'value': 1.0
}
# NOTE: For better results comment out the constant emitter above
# and uncomment out the lines below changing the filename to an HDRI
# envmap you have.
# 'type': 'envmap',
# 'filename': '/home/renes/Downloads/solitude_interior_4k.exr'
},
'sensor': {
'type':
'perspective',
'focal_length':
'50mm',
'to_world':
mi.ScalarTransform4f.look_at(origin=[0, 0, 5],
target=mesh_center,
up=[0, 1, 0]),
'thefilm': {
'type': 'hdrfilm',
'width': 1024,
'height': 768,
},
'thesampler': {
'type': 'multijitter',
'sample_count': 64,
},
},
'themesh': mesh,
})

img = mi.render(scene, spp=256)
return img


# Default to LLVM variant which should be available on all
# platforms. If you have a system with a CUDA device then comment out LLVM
# variant and uncomment cuda variant
mi.set_variant('llvm_ad_rgb')
# mi.set_variant('cuda_ad_rgb')


mesh = o3d.t.geometry.TriangleMesh.create_sphere(radius=1.0)
mesh.compute_vertex_normals()
mesh_center = mesh.get_axis_aligned_bounding_box().get_center()


# mesh.material.set_default_properties()
print('Render mesh with material converted to Mitsuba principled BSDF')
# mi_mesh = mesh.to_mitsuba('sphere')
# img = render_mesh(mi_mesh, mesh_center.numpy())
# mi.Bitmap(img).write('test.exr')


# Render with Open3D
o3d.visualization.draw(mesh)
2 changes: 1 addition & 1 deletion znvis/visualizer/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def save_callable():
mesh += item.mesh_list[self.counter]

o3d.io.write_triangle_mesh(
(self.obj_folder / f"export_mesh_{self.counter}.obj").as_posix(), mesh
(self.obj_folder / f"export_mesh_{self.counter}.ply").as_posix(), mesh
)
self.save_thread_finished = True

Expand Down

0 comments on commit 224db7a

Please sign in to comment.