Mask Rendering and Image Composition: optimizing your rendering

Mask Rendering and Image Composition: optimizing your rendering

by Pierre Le Nost



OceanTM offers many tools to visualize and apply post-processing to renders of 3D scenes . In many process pipelines, the main goal is to create an object of interest  (OOI) to be rendered, position it in its environment and finally to iterate through many settings to determine one or more working material types .

In any project, there is a certain part of the render image that will not change between each rendering process. This area, that we will call the environment, consists in everything that is not the OOI, or that is not impacted by it. To this date, we had to re-render the environment after each change in the setting of the OOI.

OceanTM 2020 offers the ability to compute only once on areas of the render that never change and, thus, to greatly improve the overall time spent on a project. This method is called mask rendering and we will learn about the concept of this technique as well as show concrete .


Mask Rendering

In image processing, any binary image used as mask is also known as spatial filtering.

Figure 1 – Representation of mask rendering; (left) normal render of the scene, (middle) binary mask, (right) combination of both

Image composition

Image composition is a process of combining two sources into a single image to create the illusion that they come from the same source. This is exactly why mask rendering is needed for.

Figure 2 – Representation of image composition; (left) environment render image computed once, (middle) render image of the OOI computed for each setting, (right) combination of both

A first rendering of the scene containing only the environment will give a base for the image composition that will be computed once. This rendering of the environment will be done with mask rendering. Then, the invert of the mask will be used to render only the object of interest. In post-processing, the addition of the image of the first scene will be added to the current render image the composited image.

In Figure 2, we chose to use this example to illustrate image composition that can be done on this render images. In this case, the OOI and the environment interact in important ways, therefore the result of compositing may be biased.


As seen previously, we can focus on the OOI by rendering the scene only on specific areas instead of on the whole image. In this section, we will showcase the usage of mask rendering as well as the possibilities of optimizations.

In this example, we will take a building in an urban environment. Let’s say, the main object of interest is  the building itself, and the goal is to determine what material is the most suitable for the client.

Figure 3 – Example scene. Object of interested circled in yellow

The first step is to create the binary masks: one mask containing the building and the other one is the opposite of the first one (thus, the environment).

Figure 4 – Illustration of the binary masks used in example scene. Left: mask for building. Right: mask for environment.

When analysing the mask, we observe that the building selection corresponds to 21% of the image. In other words, in this example, 79%  of the image when doing a classic rendering. In Figure 5, we can see the rendering image after applying each mask separately

Figure 5 – Rendering of the scene. Left: using building mask. Middle: using environment mask. Bottom: combination of both.

Table 1 shows an example of time measured on a given configuration  of computer (not dedicated to production) for a rendering with a halt condition at 500 spp (production halt condition should be 2000 spp).

Tableau 2

Table 1 – Relative time gain to process the rendering of  environment only and building only compared to the rendering of the whole scene (classic rendering)

The environment only is quicker to be computed and have a time gain of 36% while the building only has a time gain of 17% compared to the classic rendering. We notice there is no correlation between the time gain and the space occupied by the building and environment.

In this example scene, the materials used in the environment area and the ones used in the building area may differ and sometimes have important differences in their complexity. The time to render multiple glass materials will not be the same than rendering a texture on the grass.

Also, we need to consider the loading of the scene which is identical whatever the size of the binary mask selected. It can be represented as a debt that will be resorbed with the time gain by the mask rendering when computing multiple rendering of the building only, such as represented in Figure 6.

In this figure, we can clearly see that the net gain in time starts at the third rendering of the building. In addition, we can see that if we do hundred renderings of the building  to change the glazing, we will have gain more than 25 classic computation times.

| Figure 6 | Representation of the cumulated time taken to render the scenes after multiple renderings. In example scene, gain starts at render #3

Figure 6 – Representation of the cumulated time taken to render the scenes after multiple renderings. In example scene, gain starts at render #3

To summarize, time gain will not be the same for each project. As we have seen, it will vary in function of:

. The area taken by the OOI in the final render

. The material types used in the OOI

. The Ocean scene loading time

Figure 7 – The smaller the area to be re-rendered, the better the time performance will be when rendering the material(s) of interest multiple times. Gain will be highest in top left image and  lowest in bottom image.


We have seen the mask rendering process consists in two main steps: the rendering of the environment and then rendering of the OOI. It is a tool that can be powerful in cases where repeatability of rendering the OOI is high and it can reduce the processing time greatly.

In this article, we illustrated the mask rendering on a simple case. Virtual prototyping needs a lot of iterations when testing material types and, thus, takes a lot of time in a project pipeline. Even though not all scenes could benefit from this technique, it could save time further down the road in the project pipeline.