# How to enable Intel denoiser using python?

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')
# XXX: find outputs by name
# XXX: use "Noisy Image" output (31) rather than "Image" (0)?


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?

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

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