Apply Convolution2DPass to individual renderers

Hi there, I’ve been trying to figure this out for a few days but so far haven’t come up with an answer.

I’m following the example here for how to apply Convolution2DPasses:

The example applies the passes directly to a view as per this snippet:

const view = renderWindow.getViews()[0];
...
view.setRenderPasses([renderPass]);
  renderWindow.render();

However I have multiple renderers in a scene which are all affected, such as an Orientation Cube. Ideally I’d like to be able to target the pass to a single renderer. Even with looking at the source code I don’t seem to be able to find a hook that works though.

Any help would be greatly appreciated thank you :slight_smile:

Hello!
Render passes are given to the render window (the view)
The render window contains renderers, so the render pass can filter the right renderers
For example in the vtkForwardPass, the traverse function iterates over all renderers:

const renderers = viewNode.getRenderable().getRenderersByReference();

You could select the right renderer or exclude some renderers instead of iterating on all renderers?

1 Like

Hi @Thibault_Bruyere, thank you for responding so quickly! :slight_smile:

Eventually fixed it up by extending the vtkForwardPass twice and modifying the renderers/layers to focus each pass where I wanted it to apply. Then just put each pass on the view in sequence. Worked a treat, thank you again!

let pass0: Conv2DPass = renderer0Only.newInstance()
        let pass1: Conv2DPass = renderer0Plus.newInstance()

        if (state.conv != null) {
            if (state.conv.gaussianBlur)
                pass0 = applyPass(gaussianBlurPass, pass0)
            pass0 = applyPass(getMaskPass(state.conv.enhancement), pass0)
        }

        this.view.setRenderPasses([pass0, pass1])
1 Like