This is the second and last of two tutorials, made with Blender 3.6, in which we will examine the Sun Beams node to simulate light scattering in the air in Post-Production, after rendering, without resorting to Volume shaders or other elements in the scene.
Video Transcript
Hello everyone! This is the second and last of two tutorials, made with Blender 3.6, in which we will examine the Sun Beams node to simulate light scattering in the air in Post-Production, after rendering, without resorting to Volume shaders or other elements in the scene.
As I told you in the previous tutorial, we should not call it Volumetric Light, because it's just a Compositing effect.
In this tutorial, in particular, we will see how to apply the effect to the light passing through windows (i.e., through a semitransparent material), how to soften the edges of the light rays, how to exclude some areas of the rendering that we are not interested in, and how to further modify the light rays with Color Balance and other effects.
If the scene I'm using in this tutorial seems familiar to you, maybe it's because I used it in a tutorial previously published on the channel, where I showed how to achieve true volumetric lighting using the Volume Scatter node on the World Output, but limited to the areas framed by the camera.
That result was quite interesting... so, why resort to Compositing to try to reproduce it? The answer is very simple: full volumetric lighting is computationally expensive and needs to be recalculated for each frame, so in some cases, it's better to use a post-production effect.
In this case, therefore, I haven't added anything to the Volume input of the World Shader, and what you see on the screen is the rendering obtained without any Compositing effect.

We want to limit the Sun Beams effect to only the light entering through the windows. However, in this case, we cannot use the Environment Render Pass, as seen in the previous tutorial, because the light passing through the windows is considered Transmission Indirect.

So, let's activate the Transmission Indirect checkbox in the View Layer tab of the Properties editor and start the rendering again, so that we can use this information in post-production. Let's take a look at the mask obtained from the Transmission Indirect information.

To get a uniformly white mask in the areas of interest, let's connect Transmission Indirect to a Math node in Ceil mode, which will round to 1 all the values which are greater than 0, turning those pixels to white, just as we desire.

We immediately notice that the windows are ok, but there are also other elements that should not participate in emitting the Sun Beams, such as the cabinet doors, the glass of the wall clock, and the ceiling lamp cases.
To exclude these elements from the mask obtained with Transmission Indirect, let's insert two Box Mask nodes in the editor, in Add mode, resizing and positioning them to cover the areas we are not interested in.

To connect the two nodes in cascade, in addition to setting them in additive mode, we need to connect the Mask output of the first node to the Mask input of the second node.
The mask obtained in this way is white, but we want to exclude these areas from the result coming from the Ceil node.
Therefore, we need to connect a Color Invert node to the output of the second Mask node.
Then, we need to multiply the output of the Color Invert node with the output of the Ceil node, either using a Color Mix node in Multiply mode or using a Math node in Multiply mode.
In this way, we will make the areas we're not interested in black, limiting the mask to the windows only.

Now, we can insert a Sun Beams node at the output of the Multiply node, placing it and adjusting its rays as desired.
To overlay the rays onto the original image, we use a Color Mix node in Add mode, as seen in the previous tutorial.

However, now the light rays have a too well-defined perimeter at the top, and they are completely white.
To blur the edges a bit, let's insert a Filter Blur node, with settings of your choice, between the Sun Beams and Color Mix Add nodes.

To change the color of the rays, we can use various compositing nodes or techniques.
The simplest method involves connecting a Color Balance node between the Blur node and the final Color Mix Add node, then adjusting the colors until we achieve the desired result.

To analyze the rendering with and without this effect, select the final Color Mix Add node and press the M key many times to include or exclude the effect.
As mentioned several times, and in the previous tutorial too, the light rays obtained in this way are a post-production trick, not true volumetric lighting.
The difference with the rendering obtained using Volume Scatter is evident, especially in the shadows cast by objects encountered by the light rays in their path, so this technique may not be suitable for all kinds of scenes.
The advantages of using Sun Beams over Volume Scatter lie in significantly faster rendering times and greater ease of tuning.
In the Compositing process, it's easier to modify the parameters of the setup and visualize changes almost in real-time.
Moreover, with Compositing, you can experiment with various blending modes.

Well, that's all for this second and last tutorial on the basics of the Sun Beams node! I hope it has been helpful to you! See you soon!