• MRF - Main Page
  • Malia Renderer
  • Blender Bridge
  • Spectral Viewer
  • MRF - Scene format
  • Gallery
  • RGB To Spectral
  • For Developpers
  • MRF Blender Integration
    This page presents the **MRF** Blender integration for version 2.7x and older. For version 2.8x, please refer to the Blender 2.8x page. !!! WARNING Most Blender materials do not have a MRF equivalent. Please refer to the table below for the currently supported materials. # Introduction Using MRF, you can directly export and render your scenes from Blender. This permits the quick specification of a scene and enables easy camera setup or even camera animation! Blender can be downloaded from: Blender.org We follow this pipeline: ***************************************** * .---------. .-----. .-------. * * | Blender +-+->| MRF +-+->| Malia | * * '---------' '-----' '-------' * ***************************************** Where a Blender scene is exported to a mrf scene which is a combination of: - a .msf file: the scene, - a .mcf file: the camera(s) - an optionnal .mpf file: the patch (see [MRF Patch mechanism](./blender_integration.md.html/#howtousethemrfintegration/mrfpatchmechanism)) - a directory containing the assets (.obj, envmaps, .spd ...) Then we can use Malia to render the mrf scene. # Set-up the MRF integration in Blender To use the MRF integration in Blender the following steps must be completed: - [Install MRF](./main.md.html#installation) - compile the app rgb2spec using the CMakeList in MRF_DIR/apps/rgb2spec (Used to convert rgb to spectral data when exporting a scene from blender) !!! Tip You can still use the Blender integration without rgb2spec installed, but no rgb data will be converted to spectral data when you export a scene. If you want to render scenes using Malia, refer to it's [installation documention](../doc/apps/malia/main.md.html). You may also want to open the output spectral image after rendering it, for that you will need to install Spectral Viewer and add it to your path. # How to use the MRF integration To use the MRF tools in a Blender scene two simple steps must be completed. First save your scene somewhere on your computer. An unsaved scene doesn't have any name and prevents the MRF tools from working. Then you just have to **load** and **run** the script blender_mrf_ui.py. This will add our MRF tools panel in the Blender UI. You can find this script in **MRF_DIR/tools/blender_mrf_ui.py**. Currently, you will have to **re-run** the script each time you reopen Blender, to set-up the MRF ui in blender. Once you have run the script, when you are in **object mode**, you will see in the **3DView** under the **Tools panel** a 'MRF' tab.
    The MRF Control Panel allows you to export and render a scene from Blender. The exported scene can be found in the same directory than your blender scene under the same name (only the extension differs). Here are its features: - The **Fast Export (no geom.)** checkbox allows you to export everything in the scene except the geometries and their positions. The associated materials will still be exported. - The **Spectral rendering** checkbox allows you to choose if you wanna render the scene in spectral or RGB. It has no impact on the export, we always export both spectral and RGB data. (If you have rgb2spec in MRF_DIR/bin). - The **Interactive rendering** checkbox allows you to display the interactive renderer or the non-interactive renderer. Note that the interactive renderer will open a dedicated window. The non-interactive one will show its advancement in the Blender console. - The **Open viewer after render** checkbox allows you to choose if you want to open the rendered image with SpectralViewer at the end of the rendering. This works only if you have chosen the non-interactive renderer and if SpectralViewer is in your PATH. Note that this option freezes the Blender UI until the rendering is completed. ## Export Materials The following materials are currently exported from Blender to MRF. The last three columns of the table shows you their cuda implementation as well as their support in the Malia renderers.
    Blender | Blender material name | MRF (c++) | OptiX backend cuda file | Malia (RGB) | Malia (Spectral) --------------|---------------------------|-------------|-------------------------|---------------------|--- Diffuse BSDF | | Lambert | lambert.cu | YES | YES Diffuse BSDF (CheckerTexture) | | Checkerboard | lambert.cu | YES | YES | MRF_Normal | Normal | normal.cu | YES | NO | MRF_Tangent | Tangent | tangent.cu | YES | NO Diffuse BSDF | MRF_UV | UV | uv.cu | YES | NO | MRF_Flat | Flat | flat.cu | YES | NO | MRF_ShadowCatcher | ShadowCatcher | shadow_catcher.cu | YES | YES Glossy BSDF (SHARP) | | FresnelMirror | fresnel_mirror.cu | YES | YES Glossy BSDF | | GGX | ggx.cu | YES | YES Glass BSDF (SHARP) | | FresnelGlass | fresnel_glass.cu | YES | YES Glass BSDF (SHARP and THIN) | | FresnelGlass | fresnel_thin_glass.cu | YES | YES Glass BSDF | | _WalterBSDF | | NO | NO Mix Shader (Diffuse and Glossy, no texture) | | PhongNormalized | phong.cu | YES | NO
    Blender | Blender material name | MRF (c++) | OptiX backend cuda file | Malia (RGB) | Malia (Spectral) --------------|---------------------------|-------------|-------------------------|---------------------|--- Diffuse BSDF | | Lambert | lambert.cu | YES | YES Diffuse BSDF (CheckerTexture) | | Checkerboard | lambert.cu | YES | YES | MRF_Normal | Normal | normal.cu | YES | NO | MRF_Tangent | Tangent | tangent.cu | YES | NO Diffuse BSDF | MRF_UV | UV | uv.cu | YES | NO | MRF_Flat | Flat | flat.cu | YES | NO | MRF_ShadowCatcher | ShadowCatcher | shadow_catcher.cu | YES | YES Glossy BSDF (SHARP) | | FresnelMirror | fresnel_mirror.cu | YES | YES Glossy BSDF | | GGX | ggx.cu | YES | YES Glass BSDF (SHARP) | | FresnelGlass | fresnel_glass.cu | YES | YES Glass BSDF (SHARP and THIN) | | FresnelGlass | fresnel_thin_glass.cu | YES | YES Glass BSDF | | _WalterBSDF | | NO | NO Mix Shader (Diffuse and Glossy, no texture) | | PhongNormalized | phong.cu | YES | NO
    !!! Tip Note that the export of textured materials from blender is not yet supported. It will be added in a future version. !!! Tip Note that some materials require to have a specific name in blender to be exported as they do not have any equivalent in Blender Cycles. For instance the Normal material can be exported from blender by setting a name that starts with MRF_Normal. See the "Blender material name" column in the array above. !!! Tip To export a FresnelMirror or a FresnelGlass from blender use the SHARP distribution, see image below. !!! Tip To export a Checkerboard use a CheckerTexture as input color for the Diffuse BSDF, see image below. !!! Tip To export the thin glass attribute of a FresnelGlass or WalterBSDF describe in the [material section](./scene_format.md.html#materials) you just need to add a custom property named 'thin_glass' and set its value to 1. See image below. ## Export Light Sources The following types of light sources are currently exported from Blender to MRF: Blender Light source | MRF (.msf) | MRF (c++) -------------------------|---------------|------------------------- Area | area_light | QuadLight Point | sphere_light | SphereLight Sun | dir_light | DirectionalLight !!! Tip The **radius** of a MRF Sphere light can be controlled using the **Size** parameter of a Point Light in blender, see the image below. !!! WARNING Note that has blender Cycles does not support Sphere Lights, using such lights the MRF Optix Path Tracer render won't match the Blender Cycles render. ## Export Materials/Light sources with spectral data We currently support two mechanism to export material spectral data from blender: - Conversion (from blender RGB value) - Import from file (.spd) The conversion is done automatically as long as you have [rgb2spec](../doc/apps/rgb2spec/rgb2spec.md.html) installed in MRF_DIR/bin. Importing a .spd for a material/light source will disabled the conversion from blender RGB to spectral data for that material/light source. To import a .spd as spectral data, you have to set a specific value to the name of the material/light source. The name must start with MRF_ followed by a relative path to the .spd file. This relative path is relative to different sub folders in the MRF_DIR folder depanding on the material type or light source. The table below shows the different subfolders where the exporter will look to find the .spd you want to export. Blender Material/Light source type | Folder -----------------------------------|------------------------------- Any light source | MRF_DIR/assets/light_sources Diffuse Material | MRF_DIR/data/lambert Glossy Material | MRF_DIR/assets/refractive_index/data Glass material | MRF_DIR/assets/refractive_index/data/ Measured Isotropic | MRF_DIR/assets/measured_materials/ !!! WARNING An exception for this rule is made for the Measured Isotropic material, has it do not have any Blender Cycles equivalent, to export it from blender, is name must start with MRF_measured_isotropic_ !!! Tip The blender file MRF_DIR/assets/scenes/material_export.blend shows some examples of material export. ## MRF patch mechanism Alongside we all the authoring options in blender for a mrf scene presented in the previous sections, another mechanism is available. The patch mechanism, it consists of a .mpf file that you can put alongside your .msf. Using the python script patch_mrf_scene.py (that you can find in MRF_DIR/tools), you can replace some nodes of you .msf scene file. c This is particularly usefull to replace some nodes that cannot be exported from blender, for instance a PhongNormalized material (see [material section](./scene_format.md.html#materials)). Calling this script patch_mrf_scene.py will replace the nodes of your .msf scene file by the ones present in the .mpf patch if they have the same name and type.

    Not all nodes are supported by this mechanism. Here are the currently supported nodes in a .mpf: - background - ext_resources - emittance (emittance nodes contained in the materials node and emittance nodes contained in a light node) - material !!! Tip When you export a scene from blender using the mrf integration, if a .mpf patch with the same name than your scene is present in the destination folder, the patch will be automatically applied at the end of the export. !!! Tip See the material_export.msf in MRF_DIR/assets.scenes for an example of this mechanism. # Matching Blender Cycles render with MRF To compare ouptut images from Blender Cycles and MRF, you need to adjust the color management in Blender. Go to Scene -> Color Management -> Display device, set the value to None (default is sRGB). Once you have done that, the MRF render engine output should match Blender Cycles output. # Limitations of the Blender Bridge The integration with Blender remains minimal; desired improvements include: - Shading network conversion: our current approach is to take the first shader in the network, which limits material complexity; - Full scene graph: the scene graph from Blender is simply flattened for now, which is sufficient for rendering in practice; - Direct access to Blender memory: the Blender scene is currently converted to a .msf file, which hinders performance; - Dynamic scenes: the only motion that we take into account is that of the camera. Some of these limitations can be alleviated by the use of python scripts that work on the .msf file. For instance, textured objects can be obtained by replacing one material in the scene by a MRF Phong model, which handles texturing. Geometric instances may also be declared in this way. However, these are only workarounds, and better solutions should be found in the future.