# Shadow rendering issue with transparency

**URL:** https://discourse.slicer.org/t/shadow-rendering-issue-with-transparency/36557
**Category:** Support
**Created:** [June 2, 2024, 3:33pm UTC](https://discourse.slicer.org/t/shadow-rendering-issue-with-transparency/36557 "2024-06-02T15:33:31Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![mohammed\_alshakhas](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mohammed_alshakhas/32/10025_2.png) [@mohammed\_alshakhas](https://discourse.slicer.org/u/mohammed_alshakhas)
#### Post date: [June 2, 2024, 3:33pm UTC](https://discourse.slicer.org/t/shadow-rendering-issue-with-transparency/36557/1 "2024-06-02T15:33:31Z")

</div>

I find the shadow visibility feature to be so good, I love it but  
is it possible to make the effect stronger / weaker?  
I wish it were not ON by default  
it has an issue when segments are transparent. The attached pic is an example, in reality, it looks worse. the overlapped areas look dark/blurred. ( anterior mandible and ramus)

 ![Screenshot 2024-06-02 at 18.29.42](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/0/b0d4f8ebb6058989a173fc9e6b3869ed8a6b0f0e.jpeg)

---

<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: [June 3, 2024, 2:27pm UTC](https://discourse.slicer.org/t/shadow-rendering-issue-with-transparency/36557/2 "2024-06-03T14:27:34Z")

</div>

> [@mohammed\_alshakhas](#):
>
> I find the shadow visibility feature to be so good, I love it but  
> is it possible to make the effect stronger / weaker?

Yes - see [here](https://discourse.slicer.org/t/improve-ambient-occlusion-in-volume-rendering/33590/6). I just did not get around to integrate this improvement.

> [@mohammed\_alshakhas](#):
>
> I wish it were not ON by default

It is configurable. You can set it to be on or off by default in application settings / Views / Shadows visibility.

> [@mohammed\_alshakhas](#):
>
> it has an issue when segments are transparent.

There are some limitations.

Transparent surfaces don’t cast a shadow, so even if you set your opacity to 99%, you won’t see any shadow casted by that model. This can be considered either a feature or a limitation (it may be useful in some cases).

Depth peeling does not seem to work when shadows are enabled. This can be probably fixed, but most likely would need dedicated funding sent to Kitware.

---

<div class="post-metadata">

### Author: ![mohammed\_alshakhas](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mohammed_alshakhas/32/10025_2.png) [@mohammed\_alshakhas](https://discourse.slicer.org/u/mohammed_alshakhas)
#### Post date: [June 3, 2024, 2:43pm UTC](https://discourse.slicer.org/t/shadow-rendering-issue-with-transparency/36557/3 "2024-06-03T14:43:12Z")

</div>

thank you for your reply  
What is depth peeling? I can’t figure out what it does!

---

<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: [June 3, 2024, 3:23pm UTC](https://discourse.slicer.org/t/shadow-rendering-issue-with-transparency/36557/4 "2024-06-03T15:23:26Z")

</div>

Depth peeling is required for correct display of transparent surfaces (surfaces need to be ordered based on distance from camera).

Note that you may be able to avoid transparency related issues and have much higher fidelity rendering if you use “Colorize volume” module (it displays the result of segmentation combined with the original image).

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [June 4, 2024, 8:44am UTC](https://discourse.slicer.org/t/shadow-rendering-issue-with-transparency/36557/5 "2024-06-04T08:44:06Z")

</div>

This reminded me a related issue so if you don’t mind I just join this discussion.

When using transparency, I frequently see artifacts like this. Any idea what these might be and how to mitigate them? Thank you very much!

---

<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: [June 4, 2024, 3:22pm UTC](https://discourse.slicer.org/t/shadow-rendering-issue-with-transparency/36557/6 "2024-06-04T15:22:40Z")

</div>

What you show looks like depth peeling is disabled.

It is a known issue that if shadows are enabled then depth peeling does not seem to work:

> <https://github.com/Slicer/Slicer/issues/7780>
>
> \## Summary
> 
> Depth peeling (that makes semi-transparent models appear correctly… in 3D views) seems to be incompatible with shadows option. Semi-transparent models may appear incorrectly (backface occlude frontface, kind of appearing inside out) if "Shadows visibility" option is enabled in the 3D view.
> 
> \## Environment
> \- Slicer version: Slicer-5.7.0 2024-06-02
> \- Operating system: all

Is it the issue that you are seeing?

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [June 5, 2024, 9:58am UTC](https://discourse.slicer.org/t/shadow-rendering-issue-with-transparency/36557/7 "2024-06-05T09:58:16Z")

</div>

I cannot confirm if this is what I see - I don’t know what kind of arfiact the lack of depth peeling would cause in this case. Although I can confirm that this artifact is only visible with the shadows enabled, and if I disable SSAO they disappear too.

I saw the ticket yesterday, thanks for creating it! If there is a way to at least verify if depth peeling is the issue here, please let me know and I’ll investigate. Thank you!

---

<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: [June 5, 2024, 12:12pm UTC](https://discourse.slicer.org/t/shadow-rendering-issue-with-transparency/36557/8 "2024-06-05T12:12:46Z")

</div>

You can confirm by disabling shadows and toggling depth peeling on and off. If disabling depth peeling produces the same artifacts then it means that the problem is due to depth peeling ineffective or not performed when shadows are enabled.

It may be due to shadows messing up the z buffer, rendering passes missed or performed in the wrong order, or maybe combination of shadows+depth peeling would require implementing some special combined shader code.

@LucasGandel is it expected that SSAO interferes with depth peeling?

---

<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: [June 5, 2024, 12:19pm UTC](https://discourse.slicer.org/t/shadow-rendering-issue-with-transparency/36557/9 "2024-06-05T12:19:28Z")

</div>

I’ve been following the discussion but need to perform a few tests locally and check the current order of passes before pointing you in the right direction. I also recall SSAO was interfering with the translucent pass in VTK but thought it had been fixed. I’ll try to dig a bit into this in the coming days and will share updates, but your statement is definitely correct:

> [@lassoan](#):
>
> It may be due to shadows messing up the z buffer, rendering passes missed or performed in the wrong order, or maybe combination of shadows+depth peeling would require implementing some special combined shader code.

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [June 5, 2024, 12:58pm UTC](https://discourse.slicer.org/t/shadow-rendering-issue-with-transparency/36557/10 "2024-06-05T12:58:50Z")

</div>

> [@lassoan](#):
>
> If disabling depth peeling produces the same artifacts then it means that the problem is due to depth peeling ineffective or not performed when shadows are enabled.

This I tried, but there were no such artifacts. It may be possible though that depth peeling of the shadows themselves produce these, but that’s the part I cannot confirm.

> [@LucasGandel](#):
>
> I’ll try to dig a bit into this in the coming days and will share updates

Much appreciated @LucasGandel !

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [June 5, 2024, 2:08pm UTC](https://discourse.slicer.org/t/shadow-rendering-issue-with-transparency/36557/11 "2024-06-05T14:08:33Z")

</div>

I showed @lassoan this artifact, and the conclusion was that it is indeed the depth peeling. I only kept the jaw bone segment, and in this video you can see that the far side of the jaw, while rotating along AP, became “in front of” the near side, causing the artifact. In the second half of the video I disabled SSAO (this part is not shown in the video as the panel is not in the view) and then also disable depth peeling (this can be seen though), and then a similar effect can be seen, the only difference is that the shadows are not added, so it is not that emphasized.

---

<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: [June 17, 2024, 12:26pm UTC](https://discourse.slicer.org/t/shadow-rendering-issue-with-transparency/36557/12 "2024-06-17T12:26:44Z")

</div>

Sorry for the late reply. I am still not sure what is exactly producing the artefacts you initially reported @cpinter, but at least I could investigate the issue mentioned by @lassoan which is the root cause for the transparent models not being supported with shadows. For the record, I answered on the issue directly: [Semi-transparent models are not rendered correctly if shadows visibility is enabled · Issue #7780 · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/issues/7780)

---

<div class="post-metadata">

### Author: ![mohammed\_alshakhas](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mohammed_alshakhas/32/10025_2.png) [@mohammed\_alshakhas](https://discourse.slicer.org/u/mohammed_alshakhas)
#### Post date: [June 25, 2024, 5:32pm UTC](https://discourse.slicer.org/t/shadow-rendering-issue-with-transparency/36557/13 "2024-06-25T17:32:54Z")

</div>

new issue i had today

shoadow visibilty ON , depth peel OFF

 ![Screenshot 2024-06-25 at 20.28.45](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/a/7a3ccb29948ff5c549ca500fe9b6af343e99fc30.jpeg)

shoadow visibilty OFF , depth peel OFF

 ![Screenshot 2024-06-25 at 20.29.18](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/6/a6a5897695a9d2300d017e55f375cf4229034958.jpeg)

---

<div class="post-metadata">

### Author: ![mohammed\_alshakhas](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mohammed_alshakhas/32/10025_2.png) [@mohammed\_alshakhas](https://discourse.slicer.org/u/mohammed_alshakhas)
#### Post date: [December 16, 2024, 12:13pm UTC](https://discourse.slicer.org/t/shadow-rendering-issue-with-transparency/36557/14 "2024-12-16T12:13:28Z")

</div>

i found a use for the transparency issue i mentoed bedore @lassoan .

here im using teeth as opaque and jaw as transparent . i can alter the shadow on the solid object and it seems to make a good visualization .  
like only altering lightining parameter on one object .

is that possible other way , was this intedned ?

thanks

---

<div class="post-metadata">

### Author: ![mohammed\_alshakhas](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mohammed_alshakhas/32/10025_2.png) [@mohammed\_alshakhas](https://discourse.slicer.org/u/mohammed_alshakhas)
#### Post date: [December 16, 2024, 1:18pm UTC](https://discourse.slicer.org/t/shadow-rendering-issue-with-transparency/36557/15 "2024-12-16T13:18:25Z")

</div>

![Screenshot 2024-12-16 at 15.09.07](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/7/0704d76907a161a39eb88214242da207df1dc739.jpeg)
