Search code examples
transparencyopacityvtkrenderer

VTK: setting transparent renderer background


I am allowed to define the backgroundColor of a renderer by calling

renderer = vtk.vtkRenderer()
renderer.SetBackground(0,255,0)

[![enter image description here][1]][1]

My question:

Is it possible to set the opacity of the background ?

You can see my problem (with multiple viewports) in my example image. I could get rid of this "cutting" by simply using transparent backgrounds...

thanks in advance!


Solution

  • I finally found a solution :

    you can set a layer for each renderer. Default is Layer 0 (not transparent). Everything greater than layer 0 will be transparent. But keep in mind to set at least a empty renderer (no volume or object) with a background-color on layer 0 to avoid ugly reflections.

    renderer.SetBackground(255,255,255)
    renderer.SetLayer(0)
    
    # transparency layer
    renderer.SetLayer(1)
    renderer.addVolume(....)
    

    Result:

    enter image description here