I need prevent add opacities in a complex mesh

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.

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

I would try with a prepass renderer

https://doc.babylonjs.com/typedoc/classes/BABYLON.PrePassRenderer

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

1 Like

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.

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 :slight_smile:

1 Like

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

3 Likes

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

sphere.material.needDepthPrePass = true;
2 Likes

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