1
$\begingroup$

I'm creating a scene from scratch in blender (2.83+) using python, and I'd like to turn on Intel denoiser for the Cycles render output.

I've got some code but it's not working yet:

  bpy.context.view_layer.cycles.denoising_store_passes = True
  bpy.context.scene.use_nodes = True

  tree = bpy.context.scene.node_tree # inputs, outputs, nodes, links
  comp = tree.nodes[0]               # result goes into here
  render = tree.nodes[1]             # render layers: images come from here
  denoise_node = tree.nodes.new(type='CompositorNodeDenoise')
  # Link it in:
  links = tree.links
  # links.new(output ---> input)
  link = links.new(denoise_node.outputs[0], comp.inputs[0])
  # XXX: find outputs by name
  # XXX: use "Noisy Image" output (31) rather than "Image" (0)?
  link = links.new(render.outputs[0], denoise_node.inputs[0]) # Image
  link = links.new(render.outputs[32], denoise_node.inputs[1]) # Denoising Normal
  link = links.new(render.outputs[33], denoise_node.inputs[2]) # Denoising Albedo

The problem is that even though I've enabled bpy.context.view_layer.cycles.denoising_store_passes = True it doesn't seem to have taken effect by the time the rest of my code runs; the render node still only has 31 outputs. It should have 39.

Anyone know how I can wait for that setting to take effect before continuing?

$\endgroup$
  • $\begingroup$ I tried adding bpy.context.view_layer.update() but that doesn't help. $\endgroup$ – GaryO May 4 '20 at 18:41
  • $\begingroup$ And I tried render.update() -- also no effect. $\endgroup$ – GaryO May 4 '20 at 21:29
1
$\begingroup$

I don't think the problem is with the setting not taking effect. I think the node is there, you just need to reference it by name instead of index since the numbers you are using aren't working.

This should fix it:

link = links.new(render.outputs['Denoising Normal'], denoise_node.inputs[1]) # Denoising Normal
link = links.new(render.outputs['Denoising Albedo'], denoise_node.inputs[2]) # Denoising Albedo

There is a plugin on GitHub that does this: blender_instant_denoise. That's where I found the answer.

$\endgroup$

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.