# Different transparency while using thin instances

**URL:** <https://forum.babylonjs.com/t/different-transparency-while-using-thin-instances/30574>\
**Category:** Questions\
**Created:** [May 20, 2022, 3:10pm UTC](https://forum.babylonjs.com/t/different-transparency-while-using-thin-instances/30574 "2022-05-20T15:10:22Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg97](https://avatars.discourse-cdn.com/v4/letter/g/e99b99/32.png) [@greg97](https://forum.babylonjs.com/u/greg97)\
**Post date:** [May 20, 2022, 3:10pm UTC](https://forum.babylonjs.com/t/different-transparency-while-using-thin-instances/30574/1 "2022-05-20T15:10:22Z")

</div>

Dear Community,

today, I found this recent topic ([Different transparency for mesh instances](https://forum.babylonjs.com/t/different-transparency-for-mesh-instances/30331)).

I wanted to recreate this example with thin instances.  
To my surprise, I am only able to set different transparency in version 4.2.1 but not in version 5.7.0.

Am I missing here something?

Here is my playground: [https://playground.babylonjs.com/#8L50Q3#129](https://playground.babylonjs.com/#8L50Q3#129)

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 20, 2022, 8:47pm UTC](https://forum.babylonjs.com/t/different-transparency-while-using-thin-instances/30574/3 "2022-05-20T20:47:20Z")

</div>

@greg97 it is definitely a bug, I will try to have it fix ASAP.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 20, 2022, 8:47pm UTC](https://forum.babylonjs.com/t/different-transparency-while-using-thin-instances/30574/4 "2022-05-20T20:47:24Z")

</div>

Assigned @sebavan on May 20, 2022, 8:47pm UTC



---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 20, 2022, 10:29pm UTC](https://forum.babylonjs.com/t/different-transparency-while-using-thin-instances/30574/5 "2022-05-20T22:29:42Z")

</div>

Fix will be available here: [Fix Instances Color Alpha by sebavan · Pull Request #12555 · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/pull/12555)

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 20, 2022, 10:29pm UTC](https://forum.babylonjs.com/t/different-transparency-while-using-thin-instances/30574/6 "2022-05-20T22:29:45Z")

</div>

Unassigned @sebavan on May 20, 2022, 10:29pm UTC



---

<div class="post-metadata">

**Author:** ![greg97](https://avatars.discourse-cdn.com/v4/letter/g/e99b99/32.png) [@greg97](https://forum.babylonjs.com/u/greg97)\
**Post date:** [May 21, 2022, 8:42am UTC](https://forum.babylonjs.com/t/different-transparency-while-using-thin-instances/30574/7 "2022-05-21T08:42:25Z")

</div>

Thank you for the quick fix.

---

<div class="post-metadata">

**Author:** ![greg97](https://avatars.discourse-cdn.com/v4/letter/g/e99b99/32.png) [@greg97](https://forum.babylonjs.com/u/greg97)\
**Post date:** [June 1, 2022, 8:15am UTC](https://forum.babylonjs.com/t/different-transparency-while-using-thin-instances/30574/8 "2022-06-01T08:15:31Z")

</div>

Hi @sebavan.

While the transparency works fine now, I realized today that there is still something strange going on.

As you can see in the attached picture, you frequently run into cases where you look at a transparent mesh instance (annotated as 1) and you can’t see the opaque mesh instance (annotated as 2) behind it. In the most extreme case, you are also able to see another opaque mesh (annotated as 3), even though it should be hidden, as 2 is in front of it.

You can reproduce this by running the initial playground. You should find cases like this really easy.

Do I have a mistake in my code related to the sorting of the meshes or is this another bug?

[[Album] imgur.com ![](https://i.imgur.com/Qn5wy0x.png?fb "imgur.com") ](https://imgur.com/a/uaTX5Nz)

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 1, 2022, 3:11pm UTC](https://forum.babylonjs.com/t/different-transparency-while-using-thin-instances/30574/9 "2022-06-01T15:11:03Z")

</div>

Let s see if @Evgeni_Popov has some ideas on this one ?

---

<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:** [June 1, 2022, 4:37pm UTC](https://forum.babylonjs.com/t/different-transparency-while-using-thin-instances/30574/10 "2022-06-01T16:37:03Z")

</div>

The `Mesh.INSTANCEDMESH_SORT_TRANSPARENT` property only works for `InstancedMesh`, not for thin instances.

For thin instances, you give an array of transformation matrices for each thin instance and the system simply use them “as is”. If you want to sort the thin instances, you will have to sort these transformations matrices and pass them to the engine through a `box.thinInstanceSetBuffer("matrix", ...);` call each frame.

An alternate way to make transparency work with thin instances is to use the new OIT setting in 5.0 ([Transparent Rendering | Babylon.js Documentation](https://doc.babylonjs.com/divingDeeper/materials/advanced/transparent_rendering#order-independent-transparency)):

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

---

<div class="post-metadata">

**Author:** ![greg97](https://avatars.discourse-cdn.com/v4/letter/g/e99b99/32.png) [@greg97](https://forum.babylonjs.com/u/greg97)\
**Post date:** [June 3, 2022, 8:31am UTC](https://forum.babylonjs.com/t/different-transparency-while-using-thin-instances/30574/11 "2022-06-03T08:31:45Z")

</div>

Got it. Thanks to both of you 🙂
