vtkOutlineGlowPass in multiview

Hello,

I’m using Activz (vtk c#). I have a multiview following the example https://kitware.github.io/vtk-examples/site/Cxx/Visualization/MultipleViewports/ and the main viewport has a glow effect following the example https://kitware.github.io/vtk-examples/site/Cxx/Rendering/OutlineGlowPass/

If there is just a render, the glow effect works fine on camera rotation. If I add multiple views, I have an issue with the main viewport and glow effect.

Here is some code

// RenderWindowControl view;

var lightKit = vtkLightKit.New();

var xmins = new double[4] { 0, .5, 0, .5 };
var xmaxs = new double[4] { 0.5, 1, 0.5, 1 };
var ymins = new double[4] { 0, 0, .5, .5 };
var ymaxs = new double[4] { 0.5, 0.5, 1, 1 };

var colors = new Color[4] { App.Preferences.Window3DColor, Color.DarkGray, Color.DarkSlateGray, Color.Indigo };

var renderWindow = view.RenderWindow;
renderWindow.SetAlphaBitPlanes(1);
renderWindow.SetMultiSamples(3);

var renderer0 = renderWindow.GetRenderers().GetFirstRenderer();

for (int i = 0; i < 4; i++)
{
    double[] c1 = Utility.ColorToDouble(colors[i]);

    var renderer = i != 0 ? vtkRenderer.New(): renderWindow.GetRenderers().GetFirstRenderer();

    renderer.GetActiveCamera().ParallelProjectionOn();
    renderer.SetOcclusionRatio(0.0);
    renderer.SetMaximumNumberOfPeels(100);
    renderer.SetUseDepthPeeling(1);
    renderer.SetUseHiddenLineRemoval(1);
    renderer.SetBackground(c1[0], c1[1], c1[2]);
    renderer.SetViewport(xmins[i], ymins[i], xmaxs[i], ymaxs[i]);

    lightKit.AddLightsToRenderer(renderer);

    if (i != 0)
    {
    renderWindow.AddRenderer(renderer);

        var sphere = new Sphere();
        sphere.Create(0, 0, 0);
        renderer.AddActor(sphere.Actor);
        renderer.ResetCamera();
    }
}
            
var basicPasses = vtkRenderStepsPass.New();
var glowPass = vtkOutlineGlowPass.New();
glowPass.SetDelegatePass(basicPasses);
glowPass.SetOutlineIntensity(2.5f);

var outlineRender = vtkRenderer.New();
outlineRender.SetViewport(xmins[0], ymins[0], xmaxs[0], ymaxs[0]);
outlineRender.InteractiveOff();
outlineRender.SetLayer(1);
outlineRender.SetPass(glowPass);
outlineRender.SetActiveCamera(renderer0.GetActiveCamera());

renderWindow.SetNumberOfLayers(2);
renderWindow.AddRenderer(outlineRender);

Any idea?

Thank you.

Is this a VTK bug? Thank you. @LucasGandel

Indeed, it looks like the depth/color buffers are not cleared for the outline renderer. In addition, the outline is always rendered on the bottom left even if you set different viewport values. I don’t think such render passes support multiple viewports, but it should not be too hard to fix.

In the meantime, adding an extra vtkCameraPass as delegate should fix the depth/color issue:

    var cameraPass = vtkCameraPass.New();
    cameraPass.SetDelegatePass(glowPass);
   ...
    outlineRender.SetPass(cameraPass);

Thank you, Lucas, for your suggestion, but adding an extra delegate does not fix the issue.

Interesting, I tried it again with 9.1 and 9.2 and both work fine when adding an extra camera pass and making sure the viewport is (0, 0, 0.5, 0.5) for the renderer in overlay. But I confirm any other viewport values and render pass setup fails as described.

Thank you, Lucas. Indeed in my official application, I use the lower-right viewport. Do you think this bug could be fixed in a future release?

As this is a very specific use case, I don’t think this will be addressed unless someone provides funding for it. But I think it should not be too hard too fix, so you might want to open a new issue on the vtk repository in case someone wants to address it.