Skip to content

Improvements on Depth Testing for Billboards #12952

@Beilinson

Description

@Beilinson

Feature

Currently, disableDepthTestDistance=5000 by default. From my experience, this is too large of a value over our use case with relatively flat but slightly hilly terrain, resulting in too many billboards that should be hidden behind terrain to appear as if they were in front (video example 1). Due to this, we usually set disableDepthTestDistance=100, which our specific use case is an improvement on the visual pop-in that we otherwise experience. However, this leads to billboards being rendered below the ground for most zoom levels (see video example 2 below).

I decided to look around for similar issues and found a significant amount of issues with their end result being unclear to me:

  1. Billboards on terrain - some problems #4686 tagged as high priority since 2018, have 1-4 been updated over the various billboard clamping changes that have occured since 1.114?
  2. Billboard ordering incorrect when using disableDepthTestDistance #6838 I can reproduce this as well today, however I wonder if this a particularly relevant real life use case? This ticket led me to the biggest questions:
  3. Enable improved depth testing for all billboards #6802 This was closed due to being blocked by Billboard ordering incorrect when using disableDepthTestDistance #6838 ("ideally"), and disableDepthTestDistance causes weird mouse interaction #6840, which seems to be fixed (from my testing and from the conversation in the ticket). Despite this, I clearly see that parts of Enable improved depth testing for all billboards #6802 made it into main, for example the depthsilon (which is indeed a fantastic variable name) logic exists in BillboardCollectionVS.glsl. What exactly happened here?
  4. Label letters misaligned when zooming in #7376 was mentioned at the end of disableDepthTestDistance causes weird mouse interaction #6840 (which seems to be why it isn't closed yet?), however I cant reproduce this either and this hasn't been mentioned since 2017.
  5. Separate pass for billboards #8810 was opened as a result of Enable improved depth testing for all billboards #6802 and disableDepthTestDistance causes weird mouse interaction #6840, but again it looks like parts of Enable improved depth testing for all billboards #6802 made it in so what exactly is the status of this?

Personally, point 5 from #4686 was marked OBE (overruled by events? I think), however it makes a whole lot of sense to me and wasn't really explained:

Please consider depth offset in the BillboardCollectionVS.glsl. In previous versions there were the following lines:

#ifdef CLAMPED_TO_GROUND
    // move slightly closer to camera to avoid depth issues.
    positionEC.z *= 0.995;
#endif    

It would be great if, in addition to eyeOffset paramter in billboard and label, there will be a depthOffset which will be expressed as a fraction of the camera distance to the vertex (0-1).

I played around with scaling the depth in the BillboardCollectionFS.glsl, and this actually resulted in a much nicer transition and behavior for billboards that are only barely occluded by the terrain.

Default Behavior (pop-in, billboards behind terrain appearing fully instead of partially occluded):

default.webm

disableDepthTestDistance=500 (still pop-in, all billboards are now partially occluded by the terrain beneath them)

depthDistance100.webm

disableDepthTestDistance=500 + Depth Scaling by factor of 0.97 (less pop-in, smoother transitions, billboards on top of terrain are fully visible while those behind hills are partially occluded as intended):

depthDistance+depthScaling.webm
#ifdef LOG_DEPTH
    float depth = czm_branchFreeTernary(v_depthFromNearPlusOne < 1.1, v_depthFromNearPlusOne, v_depthFromNearPlusOne * .97);
    czm_writeLogDepth(depth);
#endif

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions