Radiometric kernel interface¶
Eradiate’s radiometric computations are performed by its radiometric kernel Mitsuba 3, with a few additions and changes. Mitsuba is accessed through a set of convenience functions and classes presented in this document.
Core concepts¶
- Mitsuba object¶
- Kernel object¶
Mitsuba has its internal scene representation. It consists of a tree whose nodes and leaves are
mitsuba.Objectinstances.- Mitsuba scene¶
- Kernel scene¶
A
mitsuba.Sceneinstance.- Mitsuba scene dictionary¶
- Kernel dictionary¶
Mitsuba’s Python interface can load objects specified in the XML format, through the
mitsuba.load_file()andmitsuba.load_string()functions, or as Python dictionaries, using themitsuba.load_dict()function. Eradiate uses the latter and its scene generator emits scene dictionaries based on the Eradiate scene specification.- Mitsuba scene rendering¶
- Radiometric computation¶
A Mitsuba scene can be rendered for a specific sensor using the
mitsuba.render()function. This triggers a radiometric computation.- Mitsuba scene parameters¶
Mitsuba objects declare parameters which can be collected using the
mitsuba.traverse()function. The parameter table yielded by this function (amitsuba.SceneParametersinstance) can then be modified to edit scene parameters.See also
Editing a scene tutorial in the Mitsuba docs.
- Parametric loop¶
Upon a call to
eradiate.run(), Eradiate initializes a kernel scene. It then runs a sequence of radiometric computations as part of a parametric loop. Each iteration of the parametric loop corresponds to different Mitsuba scene parameters. Consequently, each iteration consists of a parameter update operation and a rendering operation.- Kernel context¶
Scene parameters are determined by a parametric context internal to the experiment being processed. The context can carry any kind of relevant information: the current spectral coordinate, the Mitsuba ID of a
mitsuba.Mediumobject attached to a sensor, etc. The kernel context is defined by aKernelContextinstance, and its main purpose is to propagate coordinated scene parameter updates in the Mitsuba scene.- Kernel dictionary template¶
Kernel dictionaries can be created from templates defined using the
KernelDictclass. Those objects are dict-like containers whose entries may beDictParameterobjects, which are expanded contextually upon a call to theKernelDict.render()method.- Kernel scene parameter map¶
A kernel scene parameter map is generated at each iteration of the parametric loop depending on contextual information. It is then used to update the scene parameters using the
mitsuba.SceneParameters.update()method.- Kernel scene parameter map template¶
Kernel scene parameter maps are generated by rendering a scene parameter map template, defined using a
KernelSceneParameterMap, a dict-like container whose entries areSceneParameterinstances.- Scene parameter flags¶
Scene parameters can be attached flags defined by the
KernelSceneParameterFlagsenumeration. These can be used to indicate the type of changes to the scene triggered by an update of the parameter they are attached to. For instance,KernelSceneParameterFlags.GEOMETRICis meant to mention that updating the associated parameter will trigger an intersection acceleration structure update, resulting in increased computation. Flags can be used when rendering scene parameter map templates to filter out some parameters.
How Eradiate calls Mitsuba¶
Eradiate’s core processing logic is split between the Experiment.init()
and Experiment.process() methods: [1]
- InitializationCreate a kernel scene object based on the experiment configuration.
Translate the scene defined by the configuration of the current
Experimentinto aKernelDictand anKernelSceneParameterMap.Render the kernel dictionary template into a kernel dictionary using an arbitrary initialization kernel context.
Load the kernel scene.
- ProcessingPerform a sequence of radiometric computations as part of a parametric loop.
For each kernel context of the experiment:
Render the
KernelSceneParameterMaptemplate into a kernel scene parameter map.Update the kernel scene with the computed scene parameter map.
Launch a radiometric computation with the updated scene.
Collect the raw results and store them in a simple data structure.
Low-level kernel interface¶
Step 4 of the Experiment.process() is implemented by the
mi_render() function. It manipulates an instance of the
MitsubaObjectWrapper which encapsulates a Mitsuba scene alongside
its scene parameters
and an scene parameter map template
and makes a Mitsuba scene update and render for each kernel context it
gets as argument.
The MitsubaObjectWrapper instance should be obtained by traversing a
Mitsuba object (typically a mitsuba.Scene with the mi_traverse()
function. The latter reimplements mitsuba.traverse() and adds an advanced
parameter name search protocol used to work around Mitsuba’s hard-to-predict
parameter naming.
Mitsuba scene parameter search¶
Mitsuba’s scene definition and internal representation can differ, which can
make the task of predicting scene parameter names very challenging. This problem
is documented in this discussion on the Mitsuba repository . Our solution
is the addition of a name search protocol to the Mitsuba object tree
traversal function mi_traverse(). In addition to the traversed Mitsuba
object, mi_traverse() can be passed a scene parameter map template.
Each SceneParameter of the update map template has an optional
search field, which can be used to detect the name of the corresponding
scene parameter.
A convenience SearchSceneParameter protocol is available. It searches
for a Mitsuba scene tree node of a specified type and with the specified object
identifier. mitsuba.Medium and mitsuba.BSDF
objects usually require a name search because they can be referenced by an
arbitrary number of other objects, with no certainty on which of the referencing
objects will be visited first during traversal and therefore will define the
parameter names.