# SetOpacity is not working correctly!

**URL:** https://discourse.vtk.org/t/setopacity-is-not-working-correctly/1994
**Category:** Development
**Created:** [October 28, 2019, 12:20pm UTC](https://discourse.vtk.org/t/setopacity-is-not-working-correctly/1994 "2019-10-28T12:20:02Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![rai-sam](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rai-sam/32/667_2.png) [@rai-sam](https://discourse.vtk.org/u/rai-sam)
#### Post date: [October 28, 2019, 12:20pm UTC](https://discourse.vtk.org/t/setopacity-is-not-working-correctly/1994/1 "2019-10-28T12:20:02Z")

</div>

I am trying to set opacity for vtkActor but any value less than 1.0 makes it invisible completely.

Opacity test example is working fine. What I am missing here?

Using vtk 8.2.0.

---

<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: [October 28, 2019, 12:38pm UTC](https://discourse.vtk.org/t/setopacity-is-not-working-correctly/1994/2 "2019-10-28T12:38:43Z")

</div>

If you have semi-transparent actors in the scene then you need to order their cells for correct rendering, for example by enabling depth peeling.

---

<div class="post-metadata">

### Author: ![rai-sam](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rai-sam/32/667_2.png) [@rai-sam](https://discourse.vtk.org/u/rai-sam)
#### Post date: [October 29, 2019, 6:34am UTC](https://discourse.vtk.org/t/setopacity-is-not-working-correctly/1994/3 "2019-10-29T06:34:34Z")

</div>

First, I don’t see enabling depth peeling in [Opacity](https://lorensen.github.io/VTKExamples/site/Cxx/Visualization/Opacity/) example.

I enabled it still no change.

---

<div class="post-metadata">

### Author: ![rai-sam](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rai-sam/32/667_2.png) [@rai-sam](https://discourse.vtk.org/u/rai-sam)
#### Post date: [October 29, 2019, 6:56am UTC](https://discourse.vtk.org/t/setopacity-is-not-working-correctly/1994/4 "2019-10-29T06:56:54Z")

</div>

SetOpacity is working by taking out UseShadowsOn(). Without enabling peeling.

---

<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: [October 29, 2019, 5:50pm UTC](https://discourse.vtk.org/t/setopacity-is-not-working-correctly/1994/5 "2019-10-29T17:50:15Z")

</div>

> [@rai-sam](#):
>
> First, I don’t see enabling depth peeling in [Opacity](https://lorensen.github.io/VTKExamples/site/Cxx/Visualization/Opacity/) example.

@lorensen It seems that [https://lorensen.github.io/VTKExamples/site/Cxx/Visualization/Opacity/](https://lorensen.github.io/VTKExamples/site/Cxx/Visualization/Opacity/) example is somewhat misleading. It would be better to add at least an option to use depth peeling.

@rai-sam Correct rendering of translucent geometry is shown in this example: [https://lorensen.github.io/VTKExamples/site/Cxx/Visualization/CorrectlyRenderTranslucentGeometry/](https://lorensen.github.io/VTKExamples/site/Cxx/Visualization/CorrectlyRenderTranslucentGeometry/)

In some cases, from some viewpoints, some arrangement of objects, translucent objects may look like correctly rendered. However, in general you need to use depth peeling - or other polygon sorting method, or more sophisticated rendering approaches, such as raytracing - to render translucent objects correctly.

---

<div class="post-metadata">

### Author: ![rai-sam](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rai-sam/32/667_2.png) [@rai-sam](https://discourse.vtk.org/u/rai-sam)
#### Post date: [October 30, 2019, 7:05am UTC](https://discourse.vtk.org/t/setopacity-is-not-working-correctly/1994/6 "2019-10-30T07:05:56Z")

</div>

@lassoan So this will effect overall performance?

---

<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: [October 30, 2019, 2:41pm UTC](https://discourse.vtk.org/t/setopacity-is-not-working-correctly/1994/7 "2019-10-30T14:41:33Z")

</div>

Yes, depth peeling affects rendering speed. 5-10 years ago this was a significant issue but nowadays this performance impact is rarely a problem.
