Transient rendering extensions for Mitsuba 3
Project description
Transient Mitsuba 3
Miguel Crespo Diego Royo Jorge García
Introduction
This library adds support to Mitsuba 3 for doing transient simulations, and especially non-line-of-sight (NLOS) data capture simulations.
Quick start:
What is transient rendering?
Conventional rendering is referred as steady state, where the light propagation speed is assumed to be infinite. In contrast, transient rendering breaks this assumtion allowing to simulate light in motion (see the teaser image for a visual example).
For example, path tracing algorithms integrate over multiple paths that connect a light source with the camera. For a known path, transient path tracing uses the very complex formula of time = distance / speed (see [Two New Sciences by Galileo]) to compute the time when each photon arrives to the camera from the path's distance and light's speed. This adds a new time dimension to the captured images (i.e. it's a video now). The simulations now take new parameters as input: when to start recording the video, how long is each time step (framerate), and how many frames to record.
Note: note that the time values we need to compute are very small (e.g. light takes only ~3.33 * 10^-9 seconds to travel 1 meter), time is usually measured in optical path distance. See Wikipedia for more information. TL;DR opl = distance * refractive_index
Main features
- Cross-platform: Mitsuba 3 has been tested on Linux (x86_64), macOS (aarch64, x86_64), and Windows (x86_64).
- Easy interface to convert your algorithms for the transient domain.
- Temporal domain filtering.
- Python only library for doing transient rendering in both CPU and GPU.
- Several integrators already implemented including path tracing (also adapted for NLOS scenes) and volumetric path-tracing.
Roadmap
*Last update: Apr. 2024
- Importance sampling of the temporal domain
- Differentiable transient rendering
- Fluorescence BRDF
- Non-line-of-sight support (NLOS)
-
max_depth -
filter_depth -
discard_direct_paths -
auto_detect_bins - Faster implementation of exhaustive scanning
-
Requirements
Python >= 3.8Mitsuba3 >= 3.5.0- (optional) For computation on the GPU:
Nvidia driver >= 495.89 - (optional) For vectorized / parallel computation on the CPU:
LLVM >= 11.1
Installation
We provide the package via PyPI. To install mitsuba3-transient-nlos you need to run:
pip install mitransient
If you have installed Mitsuba 3 via pip you will only have access to the llvm_ad_rgb and cuda_ad_rgb variants. If you want to use other variants (e.g. NLOS simulations can greatly benefit from the llvm_mono variant), then we recommend that you compile Mitsuba 3 youself, enabling the following variants: ["scalar_mono", "llvm_mono", "llvm_ad_mono", "cuda_mono", "cuda_ad_mono", "scalar_rgb", "llvm_rgb", "llvm_ad_rgb", "cuda_rgb", "cuda_ad_rgb"]. Here's more info.
Old installation instructions (incl. Mitsuba 3 fork)
See details
_NOTE: These instructions have been tested on Linux and Windows 11 (Powershell), but can be adapted to MacOS probably (hopefully) without many problems_After cloning the repo, navigate to the root folder and execute the following commands to build the custom version of Mitsuba 3
- Step 0: Clone the repo (including the mitsuba3 custom fork submodule)
git clone git@github.com:diegoroyo/mitsuba3-transient-nlos.git mitsuba3-transient-nlos
cd mitsuba3-transient-nlos
git submodule update --init --recursive
Now the steps are different for Linux and Windows users
Linux users:
-
Step 1: Compile mitsuba3 (ext/mitsuba3) from source
-
This is for Linux. for other OSes, check: https://mitsuba.readthedocs.io/en/latest/src/developer_guide/compiling.html
cd ext/mitsuba3 mkdir -p build && cd build
-
You might want to set the C++/C compiler (probably you want this e.g. if
cmakecomplains about your version of g++). Always setC_COMPILERversion to the same version asCXX_COMPILER(e.g. if you useg++-12, then also setgcc-12) -
If you have multiple Python versions installed, also set Python_EXECUTABLE to ensure that the program is compiled for your specific version of Python
cmake \ -GNinja \ -DCMAKE_CXX_COMPILER=<path-to-c++-compiler> \ -DCMAKE_C_COMPILER=<path-to-c-compiler> \ -DPython_EXECUTABLE=<path-to-python-executable> \ ..
-
Step 1.1: You should see a message that a file was created on "build/mitsuba.conf". Open the file and look for "enabled" variants. Docs: https://mitsuba.readthedocs.io/en/latest/src/key_topics/variants.html
- Recommended variants:
"scalar_mono", "llvm_mono", "llvm_ad_mono", "cuda_mono", "cuda_ad_mono", "scalar_rgb", "llvm_rgb", "llvm_ad_rgb", "cuda_rgb", "cuda_ad_rgb". - IMPORTANT: At least one ad variant needs to be specified.
- Recommended variants:
-
Step 1.2: Re-run the cmake command to read the updated mitsuba.conf and compile the code with ninja
cmake <same arguments as before> .. ninja # This will take some time
-
-
Step 2: Install
mitsuba3-transient-nlos(a.k.a.mitransientPython library)cd ../../.. # go back to initial mitsuba3-transient-nlos folder scripts/local_install.sh
Windows users:
-
Step 1: Compile mitsuba3 (ext/mitsuba3) from source
cd ext/mitsuba3
-
A recent version of Visual Studio 2022 is required. Cmake need to be installed manually
-
Check that the version of your Python is the correct one when you execute
python# Specifically ask for the 64 bit version of Visual Studio to be safe cmake -G "Visual Studio 17 2022" -A x64 -B build
-
Step 1.1: You should see a message that a file was created on "build/mitsuba.conf". Open the file and look for "enabled" variants. Docs: https://mitsuba.readthedocs.io/en/latest/src/key_topics/variants.html
- Recommended variants:
"scalar_mono", "llvm_mono", "llvm_ad_mono", "cuda_mono", "cuda_ad_mono", "scalar_rgb", "llvm_rgb", "llvm_ad_rgb", "cuda_rgb", "cuda_ad_rgb". - IMPORTANT: At least one ad variant needs to be specified.
- Recommended variants:
-
Step 1.2: Re-run the cmake command to read the updated mitsuba.conf and compile the code with Visual Studio.
cmake <same arguments as before> # You can build from terminal with this, if you don't like opening Visual Studio cmake --build build --config Release # this will take some time
-
-
Step 2: Install
mitsuba3-transient-nlos(a.k.a.mitransientPython library)- Step 2.1: You will need to edit your environment variables in Windows manually
MITSUBA_DIR = <path-to-the-cloned-repository</mitsuba3-transient-nlos/ext/mitsuba3/build/Release Path = %Path%;%MITSUBA_DIR% PYTHON_PATH = %MITSUBA_DIR%/python - Step 2.2: Install
mitsuba3-transient-nlos(a.k.a.mitransientPython library)cd ../../ # go back to initial mitsuba3-transient-nlos folder python -m pip install .
- Step 2.1: You will need to edit your environment variables in Windows manually
After installation
At this point you should be able to import mitsuba and import mitransient in your Python code (careful about setting the correct PATH environment variable if you have compiled Mitsuba 3 yourself, see the section below).
If it works, you're all set!
For NLOS data capture simulations, see https://github.com/diegoroyo/tal. tal is a toolkit that allows you to create and simulate NLOS scenes with an easier shell interface instead of directly from Python.
If you use your own Mitsuba 3
If you have opted for using a custom (non-default installation through pip) of Mitsuba 3, you have several options for it. The idea here is to be able to control which version of Mitsuba will be loaded on demand.
- One solution is to directly execute
setpath.shprovided after the compilation of the Mitsuba 3 repo (More info). This shell script (on Linux) will modify thePATHandPYTHONPATHvariables to load first this version of Mitsuba. - Another solution following the previous one is to directly set yourself the
PYTHONPATHenvironment variable as you wish. - Another solution for having a custom version globally available is by using
pip install .--editable. This will create a symlink copy of the package files inside the correspondingsite-packagesfolder and will be listed as a package installed ofpipand will be available as other packages installed. If you recompile them, you will still have the newest version directly for use. Please follow these instructions:- Go to
<mitsuba-path>/mitsuba3/build/python/drjitand executepip install . --editable. - Go to
<mitsuba-path>/mitsuba3/build/python/mitsubaand executepip install . --editable.
- Go to
- If you are a user of Jupyter Notebooks, the easiest solution will be to add the following snippet of code to modify on-site the PYTHON PATH for that specific notebook:
import sys
sys.path.insert(0, '<mitsuba-path>/mitsuba3/build/python')
import mitsuba as mi
Usage
Check out the examples folder for practical usage.
As of November 2023, mitsuba3-transient-nlos implements the following plugins which can be used in scene XML files. To view a description of their parameters, click on the name of your desired plugin.
film:transient_hdr_film: Transient equivalent of Mitsuba 3'shdrfilmplugin.
integrators:transient_path: Transient path tracing for line-of-sight scenes. If you want to do NLOS simulations, usetransientnlospathinstead.transient_nlos_path: Transient path tracing with specific sampling routines for NLOS scenes (e.g. laser sampling and hidden geometry sampling of the "Non-Line-of-Sight Transient Rendering" paper).transient_prbvolpath: Path Replay Backpropagation for volumetric path tracing. Implemented by Miguel Crespo, untested.
sensor:nlos_capture_meter: Can be attached to one of the scene's geometries, and measures uniformly-spaced points on such geometry (e.g. relay wall).
Testing
Our test suite can be ran using pytest on the root folder of the repo.
License and citation
This project was created by Miguel Crespo and expanded by Diego Royo and Jorge García.
If you are using our code for transient NLOS simulations, we would be grateful if you cited our publication:
@article{royo2022non,
title = {Non-line-of-sight transient rendering},
journal = {Computers & Graphics},
year = {2022},
issn = {0097-8493},
doi = {https://doi.org/10.1016/j.cag.2022.07.003},
url = {https://www.sciencedirect.com/science/article/pii/S0097849322001200},
author = {Diego Royo and Jorge García and Adolfo Muñoz and Adrian Jarabo}
Otherwise you can cite this repository as:
@misc{mitsuba3transient,
author = {Royo, Diego and Garcia, Jorge and Crespo, Miguel},
title = {Mitsuba 3 Transient},
year = {2023},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/diegoroyo/mitsuba3-transient-nlos}}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mitransient-1.0.0.tar.gz.
File metadata
- Download URL: mitransient-1.0.0.tar.gz
- Upload date:
- Size: 37.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04d4d26ece8f395a59eeb4a3ebe916ac8652f259c98ac184924182b39392ebec
|
|
| MD5 |
e1bc635fb9b8bc4f8b02aa5dfba70102
|
|
| BLAKE2b-256 |
3103824a9596f0ad5857373cc1ca499c580e0ec55cc4a7832b3fff06c8bf5ca9
|
File details
Details for the file mitransient-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mitransient-1.0.0-py3-none-any.whl
- Upload date:
- Size: 42.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69de1444d6c534c3080ed9bdb232d685f9d18fd462d3c62a6a7f88ca7ddcdc5c
|
|
| MD5 |
bc930d35600d2b1d70e61524b5f8d667
|
|
| BLAKE2b-256 |
7ce9b59d03eb4ff7b3f541932264879fd2f01c2622e57949c9d03dd54afff5e0
|