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:
register_pass(scene=None, srl=None, name="", channels=1, chanid="", type='VALUE')
add_pass(name, channels, chan_id, layer="")
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.
Cycles implements the
update_render_passes method: https://github.com/dfelinto/blender/blob/1d33843ea6b128242183bb31804474019c606a9d/intern/cycles/blender/addon/init.py#L105
But I could not find out how or when this method is ever called. When I implement this method in my addon, it is never called.
In this implementation, it uses the
register_pass method: https://github.com/dfelinto/blender/blob/1d33843ea6b128242183bb31804474019c606a9d/intern/cycles/blender/addon/engine.py#L209
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:
Cache file /home/queryxchang/public_html/apps/frontend/config/../cache/-q-16-100791-how-to-use-the-new-render-pass-api-for-an-external-renderer- could not be written