[vtkusers] Enable depth peeling after initialization

Ken Martin ken.martin at kitware.com
Tue Jan 9 13:00:03 EST 2018


For VTK version 6.2 I think you are correct. Depth peeling (more
specifically alpha bitplanes probably) might have to be turned on before
the window is created. For more recent versions of VTK I don't believe that
is still the case.

On Tue, Jan 9, 2018 at 11:57 AM, Ignacio Fernández Galván via vtkusers <
vtkusers at vtk.org> wrote:

> Hi all,
>
> I'm trying to enable depth peeling with VTK. Currently my goal is using it
> with Mayavi and python. My problem, and a sample code, is in
> https://stackoverflow.com/questions/47738246/depth-peeling-in-mayavi.
>
> I think the reason is that depth peeling must be enabled before
> initializing the window, but Mayavi initializes the window as soon as it is
> declared, so changing the settings after does nothing. Consider the
> following simple, pure VTK, code:
>
> #=============================================================
> import vtk
>
> init_before = True
>
> ren = vtk.vtkRenderer()
> renWin = vtk.vtkRenderWindow()
> renWin.AddRenderer(ren)
> ren.SetBackground([.2, .2, .2])
>
> if init_before:
>   # create a renderwindowinteractor
>   iren = vtk.vtkRenderWindowInteractor()
>   iren.SetRenderWindow(renWin)
>   iren.Initialize()
>
> # enable depth peeling
> ren.SetUseDepthPeeling(1)
> ren.SetOcclusionRatio(0.1)
> ren.SetMaximumNumberOfPeels(100)
> renWin.SetMultiSamples(0)
> renWin.SetAlphaBitPlanes(1)
>
> if not init_before:
>   # create a renderwindowinteractor
>   iren = vtk.vtkRenderWindowInteractor()
>   iren.SetRenderWindow(renWin)
>   iren.Initialize()
>
> # create source
> source = vtk.vtkCylinderSource()
> source.SetCenter(0, 0, 0)
> source.SetRadius(5.0)
> source.SetHeight(7.0)
> source.SetResolution(100)
> source.Update()
>
> # mapper
> mapper = vtk.vtkPolyDataMapper()
> mapper.SetInputData(source.GetOutput())
>
> # actor
> actor = vtk.vtkActor()
> actor.SetMapper(mapper)
> actor.GetProperty().SetOpacity(0.5)
>
> # assign actor to the renderer
> ren.AddActor(actor)
> ren.ResetCamera()
>
> # enable user interface interactor
> renWin.Render()
> print ren.GetLastRenderingUsedDepthPeeling()
> iren.Start()
> #=============================================================
>
> With init_before=False I get that depth peeling was used, but not with
> init_before=True.
>
> Is there anything I can do to force and update of the render window to
> pick up the new settings? I tried iren.Reinitialize() to no avail. The only
> way I could find was removing renWin and iren and creating new ones, but
> that doesn't help with Mayavi.
>
> Thanks,
> Ignacio
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensou
> rce/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://vtk.org/mailman/listinfo/vtkusers
>



-- 
Ken Martin PhD
Distinguished Engineer
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065

This communication, including all attachments, contains confidential and
legally privileged information, and it is intended only for the use of the
addressee.  Access to this email by anyone else is unauthorized. If you are
not the intended recipient, any disclosure, copying, distribution or any
action taken in reliance on it is prohibited and may be unlawful. If you
received this communication in error please notify us immediately and
destroy the original message.  Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180109/4a2d2fe6/attachment.html>


More information about the vtkusers mailing list