Mask Rendering and Operation filter tutorial


The goal of this tutorial is to understand how to use the mask rendering and the operation filter .

Mask rendering is about to hide specific parts of the sensor in order to focus the rendering on other parts of the scene. The advantages of this process are the following:

  • Compute only once the parts of the image that will never change

  • Reduce substantially the rendering process time of the changing materials by focusing only on these materials

This tutorial will use the metal_colorcheck scene that is available here: metal_colorcheck.ocbin


Mask Rendering

Open a the “metal_colorcheck.ocbin” scene in Ocean.

Start a rendering.


The goal is to compute a rendering on all the scene (environment) except on the mirror and the ball (sample). To do so, we need to set a mask that let the all the rays go the sensor where we see the environment.

The mask can be set in the instrument node. In the Object panel, click on the “default” node.


We can see a child node “binarymask” in the instrument node. This is the node that will contain the mask that will be applied to the sensor.

Now, we click on the “binarymask” node and change its type to Linked and the target to “metal_colorcheck_BN”.


When using mask rendering, it is strongly advised to change the PixelFilter parameter of the instrument to “Box”. If not set correctly, the composition of images that will be done later with the operation filter might not be correct.

We can then start the rendering and wait for it to reach the halt condition.


We have now been able to compute a first rendering applying a mask. We need to save the render image for a later step.


To save the image, we select the Simulation menu and click on “Save Raw”. We have to select the EXR file format and save the file under the name “scene_raw.exr”.

Next, we can do the same procedure by clicking on “Save Filtered” and saving the file under the name “scene_filtered.exr”.

The file we just created can be described as below:

  • scene_raw.exr: file containing the pixel values before application of all the Ocean filters defined in the scene

  • scene_filtered.exr: file containing the pixel values after application of all the Ocean filters in the scene

Operation Filter


We can go back to the instrument node and change the mask target to “metal_colorcheck_NB”. We now have the opposite of what was rendered in the previous section and we get and image containing only the sample.


We want to add the environment without having to re-render it again and, to do so, we need to create a new post-processing filter. We need to click on the empty filter called “filter4”.

Once we clicked on it, we see a new panel and we can change the type of filter from empty to “Operation”.


The defaut operation type is “Addition”. This will add an input image to the currently rendered image. We need to select this input image. This image will actually be one of the file created in the Mask Rendering section. Let’s use the “scene_filtered.exr” for a first example.


To add it, we must click on on the image node associated with the Operation filter. Once clicked, the panel on the right changes and display the image parameters. We first change the type to “External File” and select the path of the “scene_filtered.exr” and apply the changes. Then, start the rendering and wait for it to reach the halt condition.


We have now been able to compute a rendering using Operation filter!


It must be noted that, in the example above, we put the operation filter as the last filter. It means the addition of the image will be applied on the buffer image after application of the three other filters. This is why we used the “scene_filtered.exr” file. However, if the operation filter was the first filter, we would have noticed a bad composition of image since the part of the image containing the sample would be unfiltered and the environment would be filtered. A correct use of the filter as a first filter in the list would imply to use the “scene_raw.exr” file instead. The combination of the position of the filter in the list and the input image is important.


We can now change the material of the sample by going in the Library panel, selecting a material and applying it on the sample.

../../_images/mask_ope_tuto_11.png ../../_images/mask_ope_tuto_12.png

In the examples on the right, we went in the Ocean libraries and chose two other materials:

  • ocean-metals/Au-mirror

  • ocean-building-glass/green-sheet-10mm

Each time, the rendering was only applied on the part of the sensor determined by the mask and the environment was added with the operation filter.


This is it! You may try other binary masks and other operation filters, and read the Reference manual

Don’t hesitate to contact us for more help in testing the software.