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

Billboard depth fail #5166

Merged
merged 16 commits into from
Apr 6, 2017
Merged

Billboard depth fail #5166

merged 16 commits into from
Apr 6, 2017

Conversation

bagnell
Copy link
Contributor

@bagnell bagnell commented Mar 28, 2017

Adds disableDepthDistance and alwaysDisableDepth properties to labels/billboards/points. alwaysDisableDepth will always draw the billboard in front of everything. disableDepthDistance will always draw the billboard when the distance to the camera is less than that disableDepthDistance.

Fixes #5121.

  • Add doc
  • Add tests
  • Update CHANGES.md

@pjcozzi
Copy link
Contributor

pjcozzi commented Mar 29, 2017

Fixes #5121

@pjcozzi
Copy link
Contributor

pjcozzi commented Mar 29, 2017

Also fixes #2694

@pjcozzi
Copy link
Contributor

pjcozzi commented Mar 29, 2017

For the API and naming, perhaps just:

  • disableDepthTestDistance with a default of 0.0.

When it's Number.POSITIVE_INFINITY, depth is never tested. When 0.0, it is always tested.

Billboard.NUMBER_OF_PROPERTIES = 15;
var DISABLE_DEPTH_DISTANCE = Billboard.DISABLE_DEPTH_DISTANCE = 15;
var ALWAYS_DISABLE_DEPTH = Billboard.ALWAYS_DISABLE_DEPTH = 16;
Billboard.NUMBER_OF_PROPERTIES = 17;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have ideas for avoiding going above 16 attributes?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nevermind, I see that we are good.

@@ -100,7 +102,9 @@ define([
var PIXEL_SIZE_INDEX = PointPrimitive.PIXEL_SIZE_INDEX = 5;
var SCALE_BY_DISTANCE_INDEX = PointPrimitive.SCALE_BY_DISTANCE_INDEX = 6;
var TRANSLUCENCY_BY_DISTANCE_INDEX = PointPrimitive.TRANSLUCENCY_BY_DISTANCE_INDEX = 7;
var DISTANCE_DISPLAY_CONDITION_INDEX = PointPrimitive.DISTANCE_DISPLAY_CONDITION = 8;
var DISTANCE_DISPLAY_CONDITION_INDEX = PointPrimitive.DISTANCE_DISPLAY_CONDITION_INDEX = 8;
var DISABLE_DEPTH_DISTANCE_INDEX = PointPrimitive.DISABLE_DEPTH_DISTANCE_INDEX = 15;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why 15 and 16? Not 9 and 10?

attribute vec4 eyeOffset; // eye offset in meters, 4 bytes free (texture range)
attribute vec4 scaleByDistance; // near, nearScale, far, farScale
attribute vec4 pixelOffsetScaleByDistance; // near, nearScale, far, farScale
attribute vec4 distanceDisplayConditionAndDisableDepth; // near, far, disableDepthDistance, alwaysDisableDepth
Copy link
Contributor

Choose a reason for hiding this comment

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

Could alwaysDisableDepth be the sign of disableDepthDistance?

@@ -246,8 +246,8 @@ void main()
#endif

#ifdef DISTANCE_DISPLAY_CONDITION
float nearSq = distanceDisplayCondition.x * distanceDisplayCondition.x;
float farSq = distanceDisplayCondition.y * distanceDisplayCondition.y;
float nearSq = distanceDisplayConditionAndDisableDepth.x * distanceDisplayConditionAndDisableDepth.x;
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated to this PR, but why don't we store the squared distance in the vertex attribute to avoid this computation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, updated here: 18b6769

@denverpierce
Copy link
Contributor

Is it possible to get this somewhere higher in the API, like dataSources or viewer/scene? Label clipping issues especially have been a pain point, and I don't see an issue overriding labels especially to never depth test.

@ghost
Copy link

ghost commented Mar 30, 2017

Seconded @denverpierce's comment. We load pins from KML files with label clipping.

@pjcozzi
Copy link
Contributor

pjcozzi commented Mar 30, 2017

@bagnell what do you think of a min distance on Scene that could set a czm_ uniform for @denverpierce and @Zizekftw's request?

@bagnell
Copy link
Contributor Author

bagnell commented Mar 31, 2017

@bagnell what do you think of a min distance on Scene that could set a czm_ uniform for @denverpierce and @Zizekftw's request?

Added in e990328

@bagnell
Copy link
Contributor Author

bagnell commented Mar 31, 2017

@pjcozzi This is ready for another look.

@@ -258,6 +258,24 @@ void main()
gl_Position = czm_viewportOrthographic * vec4(positionWC.xy, -positionWC.z, 1.0);
v_textureCoordinates = textureCoordinates;

#ifdef DISABLE_DEPTH_DISTANCE
float disableDepthTestDistance = distanceDisplayConditionAndDisableDepth.z;
if (disableDepthTestDistance == 0.0 && czm_minimumDisableDepthTestDistance != 0.0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Put { on a new line in GLSL.


bool clipped = gl_Position.z < -gl_Position.w || gl_Position.z > gl_Position.w;
float distance = length(positionEC.xyz);
if (!clipped && (disableDepthTestDistance < 0.0 || (distance > 0.0 && distance < disableDepthTestDistance)))
Copy link
Contributor

Choose a reason for hiding this comment

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

I might have already asked this, but should be store squared distance instead to avoid the length above? Or are you concerned about overflow? We would treat infinity as a special case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You asked about it for the distance display conditions, which I fixed, but somehow forgot this. It's been updated.

@pjcozzi
Copy link
Contributor

pjcozzi commented Apr 3, 2017

Add this to a Sandcastle example.

@pjcozzi
Copy link
Contributor

pjcozzi commented Apr 3, 2017

@bagnell feel free to push this 1.33, up to you.

@pjcozzi
Copy link
Contributor

pjcozzi commented Apr 3, 2017

@tfili @mramato does it make sense to use this by default for KML when ground clamping is used?

@denverpierce
Copy link
Contributor

Google Earth doesn't depth test labels, but it does test icons.

@bagnell
Copy link
Contributor Author

bagnell commented Apr 3, 2017

@pjcozzi This is ready for another look.

@pjcozzi
Copy link
Contributor

pjcozzi commented Apr 6, 2017

All looks good.

Please also merge into 3d-tiles.

@pjcozzi pjcozzi merged commit 7cf1df8 into master Apr 6, 2017
@pjcozzi pjcozzi deleted the billboard-depth-fail branch April 6, 2017 12:41
@lilleyse lilleyse mentioned this pull request Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants