Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glTF: Transparent materials render incorrectly when part of multi-material node #16055

Closed
2 of 12 tasks
jeyashankher opened this issue Mar 25, 2019 · 8 comments
Closed
2 of 12 tasks
Labels

Comments

@jeyashankher
Copy link

Description of the problem

Setup: Two planes combined into a single mesh, each plane has a transparent (alphaMode=BLEND) material. One view renders correctly, but rotating the object leads to an incorrect render where one plane occludes the other.

One view with correct render:
Screenshot 2019-03-25 at 7 50 57 PM

Rotated view with incorrect render:
Screenshot 2019-03-25 at 7 50 41 PM

Example attached:

2plane_group_trans_test_gltf.zip

Three.js version
  • Dev
  • r102
  • [x ] r101
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, ...)
@donmccurdy
Copy link
Collaborator

In r101 (which my viewer uses) this glTF model is constructed as:

Screen Shot 2019-03-25 at 10 16 00 AM

threejs sorts transparent objects at the mesh level – based on the mesh position – and can't performantly look through the vertices of the mesh on each frame to sort the geometry groups. So from the engine's perspective, both of these planes are located at the mesh position, 0,0,0, and sorting is arbitrary.

In r103 (coming soon) we've removed the logic that loads primitives (e.g. parts of a multi-material model) into a groups in single Mesh (#15889), and instead you'd get two Meshes in this case. They still won't sort properly (because the centers of both are 0,0,0). But I think we've discussed using a bounding box for sorting, which would solve this case and may be worth considering?

@Mugen87
Copy link
Collaborator

Mugen87 commented Mar 26, 2019

But I think we've discussed using a bounding box for sorting, which would solve this case and may be worth considering?

Interesting. Can you please link the respective discussion? AFAIK, this would mitigate the issue but not solve many edge cases. Something like out-of-order transparency seems more promising ,see #9977. However, definitely more complicated to implement.

@donmccurdy
Copy link
Collaborator

donmccurdy commented Mar 26, 2019

See #13889 (comment). I guess the suggestion there was just to use the size of the bounding box, but sorting by distance from the camera to the nearest point in the bounding box might also be cheap enough.

@makc
Copy link
Contributor

makc commented Mar 27, 2019

Can you please link the respective discussion?

this was discussed as early as in #6011, if not before, as well. it was common problem in the age of flash 3D, but somehow 3js never considered proper sorting important, and just declared that this bug is a feature.

@donmccurdy
Copy link
Collaborator

... but somehow 3js never considered proper sorting important, and just declared that this bug is a feature.

To be fair here, there is no general solution. Using bounding boxes will fix this specific issue, and will break some cases that work today. I expect it fixes more than it breaks, but I can't prove that.

@makc
Copy link
Contributor

makc commented Mar 27, 2019

Another way to cheat this is screen-door transparency (example in #10600)

@donmccurdy
Copy link
Collaborator

Is that what Unreal's "Dither Temporal AA" feature does? That would be a nice addition, I'd been thinking of implementing it as a masking node type for NodeMaterial.

@Mugen87 Mugen87 added the Bug label Mar 4, 2021
@donmccurdy
Copy link
Collaborator

Let's merge this thread into #9977. There is currently no general solution for perfect and performant sorting of transparent triangles, so I think we should consider this a feature request for better or additional options like OIT or sort-by-bounding box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants