question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GLTFLoader: Could we re-think about how we deal depth buffer for `BLEND` materials?

See original GitHub issue
Description of the problem

Already discussed a bit about it on #13889

Currently, we are letting depthWrite: true for every material that is being loaded from GLTFLoader, even when the material is alphaTest: BLEND . And glTF spec does not specify how we must set our depth write, even in non-normative sections, since the use of glTF is not restricted to the traditional realtime rasterizer. It just says that we should try to make it look proper in as many situations as possible.

See: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0/#alpha-coverage

I think we should follow other “majority” implementations for this situation. (uhhh is this good idea?) Note that it’s pretty easy to change the behavior, just adding a line to GLTFLoader would work I think.

Three.js version
  • Dev
  • r109
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, …)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
donmccurdycommented, Dec 23, 2019

@Kagetsuki the problem visible in your third image comes from setting depthWrite=false on all materials. If you set the option only on the transparent materials, you’ll get a reasonable result.

Screen Shot 2019-12-22 at 8 53 05 PM

@FMS-Cat Okay, I think I agree at this point. Let’s set depthWrite=false for transparent materials in GLTFLoader. Opened https://github.com/mrdoob/three.js/pull/18235.

2reactions
greggmancommented, May 18, 2020

Maybe you have different experience. In games I’ve rarely worked on a project that used depthWrite = false except for particles effects. It’s extremely common to enable gl.BLEND for things like leaves and grass and use an alpha test discard and the depth test has to be on for it work. I’m sure there are a ton more scenes that will break where in three.js terms it needs to be (depthWrite = true, transparency = true, alphaTest = > 0) but unfortunately most of the scenes that would show this are not downloadable from sketchfab

wjwiGLP8Uo KttvBSkioM 8BtBhCpOLr yTiAxZYKVd qU9P1XwPXH WaJe6EwygL

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gltf material depth issues in three.js but looks fine in other ...
Hi guys, I'm loading a gltf model (from Cinema4D with baked materials) using the standard GLTFLoader method from the docs/examples.
Read more >
How to deal with transparent textures and depth in three.js?
The fragments that are discarded will not contribute to the depth buffer. If you need blending, then drawing order can be very imporant; ......
Read more >
CS307: Transparency
Finally, the depth buffer is only updated if DepthMask is true. This is the default value, but you can turn it off in...
Read more >
cute of testing the - CSDN
used to do Extreme Programming and Test-First Development in the. C language. ... If you find CuTest useful we would like to hear...
Read more >
Three.js Loading a .GLTF File
OBJ file materials are directly part of the format. That said I thought I ... We also need to include the GLTFLoader and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found