Render setup

This example covers how to deal with RenderPass, Layers, AOVS and tweaking rendering attributes

Add a RenderPass

with Modifier() as mod:
        rp = mod.createnode('NewRenderPass', type='RenderPass')
        rpl = mod.createnode('bg', type='RenderLayer', parent=rp)

Add a Layer

Let’s a two layers to our new render pass

with Modifier() as mod:
    rplo1 = mod.createnode('output1', type='LayerOut', parent=rpl)
    rplo1.PlugName.set('Diffuse')
    rplo2 = mod.createnode('output2', type='LayerOut', parent=rpl)
    rplo2.PlugName.set('Specular')

Note

LayerOut name should always be outputN (where N is an integer)

Special Layers

Here we will add 3 special layers: Z, Occlusion and Id

with Modifier() as mod:

    # Occlusion
    rploOcc = mod.createnode('output3', type='LayerOut', parent=rpl)
    rploOcc.PlugName.set('Occlusion')
    occNode = rp.loadfile('$(LIBRARY)/nodes/raytracing/occlusion.gnode')
    rploOcc.Plug.adddependency(occNode[0].Output1.Plug)

    # Z
    rploZ = mod.createnode('output4', type='LayerOut', parent=rpl)
    rploZ.PlugName.set('Z')
    # inputNode will be of type ShaderNodeInput
    inputNode = rp.loadfile('$(LIBRARY)/nodes/input/input.gnode')
    inputNode[0].Mode.set('Depth')
    rploZ.Plug.adddependency(inputNode[0].Output1.Plug)

    # Id
    rploZ = mod.createnode('output5', type='LayerOut', parent=rpl)
    rploZ.PlugName.set('Id')

Note

to use the id pass, don’t forget to add either a dynamic color Plug (named Id) on your geometry nodes or a MaterialOverride in your RenderGraph.

Change render attributes

with Modifier() as mod:

    rp.Hider.set('Raytrace')
    rp.BrdfSamples.set(64)
    # Widht, Height and AspectRation are connected by default
    rp.Width.disconnectall()
    rp.Height.disconnectall()
    rp.AspectRatio.disconnectall()
    rp.Width.set(640); rp.Height.set(480)

Going further