This is a step to step guide on how to setup and use the Custom stencil to support DMP workflow when rendering from Unreal in an easy way from Post Processing Volume
Introduction
- It is essential in our design process to maintain organization by categorizing and separating elements into sublevels from the start of the project.
- For instance, elements inside our general "Dress Level" such as trees, bushes, lamp posts, people, and tables should each be grouped separately in a corresponding sublevel.
This approach will enable us to hide during rendering specific sublevels, and render elements independently, thereby ensuring a more efficient and streamlined workflow.
Overview
- For better mask results, we will turn off our lighting levels.
No lighting will be applied, resulting in a black background that allows us to focus on the elements to be masked and will bring a cleaner mask edge. You'll also want to check "ExponentialHeightFog" is turned off.
Required Settings
Before starting, make sure that you have set Custom Depth - Stencil Rendering to : "Enabled with Stencil"
You'll also want to uncheck "Custom Depth Taa Jitter". This will help somewhat with the jitter edges of the custom stencil mask that can occur.
Setting up the scene
Let's say we have our material created and our scene set up with multiple sublevels.
- We will need to apply a PostProcessMaterial to the PostProcessVolume within the Rendering Features.
- By toggling the value of "Array = 0" / "Array = 1," we can easily activate or deactivate the visibility of our IDs in the viewport.
(I will explain the material composition for PPM_CustomStencil_MASTER below.)
Remember to turn off your lighting levels and the ExponentialHeightFog
some blueprints may contain lights
Setting up the number ID inside the Mesh/ Blueprint
Don´t apply the number ID individually on scene
To ensure consistency when rendering multiple scenes, it is important to set up the number ID inside the blueprint, not on the individual mesh within the scene, as shown above. Setting the number ID inside the blueprint will also reduce production time.
Make sure Render in Depth Pass and CustomDepth Pass is checked
In this case, PPM_CustomStencil_MASTER Material has been set with 6 different ID colours. Utilizing a Master Material with a wide range of IDs is highly advantageous.
When a blueprint contains multiple meshes, it is crucial to assign a separate number ID to the foliage for future DMP adjustments. For example, if we have a table with chairs, all these elements can share the same number ID, as demonstrated in the example of the lamp post below.
The Postprocess Material
Make a basic postprocess material, and leave its Blendable Location set to "After Tonemapping".
Nodes:
Then, create two Scene Texture nodes as:
- PostProcessInput0 - the tonemapped final pixel
- CustomStencil - we'll use this for our mask
The Mask and Mask Inputs
______________________________________________________________
Breakdown
______________________________________________________________
Multiples IDs
Limitations
- There are, of course, limitations to this technique. Perhaps most apparent is that if this technique is used with either Temporal Anti-aliasing (TAA) or Temporal Super Resolution (TSR), then the edges of our mask will jitter slightly as the temporal jittering shifts the screen around ever so slightly.
Animated Elements ID
DMP is not limited to a single still image; we frequently work on projects involving animated characters or elements within a composition. This technique is also highly effective for creating an alpha sequence without relying on costly in-engine tools such as layers.
- Simply set the animated element to a number ID color of white against a black background.
- With this technique, if the animation remains the same but the materials of the character or elements change, there is no need to render the sequence again as we will apply the alpha in post-composition. Instead, we generate two separate render sequences: one with all the lighting and another that serves as our separate alpha in black and white.
I hope you can find any of this blog post useful, and come up with something beautiful.
- Monica Garcia -

































