# Screen-space ambient occlusion for volume rendering

**URL:** <https://discourse.slicer.org/t/screen-space-ambient-occlusion-for-volume-rendering/32323>\
**Category:** Development\
**Tags:** volume-rendering\
**Created:** [October 19, 2023, 9:16am UTC](https://discourse.slicer.org/t/screen-space-ambient-occlusion-for-volume-rendering/32323 "2023-10-19T09:16:17Z")\
**Posts on this page:** 11\
**Page:** 3

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 24, 2023, 7:16pm UTC](https://discourse.slicer.org/t/screen-space-ambient-occlusion-for-volume-rendering/32323/41 "2023-11-24T19:16:33Z")

</div>

We’ll need a week or so to integrate and test all the VTK updates and then add GUI to Slicer to configure it.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [November 25, 2023, 6:01am UTC](https://discourse.slicer.org/t/screen-space-ambient-occlusion-for-volume-rendering/32323/42 "2023-11-25T06:01:14Z")

</div>

I assume this is not going to get into the current release being cut (5.6)?

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [November 25, 2023, 6:12am UTC](https://discourse.slicer.org/t/screen-space-ambient-occlusion-for-volume-rendering/32323/43 "2023-11-25T06:12:04Z")

</div>

> [@muratmaga](#):
>
> I assume this is not going to get into the current release being cut (5.6)?

Earlier today, @LucasGandel and I reviewed the list of VTK changes that we would need to backport to our `Slicer/VTK` fork, I am currently assessing if integrating these into the release is sensible.

---

<div class="post-metadata">

**Author:** ![LucasGandel](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lucasgandel/32/18202_2.png) [@LucasGandel](https://discourse.slicer.org/u/LucasGandel)\
**Post date:** [December 1, 2023, 7:13am UTC](https://discourse.slicer.org/t/screen-space-ambient-occlusion-for-volume-rendering/32323/44 "2023-12-01T07:13:39Z")

</div>

The final change ([VTK!10725](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/10725)) has been merged! 🚀  
This makes SSAO available for volumes, but not with the vtkRenderer::UseSSAOOn() function, you must explicitly set the render passes like this:

```auto
 // Render passes setup
  vtkNew<vtkRenderStepsPass> basicPasses;
  vtkNew<vtkSSAOPass> ssao;
  ssao->SetRadius(40);
  ssao->SetKernelSize(128);
  ssao->SetBias(0.01);
  ssao->BlurOn();
  // The depth format must be Fixed32 for the volume mapper to successfully copy the depth texture
  ssao->SetDepthFormat(vtkTextureObject::Fixed32);
  ssao->SetVolumeOpacityThreshold(0.95);
  ssao->SetDelegatePass(basicPasses);

  renderer->SetPass(ssao);

```

I’ll start working on screenshots and will try to kick off a doc for technical writing.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [December 9, 2023, 2:30am UTC](https://discourse.slicer.org/t/screen-space-ambient-occlusion-for-volume-rendering/32323/45 "2023-12-09T02:30:15Z")

</div>

Is this available for preview versions?

---

<div class="post-metadata">

**Author:** ![LucasGandel](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lucasgandel/32/18202_2.png) [@LucasGandel](https://discourse.slicer.org/u/LucasGandel)\
**Post date:** [December 11, 2023, 3:52pm UTC](https://discourse.slicer.org/t/screen-space-ambient-occlusion-for-volume-rendering/32323/46 "2023-12-11T15:52:35Z")

</div>

I don’t think so. @jcfr can you make sure to backport the [commits from VTK!10725](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/10725/commits) ? Then @lassoan’s MR on the sandbox module needs modifications to only include the setup of the render passes as done in my last comment.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 11, 2023, 4:22pm UTC](https://discourse.slicer.org/t/screen-space-ambient-occlusion-for-volume-rendering/32323/47 "2023-12-11T16:22:39Z")

</div>

@jcfr let me know when all the required VTK commits are in. Then I’ll update the Sandbox module according to @LucasGandel latest comment ([Screen-space ambient occlusion for volume rendering - #44 by LucasGandel](https://discourse.slicer.org/t/screen-space-ambient-occlusion-for-volume-rendering/32323/44)).

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [December 13, 2023, 6:11am UTC](https://discourse.slicer.org/t/screen-space-ambient-occlusion-for-volume-rendering/32323/48 "2023-12-13T06:11:57Z")

</div>

> [@jcfr](#):
>
> Earlier today, @LucasGandel and I reviewed the list of VTK changes that we would need to backport to our `Slicer/VTK` fork, I am currently assessing if integrating these into the release is sensible.

Did this make into the patch? I am not seeing it listed under the 5.6.1 release notes.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [December 13, 2023, 6:31am UTC](https://discourse.slicer.org/t/screen-space-ambient-occlusion-for-volume-rendering/32323/49 "2023-12-13T06:31:58Z")

</div>

> Did this make into the patch? I am not seeing it listed under the 5.6.1 release notes.

These will be integrated when we update the version of VTK used in Slicer Preview.

---

<div class="post-metadata">

**Author:** ![LucasGandel](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lucasgandel/32/18202_2.png) [@LucasGandel](https://discourse.slicer.org/u/LucasGandel)\
**Post date:** [December 19, 2023, 4:34pm UTC](https://discourse.slicer.org/t/screen-space-ambient-occlusion-for-volume-rendering/32323/50 "2023-12-19T16:34:56Z")

</div>

A first post is now available: [https://www.kitware.com/screen-space-ambient-occlusion-for-volumes/](https://www.kitware.com/screen-space-ambient-occlusion-for-volumes/)

I’m happy to help writing, reviewing, or providing screenshot if you want to communicate further once this is in Slicer.

I’m also considering revisiting the approach for almost fully transparent volume, as I think the ambient occlusion contribution should be multiplied with the fragment opacity

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 2, 2024, 6:10pm UTC](https://discourse.slicer.org/t/screen-space-ambient-occlusion-for-volume-rendering/32323/51 "2024-01-02T18:10:28Z")

</div>

A post was split to a new topic: [Improve ambient occlusion in volume rendering](https://discourse.slicer.org/t/improve-ambient-occlusion-in-volume-rendering/33590)

[Previous page](https://discourse.slicer.org/t/screen-space-ambient-occlusion-for-volume-rendering/32323.md?page=2)
