SSAO peculiar effect with translucent geometry

So I’m experiencing an issue utilizing the VTK SSAO pass whilst having translucent geometry within a scene. I’ve been utilizing the default renderer until recently but had to switch because as far as I know in order to use SSAOPass you need a delegate pass for the pass to feed on from and don’t know a method to get the current pass for a renderer.

I initially used the standard basic pass but even when setting depth peeling to true translucent geometry was being rendered behind opaque ones. Adding a specific depth pass with a translucent pass into a render sequence pass seems to produce the right render when SSAO is disabled:

However when SSAO is enabled I get something pretty peculiar, specific actors in the scene get colored in black, green, yellow & red depending on their screen-space quadrant and the Ambient Occlusion fails to be added.

The odd rendering is accompanied by the following warning message:

[        E1EB9740]     vtkOpenGLState.cxx:655   WARN| Attempt to set draw buffers from a Framebuffer Object that is not bound.

Switching from vtkDualDepthPeelingPass() to vtkDepthPeelingPass() prevents the odd coloring however the SSAO pass still fails and presents the same warning.

If the translucent object is obscured in the scene the ambient occlusion works absolutely fine.

I’ve included an excerpt of the rendering code, hopefully it isn’t too different to what people are used to:

        basicPasses = vtk.vtkRenderStepsPass()
        translucentpass = vtk.vtkTranslucentPass()
        volumepass = vtk.vtkVolumetricPass()
        depthpass = vtk.vtkDualDepthPeelingPass()
        depthpass.SetTranslucentPass(translucentpass)

        passes = vtk.vtkRenderPassCollection()
        passes.AddItem(basicPasses)
        passes.AddItem(translucentpass)
        passes.AddItem(volumepass)
        passes.AddItem(depthpass) # can be commented to disable DP


        seq = vtk.vtkSequencePass()
        seq.SetPasses(passes)

        ssao = vtk.vtkSSAOPass()
        ssao.SetRadius(30)
        ssao.SetDelegatePass(seq)
        ssao.SetBias(0.1)
        ssao.SetBlur(True)
        ssao.SetKernelSize(32)



        ren.SetPass(ssao) # can be set to seq to ignore SSAO


        ren.SetUseDepthPeeling(True)
        ren.SetOcclusionRatio(0.2)
        ren.SetMaximumNumberOfPeels(100)

I don’t know if there’s anything specific I’m missing here with respect to the order of multipass renders, this seems to work fine for either translucent actors or opaque actors with SSAO but doesnt when both are used.

The odd color behavior is related to an internal color buffer that you are not supposed to see.
Note that you will be able to enable SSAO without render passes in VTK 9.1.

In the mean time, you can try something equivalent to F3D render passes:

    lightsP = vtk.vtkLightsPass()
    opaqueP = vtk.vtkOpaquePass()
    translucentP = vtk.vtkTranslucentPass()
    volumeP  = vtk.vtkVolumetricPass()

    collection = vtk.vtkRenderPassCollection()
    collection.AddItem(lightsP)

    # opaque passes
    ssaoCamP = vtk.vtkCameraPass()
    ssaoCamP.SetDelegatePass(opaqueP)

    ssaoP = vtk.vtkSSAOPass()
    ssaoP.SetRadius(30)
    ssaoP.SetDelegatePass(ssaoCamP)
    ssaoP.SetBias(0.1)
    ssaoP.SetBlur(True)
    ssaoP.SetKernelSize(32)

    collection.AddItem(ssaoP);

    # translucent and volumic passes
    ddpP = vtk.vtkDualDepthPeelingPass()
    ddpP.SetTranslucentPass(translucentP)
    ddpP.SetVolumetricPass(volumeP)
    collection.AddItem(ddpP)

    sequence = vtk.vtkSequencePass()
    sequence.SetPasses(collection)

    camP = vtk.vtkCameraPass()
    camP.SetDelegatePass(sequence)

    ren.SetPass(camP)

I can confirm that this order of passes fixed my issue completely, much appreciated. When I implemented your solution the overlay geometry was not rendered, in case anyone else uses this thread in the future that can be fixed by including:

        overP = vtk.vtkOverlayPass()
        collection.AddItem(overP)