-
I'm following Mitsuba's caustic rendering tutorial: https://mitsuba.readthedocs.io/en/latest/src/inverse_rendering/caustics_optimization.html . Now i wanted to export the scene described in the tutorial as a xml file and import it into Blender to visualize the setup. The scene is a python dict (see tutorial for further details): scene = {
'type': 'scene',
'sensor': sensor,
'integrator': integrator,
# Glass BSDF
'simple-glass': {
'type': 'dielectric',
'id': 'simple-glass-bsdf',
'ext_ior': 'air',
'int_ior': 1.5,
'specular_reflectance': { 'type': 'spectrum', 'value': 0 },
},
'white-bsdf': {
'type': 'diffuse',
'id': 'white-bsdf',
'reflectance': { 'type': 'rgb', 'value': (1, 1, 1) },
},
'black-bsdf': {
'type': 'diffuse',
'id': 'black-bsdf',
'reflectance': { 'type': 'spectrum', 'value': 0 },
},
# Receiving plane
'receiving-plane': {
'type': 'obj',
'id': 'receiving-plane',
'filename': 'meshes/rectangle.obj',
'to_world': \
mi.ScalarTransform4f.look_at(
target=[0, 1, 0],
origin=[0, -7, 0],
up=[0, 0, 1]
).scale((5, 5, 5)),
'bsdf': {'type': 'ref', 'id': 'white-bsdf'},
},
# Glass slab, excluding the 'exit' face (added separately below)
'slab': {
'type': 'obj',
'id': 'slab',
'filename': 'meshes/slab.obj',
'to_world': mi.ScalarTransform4f.rotate(axis=(1, 0, 0), angle=90),
'bsdf': {'type': 'ref', 'id': 'simple-glass'},
},
# Glass rectangle, to be optimized
'lens': {
'type': 'ply',
'id': 'lens',
'filename': lens_fname,
'to_world': mi.ScalarTransform4f.rotate(axis=(1, 0, 0), angle=90),
'bsdf': {'type': 'ref', 'id': 'simple-glass'},
},
# Directional area emitter placed behind the glass slab
'focused-emitter-shape': {
'type': 'obj',
'filename': 'meshes/rectangle.obj',
'to_world': mi.ScalarTransform4f.look_at(
target=[0, 0, 0],
origin=[0, 5, 0],
up=[0, 0, 1]
),
'bsdf': {'type': 'ref', 'id': 'black-bsdf'},
'focused-emitter': emitter,
},
} i have exported the dict to a xml using Mitsuba: import mitsuba as mi
mi.xml.dict_to_xml(scene, filename='caustic_optimization.xml') I'm running into several issues, some of which i could solve by manually editing the xml file. However, for the more complex issues i would like to debug the python code of
Downgrading python to 3.7.x won't solve it because of other dependency issues... Long story short: how can i setup an environment to run some tests on importing mitsuba xml's into Blender? I'm using Blender 3.6 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi, Installing For development, you can clone the repo and make a symlink to the |
Beta Was this translation helpful? Give feedback.
Hi,
Installing
bpy
via pip will not help you. You need to use blender's python, which already hasbpy
installed (since it's blender's python API).For development, you can clone the repo and make a symlink to the
mitsuba-blender
folder in the directory containing add-ons for blender, e.g. for linux:~/.config/blender/3.6/scripts/addons
. Alternatively you could use this VSCode extension.