-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Disable depth test for labels close to the viewer #5121
Comments
How did the vertex shader clipping look? OK? If so, this would be a good approach when someone has bandwidth. |
Came up when looking at #5083. |
Could also fix #2694. |
We may actually want this per label. In the following code example, the labels may be very far away and we still do not want to depth test them. var viewer = new Cesium.Viewer('cesiumContainer');
viewer.scene.globe.depthTestAgainstTerrain = true;
var terrainProvider = new Cesium.CesiumTerrainProvider({
url : '//assets.agi.com/stk-terrain/world',
requestVertexNormals : true,
requestWaterMask: true
});
viewer.terrainProvider = terrainProvider;
viewer.scene.terrainProvider = terrainProvider;
viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(-110, 40.03883),
point : {
pixelSize : 15,
color : Cesium.Color.YELLOW,
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND
}
});
viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(-100, 35),
label : {
text : 'Testing',
font : '12px Helvetica',
style : Cesium.LabelStyle.FILL_AND_OUTLINE,
showBackground: true,
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND
}
}); |
This check makes sure that it won't be brought to the front if it was clipped by the near or far plane: |
It may be desirable to always have a label be visible, e.g. attached to building or model, when the viewer is close. For example, a label at the center of the milk truck model should be visible at any angle. Now, the depth test on labels causes parts of the label to be occluded.
One option is to have two batches of billboards, one with the depth test enabled and the other would have it disabled. Billboards would need to be rebatched every time the camera moves.
Another option is to move the billboard positions in clip space to the near plane in the vertex shader. Here is an example that works pretty well when added to the end of
BillboardCollectionVS.glsl
:The distance
10000.0
should be replaced by a uniform or per-vertex attribute.The text was updated successfully, but these errors were encountered: