I am currently working with the PointAppearences on Point Clouds.
For visualization puroses, my goal is to colorize the points in the shader according to their height with the ground as a reference.
See [1]
I can't use the 'position' attribute directly, because in its coordinate system there is no 'up-axis' (i.e., I can't just map the y-value on the green colour. It all seems rotated).
Can you give me a hint how to get the up-vector, according to the earth's center?
Or do I have to store the height for every point in the point cloud data, and then retrieve it as an attribute?
Are the points moving? If not, it may be more efficient to compute the color in JavaScript and store it as a vertex attribute, or compute the height in JavaScript and store it in a vertex attribute.
Otherwise, you could try to convert from Cartesian coordinates to Cartographic in the vertex shader (port this function to GLSL) to get the height; however, it will have precision issues due to 32-bit floating-point.
What kind of app are you building? Have you seen 3D Tiles? They are still a work-in-progress, but may fit your use case.
Also, PointAppearence is a private class in Cesium so it may change in the future. Keep that in mind when upgrading Cesium releases.
The points don't move (for now).
I implemented the function (Ellipsoid.cartesianToCartographic) in GLSL. Everything got very slow, so I can't recommend that.
So I used the function on cpu-side, but I can't use the results for visualization. I don't know why the colors look like that [1]. It might be the precision issues, or maybe the terrain height?
Yes, I have seen 3D-Tiles. I try to figure out how to integrate our PointCloud features into the 3D-Tiles. One feature will be color mapping, so I am working on that now.
So I guess I have to store the point height into the point cloud data, or at least a custom matrix.