When attempting to link the mist pass output of a Render Layer node to the input image content of an Output File node, I found that no matter how I tried to connect the mist pass output, nothing would attach to it via the Python API. Manually, through the Blender GUI I could link the two fine, and get results as expected. The code to generate these nodes is as follows:

## Link shaders
tl = bpy.context.scene.node_tree.links

# Link raw image render layer to switch
tl.new(n_image_rl.outputs[0], n_switch.inputs[0])
# Link depth from raw image to depth file output
tl.new(n_image_rl.outputs[3], n_depth_out.inputs[0])
# Link image segment render layer
tl.new(n_img_seg_rl.outputs[0], n_alpha.inputs[1])
# Link field segment render layer
tl.new(n_field_seg_rl.outputs[0], n_col_key.inputs[0])
# Link color key node
tl.new(n_col_key.outputs[0], n_mix.inputs[1])
tl.new(n_col_key.outputs[1], n_mix.inputs[0])
# Link mix to alpha
tl.new(n_mix.outputs[0], n_alpha.inputs[2])
# Link alpha to switch
tl.new(n_alpha.outputs[0], n_switch.inputs[1])
# Link switch to composite output
tl.new(n_switch.outputs[0], n_comp.inputs[0])

This is the node linking received when the script was run, from within the Compositing Nodes window:

Incorrect node listing for Python script.

Any advice on how to resolve this issue would be appreciated!


It's weird. Might be a bug. It does not work with the output specified by it's index, but if I name the output, it works correctly. Try using:

tl.new(n_image_rl.outputs['Mist'], n_depth_out.inputs[0])

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.