# Is it possible to overlay two raycast volumes in the same render window?

**URL:** https://discourse.vtk.org/t/is-it-possible-to-overlay-two-raycast-volumes-in-the-same-render-window/2177
**Category:** Support
**Created:** [November 28, 2019, 7:41pm UTC](https://discourse.vtk.org/t/is-it-possible-to-overlay-two-raycast-volumes-in-the-same-render-window/2177 "2019-11-28T19:41:13Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![msmerps](https://discourse.vtk.org/user_avatar/discourse.vtk.org/msmerps/32/1559_2.png) [@msmerps](https://discourse.vtk.org/u/msmerps)
#### Post date: [November 28, 2019, 7:41pm UTC](https://discourse.vtk.org/t/is-it-possible-to-overlay-two-raycast-volumes-in-the-same-render-window/2177/1 "2019-11-28T19:41:13Z")

</div>

Hi everybody,  
I would like to render two different volumes using two different color maps in the same renderer. I can’t tell if this is currently possible in VTK. This post makes me think it is not yet possible:

> **[How to render two volumes in the 3D scene at the same time?](https://discourse.slicer.org/t/how-to-render-two-volumes-in-the-3d-scene-at-the-same-time/1680/5)**
>
> Just to clarify. If you don’t need them to be superimposed in the same rendering window, you can choose switch to dual 3D layout, assign each volume to a different viewport, adjust their volume properties and finally link cameras. That way you can...

However, the VTK-based Slicer does appear to have a module that can do this. See the beautiful CT-PET overlay example on this page:  
[https://www.slicer.org/w/index.php/Modules:VolumeRendering-Documentation-3.6](https://www.slicer.org/w/index.php/Modules:VolumeRendering-Documentation-3.6)

Any wisdom would be appreciated.  
-Merps

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [November 28, 2019, 8:30pm UTC](https://discourse.vtk.org/t/is-it-possible-to-overlay-two-raycast-volumes-in-the-same-render-window/2177/2 "2019-11-28T20:30:23Z")

</div>

That multi-volume renderer was a custom implementation developed 10 years ago. VTK changed a lot since then, so there would be no chance of bringing that back to life.

Fortunately, multi-volume renderer has been added to VTK recently, so custom implementations should not be needed anymore. However, this multi-volume renderer is not usable for much yet, as it does not do any shading. We spent a little time trying to add this feature, but ran into problems (volume rendering succeeding/failing randomly) that we did not have enough time to understand and fix.

We are so close to having multi-volume rendering capability in VTK… I hope Kitware will get a contract soon that would allow them to finish it up. We could contribute by a few k$ towards this goal. If a couple of other groups could make a pledge, too, then something might happen.

---

<div class="post-metadata">

### Author: ![msmerps](https://discourse.vtk.org/user_avatar/discourse.vtk.org/msmerps/32/1559_2.png) [@msmerps](https://discourse.vtk.org/u/msmerps)
#### Post date: [November 29, 2019, 3:26pm UTC](https://discourse.vtk.org/t/is-it-possible-to-overlay-two-raycast-volumes-in-the-same-render-window/2177/3 "2019-11-29T15:26:52Z")

</div>

Thanks (as always) Andras.  
It vtkMultiVolume ([https://vtk.org/doc/nightly/html/classvtkMultiVolume.html](https://vtk.org/doc/nightly/html/classvtkMultiVolume.html)) the functionality you’re referring to?

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [November 29, 2019, 3:33pm UTC](https://discourse.vtk.org/t/is-it-possible-to-overlay-two-raycast-volumes-in-the-same-render-window/2177/4 "2019-11-29T15:33:24Z")

</div>

Yes, that’s it.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [November 29, 2019, 4:56pm UTC](https://discourse.vtk.org/t/is-it-possible-to-overlay-two-raycast-volumes-in-the-same-render-window/2177/5 "2019-11-29T16:56:48Z")

</div>

Here are the changes that (almost) make multi-volume rendering work with shading:

> **[Volume Rendering not working](https://discourse.slicer.org/t/volume-rendering-not-working/4018/23?u=lassoan)**
>
> This is my branch: Shading with multi-volume rendering works with this branch, however, not every time! Unfortunately about 2/3 of the time there is no rendering at all, but when it shows up, then it looks as it’s supposed to. I haven’t been able...

---

<div class="post-metadata">

### Author: ![msmerps](https://discourse.vtk.org/user_avatar/discourse.vtk.org/msmerps/32/1559_2.png) [@msmerps](https://discourse.vtk.org/u/msmerps)
#### Post date: [November 29, 2019, 5:12pm UTC](https://discourse.vtk.org/t/is-it-possible-to-overlay-two-raycast-volumes-in-the-same-render-window/2177/6 "2019-11-29T17:12:58Z")

</div>

Gracias.

---

<div class="post-metadata">

### Author: ![MissMac](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/c57346/32.png) [@MissMac](https://discourse.vtk.org/u/MissMac)
#### Post date: [March 15, 2021, 12:58pm UTC](https://discourse.vtk.org/t/is-it-possible-to-overlay-two-raycast-volumes-in-the-same-render-window/2177/7 "2021-03-15T12:58:41Z")

</div>

Hello everyone,

does anyone know if this issue is solved or if any progress have been made in the latest VTK Version 9.xx regarding the multi-volume render?

Thank you very!  
Miss Mac.

---

<div class="post-metadata">

### Author: ![yuhuimoon](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/y/c6cbf5/32.png) [@yuhuimoon](https://discourse.vtk.org/u/yuhuimoon)
#### Post date: [March 15, 2021, 2:22pm UTC](https://discourse.vtk.org/t/is-it-possible-to-overlay-two-raycast-volumes-in-the-same-render-window/2177/8 "2021-03-15T14:22:19Z")

</div>

In my this [post](https://discourse.vtk.org/t/multi-vtkvolume-rendering-problem/5060), I have tested multi-volume rendering with the latesst VTK. There are two vtkVolume objects in a vtkRenderer and rendering result seems not bad. But if you want to manipulate one of them, such as setVisibility or setUserMatrix, some problems will occur. You can find some ways used in [3D Slicer](https://github.com/Slicer/Slicer/blob/master/Modules/Loadable/VolumeRendering/MRMLDM/vtkMRMLVolumeRenderingDisplayableManager.cxx). Hope it helps you.

---

<div class="post-metadata">

### Author: ![MissMac](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/c57346/32.png) [@MissMac](https://discourse.vtk.org/u/MissMac)
#### Post date: [March 15, 2021, 5:09pm UTC](https://discourse.vtk.org/t/is-it-possible-to-overlay-two-raycast-volumes-in-the-same-render-window/2177/9 "2021-03-15T17:09:32Z")

</div>

Thank you Harrison for your quick answer.

I am using VTK 8 and did the rendering of two volumes similar to yours mentioned in the post.  
The rendering indeed looks OK, but I am not able to apply any light settings i.e. Ambient, Diffusion, Specular it was mentioned in the post as well.

Is this now supported in VTK 9.  
I am considering upgrading to VTK9 but only if it is supported in the new version.

Thanks in advance!

---

<div class="post-metadata">

### Author: ![yuhuimoon](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/y/c6cbf5/32.png) [@yuhuimoon](https://discourse.vtk.org/u/yuhuimoon)
#### Post date: [March 16, 2021, 4:33am UTC](https://discourse.vtk.org/t/is-it-possible-to-overlay-two-raycast-volumes-in-the-same-render-window/2177/10 "2021-03-16T04:33:19Z")

</div>

I only use some general functions of volume property to set shading, and it seems to be OK.

```
multiVolume->GetProperty()->ShadeOn();
multiVolume->GetProperty()->SetInterpolationTypeToLinear();
multiVolume->GetProperty()->SetAmbient(0.2);
multiVolume->GetProperty()->SetDiffuse(1.0);
multiVolume->GetProperty()->SetSpecular(0.0);
multiVolume->GetProperty()->SetSpecularPower(1.0);
multiVolume->GetProperty()->SetScalarOpacityUnitDistance(0.8919);
```
