Surface and volume rendering in the same render

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

1 Like

Hello,

You need to enable the Depth Peeling for volumes on your vtkRenderer
See methods :
UseDepthPeelingForVolumesOn
And
UseDepthPeelingOn
Also you will need a call to SetAlphaBitPlanes(1) and SetMultiSamples(0) on your render window

HTH

4 Likes

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

I do as you say,I call the
UseDepthPeelingForVolumesOn
UseDepthPeelingOn

it works!!! :grinning:

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

but when call them not as you say
SetAlphaBitPlanes(0)
SetMultiSamples(1)
the rendering result is
222

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

Glad it works for you :slight_smile:
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 :wink:
Have a nice day

1 Like