In this tutorial, we'll see how to use View Layers to obtain masks from objects that, actually, do not need to be rendered, but whose shapes and positions are of interest to us in order to achieve other effects.



Video Transcript

Hello everyone! This is an addendum to my video tutorial on View Layers and Z-Combine, published a few days ago.

In that tutorial, I showed you how to define View Layers in Blender 4.1 to render objects belonging to a scene separately and how to blend them later using the Z-Combine node, thus displaying pixels based on their distance from the camera.

In this tutorial, we'll see how to use View Layers to obtain masks from objects that, actually, do not need to be rendered, but whose shapes and positions are of interest to us in order to achieve other effects.

In the scene I'm using, there are, in particular, three View Layers, each containing an object; specifically, we have an aircraft, a cone representing the exhaust gases, and a mesh object made by some cylinders representing the shock diamonds.

If we render only the View Layer containing the aircraft, we notice that it is rendered against the background of the virtual universe (which was obtained with Nishita Sky), without the exhaust gases and shock diamonds.

The mesh representing the shock diamonds is parented to the cone representing the exhaust gases, which in turn is parented to the aircraft, so these two elements will follow the aircraft in all its movements.

If we render all the View Layers, we get the three separate renderings that are then blended together in Compositing. Let's see how.

Since we are not interested in the actual rendering of these two elements, but rather two black and white masks representing them, let's activate the Object Index Render Pass in the two View Layers containing the objects and provide a numerical index to these two objects in the Relations section of the Object Data tab. It's worth noting that we can also give them the same index, as they are still on two different View Layers, so we can distinguish them without any issues.

In the View Layer tabs of the two View Layers, we also need to activate the Z Render Pass, in order to get the Depth information in Compositing.

Depth information is indeed necessary to blend the various View Layers with the Z-Combine node.

Let's take a look at the Compositing setup I've created to achieve the final rendering, which I showed at the beginning of this tutorial.

On the left side of the setup, we have the inputs.

As you can see, we have three Render Layers nodes, each with its own View Layer. In the two Render Layers dedicated to the exhaust gases and shock diamonds, there are the IndexOB outputs too.

On the right side of the setup, we have the two Z-Combine nodes, which you should be familiar with. In particular, the exhaust gases and shock diamonds are blended first, in this order, and then the result of this blending is passed as Foreground to another Z-Combine node, where the Background is represented by the rendering of the aircraft.

As I mentioned in the basic tutorial on View Layers and Z-Combine, the two inputs of the Z-Combine node are actually distinguished between Background (the first one) and Foreground (the second one), because if the information coming to Foreground is semi-transparent, then the information in the Background node is partially shown as well.

To get only the mask of the two additional objects, without rendering them, we extract only the IndexOB information from their Render Layers nodes, providing this information to ID Mask nodes, where we have to specify the same number we assigned to the objects in their Object Data tabs.

The incoming masks are white on a black background.

To obtain masks on a transparent background, let's provide the ID Mask output to a Set Alpha node, connecting the mask to both inputs: this way, the black part of the mask will be rendered as transparent.

Then there are the nodes that allow us to implement the glows as we desire, but in this case, it's up to you to use the Compositing nodes and parameters to achieve the desired effect: I can only provide some guidance on those I used to show the final rendering here, but these indications are by no means "binding"!

The node setup for the shock diamonds is the simplest because the mask is simply blurred with a Blur node and its brightness modified using an RGB Curves node.

Inside the RGB Curves node, I also adjusted the B curve to give a slightly bluish tone to the final image.

The node setup for the exhaust gases is slightly more complicated because I wanted to obtain only the outline of the cone representing the exhaust gases.

To achieve this outline, I subtracted from the mask a narrowed version of it, obtained using a Dilate Erode node with a negative value.

On using the Dilate Erode node to obtain only the outlines of a mask, I made a video tutorial some time ago, called "Glowing Edges," which I recommend you watch if you haven't already, as it contains some insights that might interest you.

Anyway, I then blurred the mask, changed its brightness and color using an RGB Curves node (in this case, modifying the R curve, but it's a personal choice), and added an additional glow using a Glare node in Fog Glow mode.

Since they are 3D objects, exhaust gases and shock diamonds will always follow the aircraft; in Compositing, you can modify their intensity and appearance as you like; finally, by setting up the Z-Combine nodes in this way, they will be rendered correctly in every frame, i.e., without being superimposed on the aircraft.

Well, that's all for this tutorial! I hope it can be helpful to you! See you soon!

Search Tutorials

Enter a phrase or multiple comma-separated keywords to search.

This is a personal website and does not constitute a sales channel. The pages dedicated to 3D models document a selection of my work and do not contain offers, prices, purchasing procedures, or commercial links. I am not currently accepting requests for custom work, consulting, or other professional collaborations.


EXTENDED PRIVACY AND COOKIE USAGE POLICY