# I need prevent add opacities in a complex mesh

**URL:** <https://forum.babylonjs.com/t/i-need-prevent-add-opacities-in-a-complex-mesh/49014>\
**Category:** Questions\
**Created:** [March 24, 2024, 5:15pm UTC](https://forum.babylonjs.com/t/i-need-prevent-add-opacities-in-a-complex-mesh/49014 "2024-03-24T17:15:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bitmo\_games](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bitmo_games/32/37337_2.png) [@bitmo\_games](https://forum.babylonjs.com/u/bitmo_games)\
**Post date:** [March 24, 2024, 5:15pm UTC](https://forum.babylonjs.com/t/i-need-prevent-add-opacities-in-a-complex-mesh/49014/1 "2024-03-24T17:15:40Z")

</div>

Is there a way to apply the same transparency to a mesh even if several faces of the mesh overlap in front of the camera.

 ![alphas_modes](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/8/f/8f474c567d49eaf87d17655630299b072b1461b9.png)

In the image, the red boxes have a different transparency, I want the transparency to be the same regardless of the rotation/position of the mesh

- i tested with material alpha mode.

_BABYLON.Engine.ALPHA\_COMBINE,_  
_BABYLON.Engine.ALPHA\_ADD,_  
_BABYLON.Engine.ALPHA\_SUBTRACT,_  
_BABYLON.Engine.ALPHA\_MULTIPLY,_  
_BABYLON.Engine.ALPHA\_MAXIMIZED_

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [March 25, 2024, 8:22am UTC](https://forum.babylonjs.com/t/i-need-prevent-add-opacities-in-a-complex-mesh/49014/2 "2024-03-25T08:22:21Z")

</div>

I would try with a prepass renderer

[https://doc.babylonjs.com/typedoc/classes/BABYLON.PrePassRenderer](https://doc.babylonjs.com/typedoc/classes/BABYLON.PrePassRenderer)

so only the closest pixels to the camera will be visible. No overdraw.

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [March 25, 2024, 8:33am UTC](https://forum.babylonjs.com/t/i-need-prevent-add-opacities-in-a-complex-mesh/49014/3 "2024-03-25T08:33:15Z")

</div>

> [@Cedric](#):
>
> a prepass renderer

May I ask you if this technique also doubles the drawcalls (like a depth renderer)? What’s the impact on perf?… Just being curious here.

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [March 25, 2024, 8:38am UTC](https://forum.babylonjs.com/t/i-need-prevent-add-opacities-in-a-complex-mesh/49014/4 "2024-03-25T08:38:40Z")

</div>

it depends on the number of drawcalls, and the target device. Before checking the perf, make sure it’s valid for fixing the issue. if it’s not, then no need to worry about the perf 🙂

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [March 25, 2024, 10:36am UTC](https://forum.babylonjs.com/t/i-need-prevent-add-opacities-in-a-complex-mesh/49014/5 "2024-03-25T10:36:11Z")

</div>

I would use the stencil and configure it to not write where the mesh has already written:

> **[Babylon.js Playground](https://playground.babylonjs.com/#AX9BJX)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [March 25, 2024, 4:25pm UTC](https://forum.babylonjs.com/t/i-need-prevent-add-opacities-in-a-complex-mesh/49014/6 "2024-03-25T16:25:06Z")

</div>

I wonder if setting the mesh to use depthPrepass could also solve it

```auto
sphere.material.needDepthPrePass = true;

```

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [March 25, 2024, 4:51pm UTC](https://forum.babylonjs.com/t/i-need-prevent-add-opacities-in-a-complex-mesh/49014/7 "2024-03-25T16:51:50Z")

</div>

Yes, that can work. Funny that I didn’t think of it as I’m using this a lot in my scene.

> **[Babylon.js Playground](https://playground.babylonjs.com/#AX9BJX%232)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes
