Scientific Rendering Using Mitsuba - Physically Based Renderer
Nov 19, 2012
To render some of my simulations I have recently started using Mitsuba as a quick way to get a nice visualization. The scene description file is very well documented Here. In this post I am going to provide some example code to show how I setup a scene description, stage the simulation data to render and finally render the data.
XML
Scene Definition
Mitsuba reads in all of its data via XML files. Here is an example of a scene file. I generally use a single scene file for an entire simulation. This does mean that my camera will be static however.
Note the file.xml which I include. This is where the simulation data is actually defined, at runtime you can define the “$file” variable to the data file for the current frame (ex: data123.xml)
I use TinyXML2 to generate the XML files as it is lightweight and very easy to use.
Geometry Definition
Here is an example of a data file that can be included in the scene above. It contains two spheres without any material or color.
C++ Code
Sample C++ TinyXML2 code that generates data for a sphere
Rendering
The following command will use the scene file with a specific frame file and render out that frame to png
Once all data is rendered you can use This post to convert it all into a video!