Strange behavior when there is another side of the same model beyond the model with opacity and transparent set


Hello, I have a 3D model placed on a scene.
I have a 3D model placed on a scene with the material set to transparent: true and opacity: 0.5.
(I am using MeshBasicMaterial to rule out the possibility that it is a problem with a specific material.)
The model I am using is in the shape of a human lung. If as in the attached video, there is another side of that model on the other side of the transparency,
The polygons that make up the model may or may not be visible, and appear differently, like stained glass.
Why does this happen? Is there a workaround?

In the case of a problem involving transparency, it may be resolved by manipulating renderOrder or depthTest,
In this case, since the problem is occurring within a single model, these do not seem to be relevant.

Why do you think that .depthTest is not relevant within a single mesh?

1 Like

Thanks for the advice. I was mistaken; I thought that depthTest or depthWrite only affected the interrelationship of multiple meshes.
It turns out that even within a single mesh, by setting depthTest or depthWrite to false, the stained glass-like phenomenon no longer occurs.

By the way, why did this phenomenon occur? As it is, the only solution is to turn off depthTest and depthWrite, and we will not be able to control the interrelationships with other objects. If possible, is there another way to work around this phenomenon?

1 Like

The implemented algorithm for handling transparency requires to have specific order of drawing individual triangles - it does not matter whether they come from one mesh or from several meshes.

There are tricks to address this issue for some specific situations, but there is no universal solution.

More advanced algorithms, that resolve transparency problems, are either too slow (e.g. raytracing) or too noisy (e.g. alpha to coverage).

You might like to read more about OIT (order-independent transparency).

1 Like

In most cases I set .depthWrite=false for semi-transparent materials, which may help here, but does not eliminate the effects of triangle order in the rendering process. For small meshes, sorting the triangles by distance from the camera would be an option, too.

If you are OK with having some grain in the image, also consider alpha hashing, which does eliminate sorting issues like these.

1 Like

@gkjohnson also has a great depth peeling demo three.js Depth Peeling

3 Likes

Thank you all for the advice. Finally, I was able to solve almost all of my problems by using gltf-transform reorder.


1 Like

Try mesh.material.side=THREE.FrontSide;