# vtkDualDepthPeelingPass example

**URL:** https://discourse.vtk.org/t/vtkdualdepthpeelingpass-example/15320
**Category:** Development
**Created:** [February 26, 2025, 3:04pm UTC](https://discourse.vtk.org/t/vtkdualdepthpeelingpass-example/15320 "2025-02-26T15:04:59Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![gongwaner](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gongwaner/32/6996_2.png) [@gongwaner](https://discourse.vtk.org/u/gongwaner)
#### Post date: [February 26, 2025, 3:04pm UTC](https://discourse.vtk.org/t/vtkdualdepthpeelingpass-example/15320/1 "2025-02-26T15:04:59Z")

</div>

Hi,  
I came across [this article](https://www.kitware.com/vtk-technical-highlight-dual-depth-peeling/) about dual depth peeling. It provides the code for fragment shader, but it can’t simply used.(I need to create the depth into texture and other stuff.) I then found that the feature is already implemented into a class vtkDualDepthPeelingPass. The vtkDualDepthPeelingPass.h can be found [here](https://github.com/Kitware/VTK/blob/ee730dc266c1a7ddd825870fc9b8af68aef79ec0/Rendering/OpenGL2/vtkDualDepthPeelingPass.h#L6) on github.  
It seems like there are only a few public functions to call. I have no idea how to use this class by just looking at the source code.  
Is there any example on how to use this class?

Thanks.

---

<div class="post-metadata">

### Author: ![LucasGandel](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lucasgandel/32/1831_2.png) [@LucasGandel](https://discourse.vtk.org/u/LucasGandel)
#### Post date: [February 27, 2025, 10:24am UTC](https://discourse.vtk.org/t/vtkdualdepthpeelingpass-example/15320/2 "2025-02-27T10:24:56Z")

</div>

Hi,

Calling `renderer->UseDepthPeelingOn()` should be enough. Some potentially outdated steps to follow are available here: [VTK/Depth Peeling - KitwarePublic](https://vtk.org/Wiki/VTK/Depth_Peeling#VTK_calls)

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [February 28, 2025, 5:20pm UTC](https://discourse.vtk.org/t/vtkdualdepthpeelingpass-example/15320/3 "2025-02-28T17:20:48Z")

</div>

Hello,

That is low level API. Normally you call front end API and VTK innards decide which class specialization to use. Why do you need to especifically use that class? Are you experiencing issues with your rendering?

best,

PC

---

<div class="post-metadata">

### Author: ![gongwaner](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gongwaner/32/6996_2.png) [@gongwaner](https://discourse.vtk.org/u/gongwaner)
#### Post date: [March 3, 2025, 7:36pm UTC](https://discourse.vtk.org/t/vtkdualdepthpeelingpass-example/15320/4 "2025-03-03T19:36:05Z")

</div>

Thank you for the link. That solved my problem.

---

<div class="post-metadata">

### Author: ![gongwaner](https://discourse.vtk.org/user_avatar/discourse.vtk.org/gongwaner/32/6996_2.png) [@gongwaner](https://discourse.vtk.org/u/gongwaner)
#### Post date: [March 3, 2025, 7:38pm UTC](https://discourse.vtk.org/t/vtkdualdepthpeelingpass-example/15320/5 "2025-03-03T19:38:52Z")

</div>

Hi Paulo,  
Thanks for your kind reply. My problem was that when I checked whether depth peeling was enabled or not using

```auto
    int depthPeelingWasUsed = renderer->GetLastRenderingUsedDepthPeeling();

```

it always prints “0” indicating false. I later found that it’s because I didn’t set the opacity of the actor. Depth peeling only takes effect on traslucent geometry.
