4
$\begingroup$

I am developing an addon for an external renderer and want to register custom render passes. Last time I implemented this feature I had to resort to images because Blender only had hardcoded render passes.

Nowadays the RenderEngine class offers several methods that seem to allow the registration of custom passes:

However, I could not find any explanation or examples of how to use these methods. Looking at the Cycles source code also did not help much.

Where I currently am

I have managed to add a custom pass with the following code, which is currently executed in the constructor of my RenderEngine implementation: self.add_pass("Samplecount", 1, "X") It shows up in the image editor:

enter image description here

Problems/Questions

  • The custom pass is always available in the image editor dropdown, even if it is not used in the current rendering
  • It seems there is no method to remove or unregister a custom pass - how does Cycles do this?
  • The custom pass does not show up in the compositor:

    enter image description here
$\endgroup$

1 Answer 1

3
$\begingroup$

Thanks to brecht's explanation in IRC I can now answer my own question:

Custom passes in compositor

update_render_passes is called by the compositor to display the custom passes as output sockets. In this method, register_pass should be used.

Example:

def update_render_passes(self, scene=None, renderlayer=None):
    self.register_pass(scene, renderlayer, "Combined", 4, "RGBA", 'COLOR')

    aovs = scene.luxcore.aovs

    if aovs.samplecount:
        self.register_pass(scene, renderlayer, "Samplecount", 1, "X", 'VALUE')
    if aovs.shading_normal:
        self.register_pass(scene, renderlayer, "Shading_Normal", 3, "XYZ", 'VECTOR')

Custom passes in image editor

add_pass on the other hand should be called at the start of the render method to add custom passes (before writing data into a render_result).

Example:

# Note: the Depth pass is already added by Blender
# If you add it again, it won't be displayed correctly 
# in the "Depth" view mode of the "Combined" pass
# in the image editor.

aovs = scene.luxcore.aovs

if aovs.samplecount:
    self.add_pass("Samplecount", 1, "X")
if aovs.shading_normal:
    self.add_pass("Shading_Normal", 3, "XYZ")

I hope this helps other developers of addons for external render engines.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .