Coder Social home page Coder Social logo

mitsuba-blender's Introduction

Addon Banner

Mitsuba Blender Add-on

Nightly Release

This add-on integrates the Mitsuba renderer into Blender.

Main Features

  • Mitsuba scene import: Import Mitsuba XML scenes in Blender to edit and preview them. Materials are converted to Cycles shader node trees.

  • Mitsuba scene export: Export a Blender scene to a Mitsuba XML scene for rendering.

More in-depth information about the features of the add-on are available on the wiki.

Installation

  • Download the latest release from the release section.
  • In Blender, go to Edit -> Preferences -> Add-ons -> Install.
  • Select the downloaded ZIP archive.
  • Find the add-on using the search bar and enable it.
  • To point the add-on to the Mitsuba dependencies, either click on Install dependencies using pip to download the latest package, or check Use custom Mitsuba path and browse to your Mitsuba build directory.

Common issues

⚠️ For versions of blender prior to 3.5, you may encounter the error message Failed to load Mitsuba package after installing the dependencies via pip. In order to fix that, you need to run blender with the --python-use-system-env flag in order for it to correctly pick up the dependencies. In order to do so, find the path to the blender executable, and in a command prompt run:

<path_to_blender> --python-use-sytem-env

You can refer to the Installation & Update Guide on the wiki for more detailed instructions.

Supported versions

Blender version should be at least 2.93. The addon has been extensively tested on LTS versions of blender (3.3, 3.6). We recommend using those whenever possible.

mitsuba-blender's People

Contributors

bathal1 avatar dvicini avatar merlinnd avatar ros-dorian avatar rtabbara avatar waytobehigh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mitsuba-blender's Issues

UI: Installing the dependencies using pip on a machine with no CUDA-capable device displays an error icon

Bug Description
When installing the addon on a machine that has no CUDA-capable device, and installing the dependencies with pip. The UI will show an error icon with no error message.

Expected behavior
Mitsuba 3 indeed logs an error message as it could not initialize a CUDA context, but it merely disables the CUDA variants. Exporting works fine as it does not require a CUDA variant. The UI should just show a success message.

Environment:

  • OS: Windows 10
  • Blender Version: 3.0
  • Add-on Version: latest

Installation: manual setting of mitsuba path is required

  1. I need to manually specify the path of the mitsuba package in ~/.config/blender/3.3/scripts/addons/mitsuba-blender/__init__.py so that the addon can work. Here is the code I add in function init_mitsuba:
    import sys
    sys.path.append("/home/<someone>/.local/lib/python3.10/site-packages")
  1. Although the mitsuba package is installed in the blender python env., it can not be imported in the console in blender but can be imported in a new terminate.

Steps to reproduce the behavior:

  1. Install the addon according to the instructions.
  2. "could not load mitsuba package" will show in the blender dialog.
  3. ctrl+alt+T, type cd blender/3.3/python/bin and python3.10
  4. Type import mitsuba, this works.
  5. Open blender, click scripts layout
  6. Type import mitsuba, this doesn't work and raises import error (could not find module mitsuba)
  • OS: ubuntu20.04
  • Blender Version: 3.3
  • Add-on Version: latest

Exporter: Bake procedural nodes into textures when converting from Cycles

The add-on tries to convert Cycles materials to Mitsuba whenever possible. However, it does not support any of Blender's math nodes which are often used in shader graphs to process textures or create them procedurally. This can be very problematic when exporting scenes that leverage this techniques a lot, resulting in many exporting failures.

Solution

The exporter could evaluate if a texture input socket can be baked into a fixed texture. Then, during the export process, this texture is rendered and replaces the baked node graph.

Additional context

An Python script example that bakes a texture can be found here.

Add support for the Principled BSDF node

The Principled BSDF is an essential element of shaders in Blender 2.8x and many scenes that are not designed primarily for mitsuba rely on this shader. It would be nice to have a "Disney BSDF" plugin in mitsuba 2, to support this node in the exporter, I'll work on that in the future.

Specular component is exported wrong for pure metallic objects

Hi! Could you please help with the following?

I have a simple scene in Blender with one camera, one cube, and one rectangular emitter (see attached). The cube has metallicity = 1 and specular = 0, i.e., it is pure metallic. We see a perfect reflection of the light source in Blender:

Screenshot 2022-08-24 at 17 48 03

However, after exporting the scene to xml using this add-on and rendering the obtained xml in Mitsuba3 I obtain a black screen.

