4
$\begingroup$

Hi lovely Blender community,

I mostly work on larger environment scenes in which depth plays a decisive role. Now there are several methods to get this, either you render volumes (which unfortunately increase the rendering time drastically) or you use the mist or depth past in post work. Now I asked myself whether it isn't possible to put the mist pass in the live render viewport over the beauty pass, so that you can see live how the mist pass affects the entire scene without having to do this first in the post work. Actually this should be possible with a blend effect, since you can also look at all individual passes live in the render viewport. I am grateful for your answers!

$\endgroup$
1
  • $\begingroup$ Sounds interesting, though I’m not aware of it. I think it might be kind of nice if you could actually just activate the compositor to work on the view port, but I’m not sure if that would work. $\endgroup$
    – TheLabCat
    Nov 11 '21 at 14:23
2
$\begingroup$

It was initially planned for the 2.9 series but was postponed.

enter image description here

Apparently it is planned in one of the next versions for Eevee, but no ETA.

https://code.blender.org/2021/10/blender-3-x-roadmap/ (Navigate to Eevee section)

I guess it will be part of the general Eevee refactor but it's hard to predict when it will be out or how it will be used.

$\endgroup$
2
  • $\begingroup$ Coolio, can't wait for that feature :D $\endgroup$
    – HISEROD
    Nov 12 '21 at 9:30
  • $\begingroup$ Thanks for give us the information! Hope to see it soon. Would be great for early lookdev. $\endgroup$
    – MarvCG
    Nov 12 '21 at 23:10
2
$\begingroup$

Currently, the only way to get the mist pass to be included in the combined pass, that I can conceive, is to create a mist node group and add it to every material.

Node Group

I have tested the following node group with refraction, transparency, and volumetrics with fair results at low densities for everything except Eevee's volumes:
1

The Multiply node (just to the right of the Mix node) is the density control.
Color and intensity can be controlled via the Emission node.

To use the node group, simply insert it right before the Surface output.
2

For Cycles volumes, be sure to insert a Transparent BSDF as shown.
3

This node group also works for the World material.


Script

I have also made a crude script to add the mist node to all materials in the current scene which do not already contain the node group.

import bpy

for ob in bpy.context.scene.objects:
    if ob.type not in ('MESH', 'META', 'CURVE', 'SURFACE', 'FONT', 'VOLUME'):
        continue
    for slot in ob.material_slots:
        main_tree = slot.material.node_tree
        mist_in_tree = False
        
        for node in main_tree.nodes:
            if node.bl_idname == 'ShaderNodeGroup':
                if node.node_tree == bpy.data.node_groups['Mist']:
                    mist_in_tree = True
                    break
        
        if mist_in_tree:
            continue
        
        link = main_tree.get_output_node('ALL').inputs[0].links[0]
        
        mist = main_tree.nodes.new('ShaderNodeGroup')
        mist.node_tree = bpy.data.node_groups['Mist']
        mist.location = 0.5 * link.from_node.location + 0.5 * link.to_node.location
        
        main_tree.links.new(link.from_socket, mist.inputs[0])
        main_tree.links.new(mist.outputs[0], link.to_socket)

$\endgroup$
1
  • 1
    $\begingroup$ Thank you so much for taking the time and for showing the nodes! Hope this will be implemented in Blender someday.. Exactly this example is what I was looking for.. $\endgroup$
    – MarvCG
    Nov 12 '21 at 23:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.