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

Depth: depth test is wrong when enable logarithmic depth #30203

Open
Lafeu-p opened this issue Dec 25, 2024 · 2 comments
Open

Depth: depth test is wrong when enable logarithmic depth #30203

Lafeu-p opened this issue Dec 25, 2024 · 2 comments
Milestone

Comments

@Lafeu-p
Copy link

Lafeu-p commented Dec 25, 2024

Description

When I set depthTest = true and depthWrite = false, depth testing still works as expected.
When I use WebGLRenderer or WebGPURenderer (without enabling logarithmic depth), everything works fine. However, the issue arises after I enable logarithmic depth.
The image below is the expected result.
image
wrong depth
image
The green sphere in the foreground should be occluded by the red sphere below it.

This issue has affected many visual effects in my scene, and I sincerely hope it can be resolved.

Reproduction steps

emoty

Code

// code goes here

Live example

jsfiddle example

Screenshots

No response

Version

171

Device

Desktop

Browser

Chrome

OS

MacOS

@Spiri0
Copy link
Contributor

Spiri0 commented Dec 25, 2024

Maybe it's because you're using a MeshBasicMaterial instead of a MeshBasicNodeMaterial. In addition, the depthNode is not served. I don't know how much automatism can be expected. I have an example here that works very well. You can see the different depths through the cubes.

https://codepen.io/Spiri0/pen/vYqpRga

I optionally created a depthShader for the depthNode and did the same with the node system. Both work identically. I hope it helps you

@Lafeu-p
Copy link
Author

Lafeu-p commented Dec 26, 2024

Thank you for your example.

Both MeshBasicNodeMaterial and MeshBasicMaterial have the same depth issue.

I tried your example and found that enabling depth testing and disabling depth writing still results in the same issue I mentioned earlier. This issue becomes more pronounced when transparent is set to false.
image
image

I believe that depthTest, depthWrite, and similar settings should be part of the three.js's fundamental configuration. Users shouldn't need to perform additional operations; Requiring users to set a custom depthNode for all materials while also considering whether logarithmic depth is being used places an unnecessary burden on them.
@sunag

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

No branches or pull requests

3 participants