I think that the reason is as follows. The specular value in xml is exported as zero. It seems for me that in Mitsuba3 the specular parameter has another meaning and it should be exported as 0.5 in this case. If I change it manually to 0.5, I obtain the correct images in Mitsuba.

addon_test_metal.blend.zip

Importer : AttributeError: 'NoneType' object has no attribute 'data'

Impotter : AttributeError: 'NoneType' object has no attribute 'data'

Bug Description
When I try to import a scene(scenes\dragon\dragon.xml) from differentiable-sdf-rendering, the first error that occurs is Cannot resolve scene relative path "textures/cathedral.hdr".I think it is because <path value="../"/> doesn't work correctly, so I move the all the files(scenes\dragon\*) directly to scenes\.The error goes away, but a new one appears.

Traceback (most recent call last):
  File "C:\Users\hgx\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\mitsuba-blender\io\__init__.py", line 61, in execute
    importer.load_mitsuba_scene(context, scene, collection, self.filepath, axis_mat)
  File "C:\Users\hgx\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\mitsuba-blender\io\importer\__init__.py", line 393, in load_mitsuba_scene
    if not instantiate_bl_data_node(mi_context, bl_scene_data_node):
  File "C:\Users\hgx\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\mitsuba-blender\io\importer\__init__.py", line 356, in instantiate_bl_data_node
    if not _bl_node_instantiators[node_type](mi_context, bl_node):
  File "C:\Users\hgx\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\mitsuba-blender\io\importer\__init__.py", line 224, in instantiate_bl_scene_node
    if not instantiate_bl_data_node(mi_context, child_node):
  File "C:\Users\hgx\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\mitsuba-blender\io\importer\__init__.py", line 356, in instantiate_bl_data_node
    if not _bl_node_instantiators[node_type](mi_context, bl_node):
  File "C:\Users\hgx\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\mitsuba-blender\io\importer\__init__.py", line 322, in instantiate_bl_properties_node
    if not _bl_properties_node_instantiators[node_prop_type](mi_context, bl_node):
  File "C:\Users\hgx\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\mitsuba-blender\io\importer\__init__.py", line 308, in instantiate_sampler_properties_node
    return renderer.apply_mi_sampler_properties(mi_context, bl_node.mi_props)
  File "C:\Users\hgx\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\mitsuba-blender\io\importer\renderer.py", line 248, in apply_mi_sampler_properties
    return _mi_sampler_properties_converters[mi_sampler_type](mi_context, mi_props)
  File "C:\Users\hgx\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\mitsuba-blender\io\importer\renderer.py", line 182, in apply_mi_independent_properties
    mi_camera = mi_context.bl_scene.camera.data.mitsuba
AttributeError: 'NoneType' object has no attribute 'data'

