# Surface and volume rendering in the same render

**URL:** <https://discourse.vtk.org/t/surface-and-volume-rendering-in-the-same-render/2717>\
**Category:** Development\
**Created:** [February 28, 2020, 8:08am UTC](https://discourse.vtk.org/t/surface-and-volume-rendering-in-the-same-render/2717 "2020-02-28T08:08:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![snow](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/ba9def/32.png) [@snow](https://discourse.vtk.org/u/snow)\
**Post date:** [February 28, 2020, 8:08am UTC](https://discourse.vtk.org/t/surface-and-volume-rendering-in-the-same-render/2717/1 "2020-02-28T08:08:40Z")

</div>

I create a vtkpolydata and a vtkImagedata ,add a vtkActor and vtkVolume to the same render,the vtkpolydata is a closed surface, and intersect with the volume .

when I set the vtkActor opacity to 1,

actor-\>GetProperty()-\>SetOpacity(1);

it looks all right,but when i set the opacity to 0.5,

actor-\>GetProperty()-\>SetOpacity(0.5);

it looks strange , like the volume covers the suface , I don’t know what caused this problem,  
Can you give me some advice? thanks

---

<div class="post-metadata">

**Author:** ![simonesneault](https://discourse.vtk.org/user_avatar/discourse.vtk.org/simonesneault/32/67_2.png) [@simonesneault](https://discourse.vtk.org/u/simonesneault)\
**Post date:** [February 28, 2020, 8:53am UTC](https://discourse.vtk.org/t/surface-and-volume-rendering-in-the-same-render/2717/2 "2020-02-28T08:53:49Z")

</div>

Hello,

You need to enable the Depth Peeling for volumes on your vtkRenderer  
See methods :  
[UseDepthPeelingForVolumesOn](https://vtk.org/doc/nightly/html/classvtkRenderer.html#a91bb9e0129f8d73173a945d65a0811d8)  
And  
[UseDepthPeelingOn](https://vtk.org/doc/nightly/html/classvtkRenderer.html#a4e9d72654eb7972a6abf82fbeb2a8a66)  
Also you will need a call to SetAlphaBitPlanes(1) and SetMultiSamples(0) on your render window

HTH

---

<div class="post-metadata">

**Author:** ![snow](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/ba9def/32.png) [@snow](https://discourse.vtk.org/u/snow)\
**Post date:** [March 3, 2020, 3:03am UTC](https://discourse.vtk.org/t/surface-and-volume-rendering-in-the-same-render/2717/3 "2020-03-03T03:03:54Z")

</div>

Thanks a lot!  
I read something about depth peeling , have a general idea of it.

I do as you say,I call the  
[UseDepthPeelingForVolumesOn](https://vtk.org/doc/nightly/html/classvtkRenderer.html#a91bb9e0129f8d73173a945d65a0811d8)  
[UseDepthPeelingOn](https://vtk.org/doc/nightly/html/classvtkRenderer.html#a4e9d72654eb7972a6abf82fbeb2a8a66)

it works!!! 😀

but it seems there is no different when i call the function of render window using different parameter;

when i call them as you say  
SetAlphaBitPlanes(1)  
SetMultiSamples(0)  
the rendering result is  
 ![111](https://discourse.vtk.org/uploads/default/original/2X/3/364445fc9d0dd2d22e27212047eb1c0eded3ed33.jpeg)

but when call them not as you say  
SetAlphaBitPlanes(0)  
SetMultiSamples(1)  
the rendering result is  
 ![222](https://discourse.vtk.org/uploads/default/original/2X/6/6257cef8f109e860bb5ae6fa49ea95e2a29ba8e9.jpeg)

I can’t see the difference, I’m a little confused, could you tell me The differences between the two approaches??

---

<div class="post-metadata">

**Author:** ![simonesneault](https://discourse.vtk.org/user_avatar/discourse.vtk.org/simonesneault/32/67_2.png) [@simonesneault](https://discourse.vtk.org/u/simonesneault)\
**Post date:** [March 3, 2020, 8:35am UTC](https://discourse.vtk.org/t/surface-and-volume-rendering-in-the-same-render/2717/4 "2020-03-03T08:35:26Z")

</div>

Glad it works for you 🙂  
I’m not a specialist but I believe SetMultiSamples to 0 is meant to disable the hardware antialiasing. That should be a condition for the Depth peeling to work correctly. And probably the same goes for the alpha bit planes, maybe some experts can highlight you here…

Anyway, the images looks nice, so it is indeed working 😉  
Have a nice day
