Precision of POSITION_ABSOLUTE point attribute for 3D Tiles styles for point clouds

Hi!

1. A concise explanation of the problem you’re experiencing.

I’m visualizing 3D point clouds with Cesium and would like to visualize a height gradient (something like this: https://user-images.githubusercontent.com/3269617/33374948-e5173068-d510-11e7-9ef5-2df7b4833f74.png).

I am trying to accomplish this using 3D Tiles styles based on the POSITION_ABSOLUTE attribute.

When tinkering around with approximations for the point-to-ellipsoid distance problem, I noticed that there are visible artifacts in the gradient I’m getting.

This makes we wonder: What is the precision of the POSITION_ABSOLUTE attribute of a point? It seems like the precision used in styling is much lower than the precision used for placing the point. Or am I missing something else entirely?

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

See here for an example based on the “3D Tiles Point Cloud” sandcastle example.

In this example, I color points based on the fractional part of the z-axis component of the POSITION_ABSOLUTE attribute. What I would expect is a rather smooth greyscale gradient along some tilted axis (as the z-axis is not ‘up’). The visualization however shows basically two colors: Black and grey. This tells me that all points have a precision of not even one fractional digit?!

This is the same for the x-axis component. For some reason, the y-axis component seems to provide better results in the example.

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

If there is a better way to visualize a height gradient of the point cloud, I’m interested. However, I’d rather avoid pre-calculating (and storing!) that attribute for every point for all data sets that we have.

4. The Cesium version you’re using, your operating system and browser.

Sandcastle currently uses Cesium 1.62, I’m using Arch Linux and Firefox 69. I also reproduced the problem on a Windows 10 machine with Chrome.

2 Likes

This is where the position_absolute is computed in the shader:

Notice that it’s possible position_absolute has less precision than is used to place the point in the right location on the globe, because the point’s location is split into the RTC_CENTER and its position relative to that.

Also, in case others find it useful, here’s a Sandcastle that styles the points by distance relative to a given point. The point is computed by clicking somewhere and copying the console output into the shader.

thanks,and how i adjust opacity base on color, the code below is not run
new Cesium.Cesium3DTileStyle({
color:‘vec4(${COLOR},0.8)’
});

Styling with transparency should work, there’s some examples of this here: https://sandcastle.cesium.com/index.html?src=3D%20Tiles%20Point%20Cloud%20Styling.html

Hello @omar ,
this precision issue is still there and creates a certain “patchiness” in the Sandcastle you provided. I modified it, please have a look:

  1. I reduced the size of the yellow shine and changed its position. Zoom in on it to see that the gradient is quite “patchy”. It seems that some tiles use different positions:

  1. Notice that I also provided a custom shader, which is supposed to draw a repeating rainbow gradient based on height. (You have to re-activate the line // tileset.customShader = customShader; and deactivate the line tileset.style = new Cesium.Cesium3DTileStyle(style), see lines 92 and 93). Instead of a nice gradient, we see patches again, and their lines are not parallel, so there is something going on there:

grafik

Is there any way to get more precision to color the points?

On another note, I confirm what aholfter already found out, i.e. that the y axis has a very good precision. It’s x and z that give those artifacts:

Sandcastle from which I took the pictures.

I changed Line 57 to produce those pictures.

float distance = abs(point.x - positionAbsolute.x);

Hard transitions between colors, and a kind of “dithering”.

float distance = abs(point.y - positionAbsolute.y);

Notice the nice gradient here:

float distance = abs(point.z - positionAbsolute.z);

Again, no gradient but hard transitions. At least no “dithering”.

Can this be considered a bug?

I now created a bug ticket at cesium github: Precision of position attribute in Point Cloud is good on Y axis, but bad on X and Z axis · Issue #11819 · CesiumGS/cesium · GitHub