To Reproduce
Steps to reproduce the behavior:

  1. download scenes from differentiable-sdf-rendering
  2. import the xxx\scenes\dragon\dragon.xml which you will see the first error.
  3. move filesscenes\dragon\* to scenes\(I'm not sure if this is the right way to do it)
  4. See the second error

Expected behavior
Load the scene correctly

Environment (please complete the following information):

  • OS: [Windows]
  • Blender Version: [3.3]
  • Add-on Version: [latest]

ModuleNotFoundError upon attempting to activate addon

Hey folks,

After following the documentation for configuring and compiling the renderer, I'm now at the stage of setting up the addon for Blender to be able to use it. However, each time I try to activate the addon, it keeps throwing this:
image

This is effectively stopping my progress for the time being. Is there something I need to modify perhaps?

This is on a Windows 10 x64 machine, used Python 3.7x. I had the same situation happen on my Windows 7 x64 machine that used Miniconda (pretty much an exact duplicate of the documentation's process except for the operating system)

Importer/Exporter: uv coordinates flipped when importing exported scene.

Bug Description
When exporting a scene to the mitsuba format and importing it back into blender the vertical axis of the uv map is flipped.

To Reproduce
Steps to reproduce the behavior:

  1. Export scene to mitsuba xml
  2. Import same scene to blender

Expected behavior
UV coordinates should be the same after importing

Resources
Before:
Screenshot from 2022-11-12 00-36-57
After:
Screenshot from 2022-11-12 00-37-47

Environment:

  • OS: Linux
  • Blender Version: 3.3
  • Add-on Version: latest

Unable to import mitsuba

Hello,

I have followed all the instructions to install mitsuba 2.2.1 and install the add-on. However, when I try to run the export, it fails just at the start with an import error, unable to import mitsuba.

The thing is, I have run some python scripts where I'm able to import mitsuba without any problem. This error only happens when executing the code inside the blender API. However, I believe this is the only method right now to export it. Is it possible to run the export files without needing to run it from the Blender environment ?

From the error file I get that mistuba was compiled in a different python environment as blender, but I guess that should be normal, since Mitsuba was compiled following a virtual conda environment and blender is always compiled following the blender compiler. Still, since mitsuba is in PATH, I guess Blender should find it ?

These are my system specifications:

Ubuntu 20.4
Python 3.8
Mitsuba 2.2.1
Blender 2..8.3 -2.9.3 ( I tried two separate versions but none worked )

The PATH variable is pointing to both:
home/ubuntu/mitsuba2/build
home/ubuntu/mitsuba2/build/dist

and PYTHONPATH to:
home/ubuntu/mistuba2/build/dist/python

Installation: Freeze Python dependencies to predefined versions

As the Python dependencies of the add-on (mitsuba and drjit) are evolving, it creates some instabilities if breaking changes are introduced. These issues cannot be caught by the CI because periodic builds are not set up.

Solution
We can freeze the version of each dependencies installed by the add-on and make a pull request with the changes required by the newer versions. This avoids random installation failures in the wild, but would constrain the add-on to a specific mitsuba version (in the case of custom builds).

Blender 3.3 and 3.4 Addon installation: impossible to see the addon in Blender\preferences

The add on is not present in the list of the addons even after refresh or blender restart.

The tests where run with Blender 3.4 and 3.3 on Linux Mint 20.3 distrib.
The addon is downloaded on disk and chosen in Blender/Preferences
Message in the console:
Modules Installed () from '/media/LINUX_DATAS/Zeff/3D/mitsuba-blender-master.zip' into '/home/zeff/.config/blender/3.4/scripts/addons'

Then, even by clicking the refresh button or restart blender, the addon is never seen in the list and so cannot be chosen.

Environment (please complete the following information):

  • OS: Linux Mint 20.3
  • Blender Version: 3.3 and 3.4
  • Add-on Version: [e.g. latest]

Thanks for all!!! ;-)

Suggested XML output enhancements

Hi @bathal1,

Thanks for the great work on the plugin so far!
Here are some small suggestions to improve the output XML when exporting a scene to Mitsuba 2:

  • Insert a newline between each section: sampler, integrator, sensor // BSDFS // shapes
  • Create a default tag for resx, resy and spp to set them quickly from the command line
  • Create plugin options to pick the relative path where textures, shapes, etc are saved. E.g. some people may want everything in the same directory, others may want to have different directory names, etc.
  • Create an option (maybe in the export dialog where we decide where to save the scene) to have it split up into several sub-scene files in a fragments subdirectory (sampler, integrator, sensor // BSDFS // shapes), and then one main file which includes all of them. The idea is that this makes it much easier to replace e.g. just the BSDFs with a manually-modified file rather than having it to carefully insert the changes every time the scene is re-exported.
  • For the sensor's to_world transform, consider using a sequence of rotations and translations rather than a single transformation matrix which is harder to modify afterwards.

A black background is exported as a constant emitter with zero intensity

Hi,

It seems that if I set the background color to black inside Blender, the plugin still exports an emitter of strength zero:

<emitter type="constant">
	<rgb value="0.000000 0.000000 0.000000" name="radiance"/>
</emitter>

It would be better to just not export an emitter if it's radiance is zero

Best,
Delio

No module named 'mitsuba.python.xml'

Hello everyone,

I installed the plugin on Blender 2.82 and I manually added the path to Mitsuba 2 build (root folder).

Screenshot (36)

On exporting using File -> Export -> Mitsuba 2, I am getting this error:

Screenshot (35)

Is there something I need to modify perhaps (Mitsuba 2's build directory)?

Thank you for your support.

Installation: Blender crash after installing with pip

Hi,
blender is crashing after I installed mitsuba via the "install dependencies using pip" button.
The error I get in the command line is:

munmap_chunk(): invalid pointer
[1]    6518 IOT instruction (core dumped)  ./blender

, crash log
At any further launch of blender I get the following error:

Writing: /tmp/blender.crash.txt
[1]    6723 segmentation fault (core dumped)  ./blender

, crash log

To Reproduce
Steps to reproduce the behavior:

  1. Download blender 3.3 and run it
  2. Download latest release of mitsuba-blender (9d9a4cb) and install it
  3. Install mitsuba using the button "install dependencies using pip"
  4. Blender crashes

Resources
If applicable, add screenshots or other files (Blender projects, Mitsuba scenes) to help explain or demonstrate your problem.

Environment (please complete the following information):

  • OS: Linux (Fedora 36)
  • Blender Version: 3.3.0, 3.2.2, 2.93.10
  • Add-on Version: latest (9d9a4cb)

Thanks for your help.

"Selection only" option does not work

Hi,
It seems like the "selection only" option in the exporter does not do anything. Even if I check it, the exported XML contains all objects in the scene, and not just my selected objects. This is on the branch sp-addon, but has existed for a while already.
Delio

Installation: Cannot render an image using render engine

Hi! I have followed the steos of mitsuba-blender installation in Wiki "Installation & Update Guide": Download the archives "mitsuba-blender.zip", Install Add-on, click on "Install the dependencies with pip"...
everything looks the same with the captions in the guide.
(It is my first time doing this, so I do not have other versions of the add-on)
Blender version: v3.4

In Blender, when I switched from Cycles to Mitsuba in the Render Engine bar to render an image, no image came out but a chessboard texture, which means nothing was rendered. But everything was okay when using Cycles or other engines like Eevee, etc.

Maybe I need some additional configurations to do, except for the things mentioned in the Wiki guide?
Does anyone know what I should do?
Thanks!

Add license

Hello,

Mitsuba2 itself has a license included into the repository (link), but the Blender add-on has no license at all.

Therefore, it would be really great if a license could be added to this project (either the same license as in the main mitsuba2 project or a similar license that allows usage under certain conditions (e.g., MIT)).

Without any license, the default copyright laws apply, which means that the usage of the source code is very limited (see GitHub documentation). This vague specification creates a difficult situation for possible users, especially (but not only) for usage in the context of commercial projects.

Thank you very much!

Plugin "blender" not found on attempting to export scene

Hello everyone,
I installed the plugin on Blender 2.82 and I manually added the the path to Mitsuba 2 build (dist folder; I have no MITSUBA_DIR in my environment).

However, when I try to export a scene I have the following error message.

image

Do you think this could be related to the Mitsuba 2 build?

This happened on a Windows 10 x64 machine. I used Python 3.7 from Anaconda 3 for the build of Mitsuba 2.

Thank you for the support.

Installation: Failed to enable the Mitsuba Blender Add-on

Failed to enable the Mitsuba Blender Add-on
Failed to enable the Mitsuba Blender Add-on

Bug Description
I use pip to install the Mitsuba and specify version 3.0.1

When I enable the Mitsuba Blender Add-on, the report shows that AttributeError: module 'mitsuba' has no attribute 'set_variant'

And when I import mitsuba and call the same code in cmd and, it works well

To Reproduce
Steps to reproduce the behavior:

  1. Download the latest release from the release section.
  2. In Blender, go to Edit -> Preferences -> Add-ons -> Install.
  3. Select the downloaded ZIP archive.
  4. Find the add-on using the search bar and enable it.

Expected behavior

Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\Blender 3.3\3.3\scripts\modules\addon_utils.py", line 369, in enable
    mod.register()
  File "C:\Users\dgsd\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\mitsuba-blender\__init__.py", line 260, in register
    if try_register_mitsuba(context):
  File "C:\Users\dgsd\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\mitsuba-blender\__init__.py", line 60, in try_register_mitsuba
    could_init_mitsuba = init_mitsuba(context)
  File "C:\Users\dgsd\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\mitsuba-blender\__init__.py", line 37, in init_mitsuba
    mitsuba.set_variant('scalar_rgb')
AttributeError: module 'mitsuba' has no attribute 'set_variant'

Environment (please complete the following information):

  • OS: Windows
  • Blender Version: 3.3
  • Add-on Version: latest

Use Mitsbua Renderer within Blender?

Thank you for providing this useful plug in for Blender! This has significantly increased the ease in which I can construct scenes for Mitsuba.

After installing the latest version of Mitsuba-Blender, I noticed that Mitsuba is 'selectable' as a renderer within Blender. After importing the scene from the repo test1.xml, I attempted to see if I could somehow use the renderer within Mitsuba but couldn't quite figure it out.

I am familiar with how to render using Mitsuba in Python but hoped to take advantage of the newer functionality if this is the intent.

Can you provide any assistance with this?

image

Exporter: Sequence animations simulations; in blender rendering

Feature request: Exporter
In blender rendering integration or a suggestion/workaround on exporting scene animation sequences.

Is your feature request related to a problem? Please describe.

I read the wiki on the exporter module current functionalities' support at

"Future versions may support more fancy features, such as custom nodes for materials or in-blender rendering."

I'm going to try a few things myself, but I was wondering how could one use Mitsuba render engine directly in Blender? Or use the xml export and export a frame sequence similar to blender command line for animation rendering. Cameras objects would be nice as well.

Describe the solution you'd like

Currently I have a few scenes in Blender, and I use the LuxCore render engine to use the Metropolis method and easily get caustics along boids and ocean simulations.

orca

I was wondering if I could get this exact project and render the animation sequence, so like a series of images I could later turn into a video... or even pipe ffmpeg to export a video too.

Describe alternatives you've considered

At first I thought of setting a different frame and sequentially export the xml corresponding to the frame, but it would be a lot easier if I could control the xml like the blender command line animation render options, perhaps mitsuba would give even greater control like different/multiple camera selection

Additional context

I was first interested in Mitsuba after reading Tizian Zeltner, Iliyan Georgiev, and Wenzel Jakob. 2020. Specular Manifold Sampling for Rendering High-Frequency Caustics and Glints. In Transactions on Graphics (Proceedings of SIGGRAPH) 39(4). The caustics were quickly calculated, I believe it could beat LuxCore current performance on CPUs.

This is what I am trying to accomplish with Mitsuba in my pipeline. I used the Metropolis method in LuxCore as a render engine, directly in Blender. I was able to do all sorts of fancy stuff like boids, ocean simulation, multiple cameras... but it takes ages for an animation sequence.

seals.mp4
whales.mp4

I would be very open to share any potential developments I come up with on trying to implement Mitsuba in my Blender scenes, or help in some other possible way.

Installation: Crash when choosing custom mitsuba path

Bug Description
Blender crashes when I switch on the mitsuba-blender addon and add the custom path to mitsuba, which is compiled from the source.

free(): invalid pointer
Aborted (core dumped)

To Reproduce
Steps to reproduce the behavior:

  1. Compile mitsuba 121a637d) from source.
  2. Switch on the addon from blender -> preferences -> addons
  3. Click on Use custom Mitsuba path
  4. Select the build directory

Expected behavior
The plugin to load properly without any crashes

Environment (please complete the following information):

  • OS: Ubuntu 22.04
  • Blender Version: 3.4.0 Alpha
  • Add-on Version: 9d9a4cb

Additional context
The crash also occurs when I install mitsuba using pip.

Importer: Improve OBJ file loading performance

Blender's built-in operators for OBJ file loading directly creates Blender objects, meshes and materials in the given scene. In the context of the add-on, the importer needs a function that returns a single mesh instance (multiple object from a single OBJ file is not currently supported).

The current implementation is based on Blender's own Python OBJ parser and makes the necessary adjustments to return a mesh instance. However, the newer Blender 3.2.2 version comes with a C++ implementation that promises more than 10x performance improvements and the current solution would not be able to leverage it.

Solution

One can record the state of the scene (objects, meshes, materials, etc...) before and after calling the built-in Blender operator and extract the required information from the difference.

This solution means that the add-on always uses Blender's own implementation which can benefit from performance improvements in future versions.

KeyError: 'bpy_prop_collection[key]: key "Material Output" not found'

Traceback (most recent call last):
File "C:\Users\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\mitsuba-blender\io_init_.py", line 136, in execute
self.converter.scene_to_dict(deps_graph, window_manager)
File "C:\Users\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\mitsuba-blender\io\exporter_init_.py", line 97, in scene_to_dict
geometry.export_object(object_instance, self.export_ctx, evaluated_obj.name in particles)
File "C:\Users\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\mitsuba-blender\io\exporter\geometry.py", line 104, in export_object
export_material(export_ctx, b_mesh.materials[mat_nr])
File "C:\Users\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\mitsuba-blender\io\exporter\materials.py", line 353, in export_material
mat_params = b_material_to_dict(export_ctx, material)
File "C:\Users\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\mitsuba-blender\io\exporter\materials.py", line 330, in b_material_to_dict
output_node = b_mat.node_tree.nodes["Material Output"]
KeyError: 'bpy_prop_collection[key]: key "Material Output" not found'

ImportError Mitsuba2, despite the fact that the python versions (compiled and Blender) matches. Windows

Win11

  • Blender 2.93 + Mitsuba-Blender (the 'next' branch)+ Mitsuba2 (compiled against Python 3.9.2, which is the version for Blender 2.93.0) = Not recognized
  • Blender 2.93 + Mitsuba-Blender (the 'next' branch)+ Mitsuba2 (compiled against Python 3.9.7, which is the version for Blender 3.0.0) = Not recognized
  • Blender 3.0 + Mitsuba-Blender (the 'next' branch)+ Mitsuba2 (compiled against Python 3.9.7, which is the version for Blender 3.0.0) = Not recognized
  • New: according to this comment (#13 (comment)), Blender 2.83 + Mitsuba-Blender + Mitsuba2 (compiled against Python 3.7.9, but the Blender Python is 3.7.4) should work, but it doesn't work, same problem = Not recognized
    image
    image

Any thoughts ?

Exporter: Curve support

It would be great if the exporter could export curves in a format complying with the recently added curve support in Mitsuba 3.

error messsage

image
Please help
same message in win 10, Blender 2.93 and blender 3.2

Exporting of scenes via the Python API

It would be amazing, if the export could not only be done via the "Export" dialog, but if there would also be a direct access from the Python API (if that is feasible).

I am working a lot on creating scenes with the Python API, and adding this to the scripts would save the manual work here.

PS: is this project also open for external contributors? Then I could give it a try.

Install details: Numpy dependency

When I installed this addon I had a dependency issue, that could be prevented by extending to the install instructions in the README:

Install numpy to the system python. This addon requires numpy to be installed such that Blender's python can find it (see the search path import sys; sys.path in python console).

SceneConverter.scene_to_dict() missing 1 required positional argument: 'window_manager'

Traceback (most recent call last): File "C:\Users\Patrick\AppData\Roaming\Blender Foundation\Blender\3.3\scripts\addons\mitsuba-blender\engine\final.py", line 42, in render self.converter.scene_to_dict(depsgraph) TypeError: SceneConverter.scene_to_dict() missing 1 required positional argument: 'window_manager'

Bug Description
I installed the 3.3.0 Blender and the last addon for Blender.
Installed the Mitsuba pip module
and activated the addon, then re-run Blender.
I make a cube, saved the blend file and run F12 to render the view
BUT nothing in Render viewport !
and obtained this traceback in terminal windows!

Environment :

  • OS: Windows 10
  • Blender Version: v3.3.0
  • Add-on Version: v0.1 alpha

Exporter: Export of scene fails

Exporting a Scene in Mitsuba Format Fails

Bug Description
I want to export a scene in the Mitsuba format to import it to another Python tool. When trying to export a scene, there is an error and the scene is not saved. This happens already with the default Blender scene.

To Reproduce
Steps to reproduce the behavior:

  1. Opening Blender
  2. Save file. (does not have an impact, also tried to directly export)
  3. File > Export > Mitsuba 2

The error message is the following:

Python: Traceback (most recent call last):

  File "C:\Blender\blender-3.4.1-windows-x64\3.4\scripts\addons\mitsuba2-blender\export.py", line 112, in execute
    self.export_ctx.set_filename(self.filepath, split_files=self.split_files)
  File "C:\Blender\blender-3.4.1-windows-x64\3.4\scripts\addons\mitsuba2-blender\file_api.py", line 100, in set_filename
    self.xml_writer = WriteXML(name, split_files)
  File "C:\Blender\blender-3.4.1-windows-x64\3.4\python\lib\site-packages\mitsuba\python\xml.py", line 62, in __init__
    self.set_filename(path)
  File "C:\Blender\blender-3.4.1-windows-x64\3.4\python\lib\site-packages\mitsuba\python\xml.py", line 167, in set_filename
    self.textures_folder = os.path.join(self.directory, self.subfolders['texture'])
TypeError: 'bool' object is not subscriptable

I tried different filenames and paths, one example is C:\Blender\scenes\scene1.xml. Dialog configuration as below, but also different options do not seem to have an impact.
image

Environment (please complete the following information):

  • OS: Windows 11
  • Blender Version: 3.4.1
  • Add-on Version: latest
  • Mitsuba installed via pip

Installation: Fail to load package after pip install

Hi
I'm encountering problems with the mitsuba2-blender add-on
It says it fails to install the package but actually I can use mitsuba in the terminal , so it install it
I can also install mitsuba by myself with pip but still not working
I tried a custom version with mitsuba2 but it doesn't work too but, In the scripting window, I can import mitsuba
Do you have any suggestion to help me solve that problem?

It is on in the add-on window that it shows: Fail to load package
And when I choose to use the custom path it doesn't show anything (just the checkbox but any near message)
but still I cannot see the export import option

Ubuntu 20.04
Python 3.9.5
Blender 2.93

Can't import mitsuba: ImportError: DLL load failed while importing mitsuba_ext: The specified procedure could not be found.

Bug Description
I'm using a custom build of mitsuba, following the instructions here.. After specifying the custom mitsuba path, I get the error "The 'mitsuba' native modules could not be imported.". Digging further, I tried importing mitsuba using blender's python exe, which worked without problems. However, when the trying to import mitsuba in blender's build-in console, i get the full error:

Traceback (most recent call last):
  File "C:\Users\user\Desktop\mitsubabuild\mitsuba3\build\Release\python\mitsuba\__init__.py", line 39, in <module>
    _import('mitsuba.mitsuba_ext')
  File "C:\Program Files\Blender Foundation\Blender 3.5\3.5\python\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 674, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 571, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1176, in create_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
ImportError: DLL load failed while importing mitsuba_ext: The specified procedure could not be found.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
  File "C:\Users\user\Desktop\mitsubabuild\mitsuba3\build\Release\python\mitsuba\__init__.py", line 60, in <module>
    raise exc
ImportError: The 'mitsuba' native modules could not be imported. 

So blender obviously seems to find mitsuba_ext, as it gives a different error if I try to import a non-existing module with the same function. I've narrowed down that mitsuba_ext is "mitsuba_ext.cp310-win_amd64.pyd". Explicitly importing that specific file works without any problem using blender's python exe, but inside the blender terminal, i get the same "ImportError: The 'mitsuba' native modules could not be imported. ".

So it seems that the root cause is that somehow mitsuba_ext.cp310-win_amd64.pyd is imported differently inside of blender compared to blender's python exe run in cmd. If needed, I can send my build of mitsuba. Thanks for any help!

If this doesn't belong here, should I ask the blender or mitsuba guys for help?

Environment (please complete the following information):

  • OS: Windows
  • Blender Version: 3.5
  • Add-on Version: latest
  • Python: 3.10.9

Windows installation -- Different Python

While the installation on Ubuntu worked almost as described in the README, we fail to install under windows with You're likely trying to use Mitsuba within a Pythom binary that is different from the one for which the native module was compiled. As described in the README, we checked the python executables in Blender and the one used to build Mitsuba to have the same version.

My guess what is going wrong: Blender's python does not find packages inside an anaconda environment, thus failing to import the Mitsuba extension (see also #14). Mitsuba is not checking the python version, but simply the executable path and a misleading error message is printed. Under Linux, I would work around by installing Mitsuba to the system python, which is in Blenders python package path, but afaik there is no system python under windows.

Any experience or workaround to use this plugin with windows?

Add progress bar

Hi,

It would be great to have some form of a progress bar in the UI, just to be able to tell whether the plugin is really working on a more complex scene

Delio

<Mitsuba blender add on error>: <Cannot install Mitsuba add-on in blender>

Cannot install mitsuba add on for blender

Bug Description
While trying to install mitsuba add-on in blender, i am getting following error:

Read prefs: C:\Users\MOH80574\AppData\Roaming\Blender Foundation\Blender\3.5\config\userpref.blend
Exception in module register(): C:\Users\MOH80574\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\mitsuba-blender_init_.py
Traceback (most recent call last):
File "C:\Program Files\Blender Foundation\Blender 3.5\3.5\python\lib\site-packages\mitsuba_init_.py", line 49, in
import('mitsuba.mitsuba_ext')
File "C:\Program Files\Blender Foundation\Blender 3.5\3.5\python\lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 674, in _load_unlocked
File "", line 571, in module_from_spec
File "", line 1176, in create_module
File "", line 241, in _call_with_frames_removed
ImportError: DLL load failed while importing mitsuba_ext: The specified procedure could not be found.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Program Files\Blender Foundation\Blender 3.5\3.5\scripts\modules\addon_utils.py", line 369, in enable
mod.register()
File "C:\Users\MOH80574\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\mitsuba-blender_init_.py", line 301, in register
if try_register_mitsuba(context):
File "C:\Users\MOH80574\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\mitsuba-blender_init_.py", line 55, in try_register_mitsuba
could_init_mitsuba = init_mitsuba(context)
File "C:\Users\MOH80574\AppData\Roaming\Blender Foundation\Blender\3.5\scripts\addons\mitsuba-blender_init_.py", line 35, in init_mitsuba
import mitsuba
File "C:\Program Files\Blender Foundation\Blender 3.5\3.5\python\lib\site-packages\mitsuba_init_.py", line 69, in
raise exc
ImportError: The 'mitsuba' native modules could not be imported. You're likely trying to use Mitsuba within a Python binary (C:\Program Files\Blender Foundation\Blender 3.5\3.5\python\bin\python.exe) that is different from the one for which the native module was compiled (C:\Users\runneradmin\AppData\Local\Temp\cibw-run-rwptb42b\cp310-win_amd64\build\venv\Scripts\python.exe).

To Reproduce
Steps to reproduce the behavior:

  1. Download blender and mitsuba add on from these two links - https://www.blender.org/download/releases/3-5/ and https://github.com/mitsuba-renderer/mitsuba-blender
  2. Open blender and click on edit -> preferences -> install -> mitsuba zip file
  3. Error is popped up when activating the add-on

Expected behavior
While activating, mitsuba add-on should be activated without any issue

Environment (please complete the following information):

  • OS: [Windows]
  • Blender Version: [3.5]
  • Add-on Version: [latest]

Cannot render in Blender using mitsuba as renderer

Issue Title
When render a simple scene with mitsuba as the renderer, the image is empty.

Bug Description

Traceback (most recent call last): File "/home/khiem/.config/blender/3.3/scripts/addons/mitsuba-blender/engine/final.py", line 42, in render self.converter.scene_to_dict(depsgraph) TypeError: SceneConverter.scene_to_dict() missing 1 required positional argument: 'window_manager'

Resources
Blender file: https://drive.google.com/file/d/1sOkORFJkd8oHzvQwA1Raqm6vMcOON5Z0/view?usp=sharing

Environment (please complete the following information):

  • OS: Pop OS 20.04
  • mitsuba-blender v0.1alpha registered (with mitsuba v3.0.1)
  • Blender Version: 3.3.9

Wrong fov for vertical cameras during export

Hi! I noticed that while exporting scenes with vertical cameras (resy > resx), fov becomes diffenent. Horizontal cameras (resy < resx) are exported perfectly. Please see the examples below.

Fixed that with changing the line below to params["fov"] = max(b_camera.data.angle_x, b_camera.data.angle_y) * 180 / np.pi on my end.

params['fov'] = b_camera.data.angle_x * 180 / np.pi#TODO: check cam.sensor_fit

untitled.blend.zip

mitsuba blender
Blender is the rightmost and Mitsuba is the leftmost.

export_world() fails if there is no node tree

Some Blender scenes do not have a node tree for the world-object.

Then, the add-on crashes with the following error message:

[...]  line 439, in export_world
    output_node = world.node_tree.nodes['World Output']
AttributeError: 'NoneType' object has no attribute 'nodes'
Process finished with exit code 1

When I inspect one of the corresponding scenes, I get this output:

>>> import bpy
>>> print(bpy.context.scene.world.node_tree)
None

Therefore, it should be enough to add these lines at the beginning of export_world():

    if world.node_tree is None:
        return

If you want, I can create a PR for this change.

Version of mitsuba required for render-engine branch

Thank you for the great work!

I'm trying to use the render-engine branch, since it seems to support converting blender scenes into mitsuba dictionaries (as opposed to xml files), which I am trying to do in a headless blender script.

Which branch of the mitsuba2 repo are you working against? I tried the blender-refactoring branch but I'm unable to import mitsuba in python after building it, due to an import error with enoki. Can you point me in the right direction?

Export from command line

Hi,

it would be really nice to be able to do exports directly from the command line. Like that, the add-on will become more versatile and can even be executed without a GUI (when using blender -b, see here)). That is especially helpful for GUI-less Blender operation, e.g., when working on a specific machine via SSH.

Personally, I would say that a Python script, which handles this and possibly allows options via a CLI, would be the easiest and best option. (I.e., usage would somehow look like this: blender somescene.blend -b --python new_exporter_script.py and could be wrapped further with a shell script.)

Thank you!

Exporter/Importer: Blender crash on import/export

I am trying to export or import an xml file and blender closes.

Console output:

Read prefs: /home/user/.config/blender/2.93/config/userpref.blend
jit_cuda_init(): could not find symbol "cuDevicePrimaryCtxRelease_v2" -- disabling CUDA backend!
mitsuba-blender v0.1alpha registered (with mitsuba v3.0.1)
Read blend: /home/user/Blender-Projects/dao.blend
Scene File: /home/user/Blender-Projects/dao.xml
Scene Folder: /home/user/Blender-Projects
Writing: /tmp/dao.crash.txt
Segmentation fault (memory stack flushed to disk)
  • OS: Ubuntu 22.04.1
  • Blender Version: 2.93.10
  • Add-on Version: latest

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.