Meshes alpha blend with other objects in scene but not themselves

Hi,

I am trying to set some meshes(multiple meshes) loaded from a model file alpha to blend with other objects in scene, but inside the meshes they are not transparent. What’s the best way to achieve this? Thanks!
https://www.babylonjs-playground.com/#WGZLGJ#574
(This may not be a perfect example since it only has 1 mesh but you can get my point)

If you set the Transparency Mode of the material to be Alpha Blend, it seems to work.
https://www.babylonjs-playground.com/#WGZLGJ#576

I found this by using the Inspector, if you look at Materials > BoomBox_Mat, there is a Transparency category there.

Granted, it doesn’t look like the mesh can completely disappear unless you change the Transparency Mode to be Alpha Blend and Test. There might be a better way though.

1 Like

Hi @johannhuang

Not entirely sure if this answers your question, but you can also manually set the visibility of a mesh like this:

mesh.visibility = 0.5;

Updated in this playground.
https://www.babylonjs-playground.com/#WGZLGJ#578

Also for more reading on this subject, here’s a good thread that goes into more detailed explanations with examples:

3 Likes

Hi, @PirateJC

Thank you for the quick response. Your code works perfectly on the playground, but they are not exactly what I meant. My model file has multiple meshes, when I set the visibility to 0.5, they are blended with each other and makes the whole model looking weird. What I am trying to achieve is to create a group of meshes inside a node that are not transparent among each other, but transparent to outside objects in the world. (kinda like a hologram in star wars) Is there a quick way to do that without merging all the meshes into one? (assuming they have their own transformation and animation so it’s not a good idea to merge them)

An idea could be to use the pre depth rendering for these meshes:
https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#depth-pre-pass-meshes

1 Like

@Deltakosh Thanks a lot for your answer, it works one step further! I can see will that flag turned on in a mesh faces are no longer transparent to each other. But what if I have multiple meshes inside a root node? Do I need to manually merge them into 1 mesh to achieve the same result or can the same trick apply to the root node?

It is a bit tricky but you can try to set that flag to all meshes. It should work if no other mesh is transparent
Else you will be forced to merge them