Instanced mesh with alpha = 1.0 is still semi transparent

Hello,

I have a scenario where I want to have instanced meshes. The instanced mesh should either be semi-transparent or solid. However the mesh that has alpha = 1.0 is still semi transparent. I.e. it is possible to see through from one mesh to the other for both meshes.

Please see the PG:
https://playground.babylonjs.com/#LFXT0L#18

Thanks a lot.

Pinging @Evgeni_Popov

As the transparency mode is “alpha blend” the meshes are considered to be transparent. That means they are not rendered to the zbuffer. Regular transparent meshes are sorted from back to front before rendering (based on the center of their bounding sphere), but because in your PG the meshes are instances they are always rendered in their order of creation (so orange first and blue second) whatever the camera position.

As it seems to be a recurring problem, I tried a PR:

If accepted, you will need to set Mesh.INSTANCEDMESH_SORT_TRANSPARENT = true when merged to enable the sorting.

4 Likes

I like it a lot!

@Evgeni_Popov

Thanks a lot for the fix and sorry for the late reply. I had some problem with upgrading from babylon 4.2.0. I can confirm that fix is working in my project.

Updated PG with the fix:

https://playground.babylonjs.com/#LFXT0L#20