-
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
Guard against negative height samples in HeightmapTerrainData #4103
Conversation
@chris-cooper I could be missing something, but I don't see how this change makes sense. First, your claim that this should still allow heights below WGS84 zero. Are you sure? It looks like to me like all heights created by upsampling will be clamped at zero. That Now it's true that HeightmapTerrainData heights are stored encoded. The encoding is defined by the Because the encoded height buffer is a It should only happen if your heights are outside the valid range of your So how can that happen? Well, sometime around when you started seeing the problem, Cesium started encoding terrain tile meshes in a clever way to save memory. It also started upsampling from meshes instead of upsampling from the original height data. The heights are encoded with So I'd suggest:
|
By the way the |
Thanks for having a look @kring. I've moved the clamping as you've suggested. I tried changing compressTextureCoordinates and decompressTextureCoordinates but that didn't fix the problem. |
@chris-cooper I've just committed what I think is the right fix to texture coordinate compression to the |
Chris and I spent awhile looking at his problem in more detail. Basically, here's what was happening:
So the solution here of clamping the heightmap-encoded height value to 0 just before writing it into the heightmap buffer is reasonable. The only potential problem is some other terrain provider (not I'm going to hold off on merging this a bit longer in order to think about how much of a problem this actually is, and what we might do about it. |
This used to look good, but these days Bing Maps aerial imagery looks much better without the gamma correction.
@chris-cooper can you try out this branch? You'll need to add the new fields, |
Thanks for your time @kring. Sorry it took longer than expected to investigate. Yes your fix work and is safer than the one I proposed. I've updated the spec. I notice the ternary operators will fall back to the old behaviour if lowestEncodedHeight or highestEncodedHeight is undefined which allows the other specs to pass. I think compressTextureCoordinates should still be fixed like you proposed, but probably in a separate PR. |
Should this include an update to CHANGES.md? If so, please update in master. |
Nevermind, I see #4354 (comment) |
We are getting some strange artefacts with heightmap terrain that were introduced somewhere between Cesium versions 1.15 and 1.18.
Tiles outside the main dataset area are getting pushed up. On further investigation some of the remapped heightSamples from interpolateMeshHeight() are below zero, and setHeight() then encodes them as a value close to 65535 instead of zero. I notice in this commit an
| 0
was added...Maybe @bagnell can provide some insight as to what that was guarding against as it may no longer be needed.
Note that this should still allow elevations below WGS84 zero. It's just the encoding provided by setHeight() doesn't seem to be built to handle the negative numbers being generated by interpolateMeshHeight().