Skip to content

Conversation

@mzschwartz5
Copy link
Contributor

@mzschwartz5 mzschwartz5 commented Nov 5, 2025

Description

In #12821, I turned off automatic depth testing for billboards / labels, and implemented it manually in the shaders. This was to give us more control over how these entities clip against the globe at various distance scales. (We've done a similar thing in the past, this was supposed to improve / build on those techniques)

That PR introduced a regression: the outlines or transparent parts of billboards and labels will now clip through models no matter what. This is because:

  1. The aforementioned manual depth test reads from the globe depth texture
  2. The opaque render pass does not write to the globe depth texture, so parts of billboards rendered in the subsequent translucency pass do not adhere to the depth values for things (like models) written in the opaque pass.

Moreover, in digging into this bug, I realized that there's another bug: opaque billboards / labels also do not respect the depth of other opaque billboards / labels, since the opaque billboard pass only reads from the globe depth, but doesn't write back to it (and you can't read-from and write-to the same depth texture in webgl2, in the same pass).

Solution

  1. Re-enable automatic depth testing for billboards and labels.
  2. Keep the manual depth testing that was added. This will still be the primary control over how billboards and labels clip or do not clip against the globe.
  3. Fudge the depth value written out of the fragment shader so that any fragments that passed the manual depth test will pass the automatic depth test (at least, compared to the globe depth. Fragments can still fail if there are other occluders, like models, in front).

This gets us the best of both worlds - more depth testing control but also we still utilize the standard depth testing pipeline and thus get proper clipping against models and other billboards, without poor clipping against the globe.

Issue number and link

#13012

Testing plan

Same testing plan as in #12821, but with an additional regression test per the linked issue:

Test this sandcastle, and confirm that, on this branch, it looks the way it does in the Cesium 1.134 picture of the linked issue.

Author checklist

  • I have submitted a Contributor License Agreement
  • I have added my name to CONTRIBUTORS.md
  • I have updated CHANGES.md with a short summary of my change
  • I have added or updated unit tests to ensure consistent code coverage
  • I have updated the inline documentation, and included code examples where relevant
  • I have performed a self-review of my code

@mzschwartz5 mzschwartz5 marked this pull request as ready for review November 5, 2025 14:25
enabled: true,
func: useTranslucentDepthMask
? WebGLConstants.LEQUAL
: WebGLConstants.LESS,
Copy link
Contributor Author

@mzschwartz5 mzschwartz5 Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renabled as it was before #12821 (yes, that is LEQUAL)

@github-actions
Copy link

github-actions bot commented Nov 5, 2025

Thank you for the pull request, @mzschwartz5!

✅ We can confirm we have a CLA on file for you.

@mzschwartz5 mzschwartz5 force-pushed the billboard-depth-regression-fix branch from 6812978 to 020749d Compare November 5, 2025 14:27
@mzschwartz5 mzschwartz5 self-assigned this Nov 5, 2025
@ggetz
Copy link
Contributor

ggetz commented Nov 6, 2025

@jjhembd Do you have the bandwidth to review this?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants