-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Option to clamp point cloud points to terrain #6714
Comments
If we were to address this use case, I feel like this is something that would happen as part of the conversion to 3D tiles, not runtime in CesiumJS. @lilleyse what do you think? |
@hpinkos That was what I thought about doing as well. Similar to Cesium.sampleTerrainMostDetailed works but offline. My concern with this solution is if the terrain is modified the points would have to be recomputed. The other solution I thought of was tying the tile loading process to the pointcloud and when a higher resolution tile is loaded find the intersecting pointcloud tiles from the oct-tree and offset the points positions. My problem with this idea is I feel as if it would be a lot of wasted compute time. The best solution would be a higher resolution version of approximateTerrainHeights.json that transforms the points at loadtime. Although I would love to hear @hpinkos and @lilleyse thoughts |
After doing further research I now believe the proper solution would to be a shader level toggle that offsets the point above the terrain at runtime; unless some faster endpoint was exposed to the user. |
The main problem with the shader approach is terrain heights are not available there. I can't think of a way around that right now. What you're doing now is probably the best way to do this dynamically but I agree with @hpinkos that it would be easiest to clamp to terrain on the content creation side. This is what we do for 3D buildings which face a similar sort of problem. Your concern is valid though, but maybe not a limiting factor. One last idea I have is to still set |
@lilleyse Would it be possible to see a code snippet for the implementation for fuzzy point testing? The content creation idea works but is way too slow to run at scale. So I think a fuzzy depth tester would be the best of both solutions. |
Honestly the infrastructure isn't really set up for my idea, you would need to make the framebuffer's depth texture available to the point cloud shader. But after that it should be something like this in the fragment shader (with depth test disabled): float depth = texture2D(u_depthTexture, gl_FragCoord.xy);
float depthEC = -czm_windowToEyeCoordinates(gl_FragCoord.xy, depth).z;
float pointDepthEC = -czm_windowToEyeCoordinates(gl_FragCoord).z;
if (pointDepthEC - depthEC > 10.0)
{
// Point is 10 meters behind an occluder
discard;
} |
@lilleyse is there any middle ground where points aren't rendered on the other side of the earth but are not necessarily depth tested against terrain? I mean hypothetically this could be solved with tiles that are not too large. However, that kinda beats the purpose of tiles in add mode. Generally a way of solving CesiumGS/3d-tiles#319 but without the occlusion caused by The way I see this being done is creating a globe of some scalar, then comparing the points against that rather than the terrain itself. I mean the terrain itself would maybe work better since its more true to the world. |
@ProjectBarks - the points on the opposite side should be occluded, but I think there is a bug in the command execution. It might be an easy fix. Some background - when @bagnell do you know if it would be possible to render the depth plane before 3D Tiles and not interfere with inverse classification etc? This may have come up before... I forget. |
We execute 3D Tiles before the depth is cleared and the depth plane is rendered. This is so they can depth test against the terrain which is useful for 3D Tiles that are terrain or buildings. You could add an option to do it before 3D Tiles are rendered. The invert classification should be fine since it only applies to a single tileset. |
@bagnell any thoughts on a good place to stick this property? |
@lilleyse this works until contextOptions: {
requestWebgl2: true
} is added. (Note this is on the 1.46 release -- but this also holds true in the 1.47 release). Demos |
@ProjectBarks do you want to open a PR with the rollback? Just make sure to revert all the changes that were made in 1fda8c0, including in After reading through the dicussion in #5770 I think the rollback is safe. This issue is basically the "edge case" that I didn't think would happen. |
@lilleyse I think the change to DepthPlane.js is fine right? That's just a code change to shallow clone the radii. Once we clarify that I will submit the PR. Also for reference, the way around the render bug when using webgl 2 is the following: viewer.scene.globe.depthTestAgainstTerrain = false;
viewer.scene.logarithmicDepthBuffer = false; |
Also requested in #11544. |
Requested on the forum: https://groups.google.com/forum/#!topic/cesium-dev/Wb4d5ud7nFw
The text was updated successfully, but these errors were encountered: