-
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
Don't reproject Web Mercator imagery tiles unnecessarily #4339
Conversation
Its pretty hacky right now, but working.
It looks terrible in current versions of Bing Maps.
Do you have a nice before/after (maybe with an image diff if useful) we could use for twitter and the release blog? |
Ouch. @bagnell and I will brainstorm since the trend is to use less memory, not more. Maybe it is unavoidable. Maybe we can optimize something else. Maybe this is the best we can do. |
@@ -3,6 +3,7 @@ Change Log | |||
|
|||
### 1.26 - 2016-10-03 | |||
|
|||
* Removed an unnecessary reprojection of Web Mercator imagery tiles to the Geographic projection on load. This should improve both visual quality and performance slightly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure we can make the performance claim in practice? In the steady state, this is probably worse.
* @param {Rectangle} [result] The object onto which to store the result. | ||
* @returns {Rectangle|undefined} The modified result parameter, a new Rectangle instance if none was provided or undefined if there is no intersection. | ||
*/ | ||
Rectangle.simpleIntersection = function(rectangle, otherRectangle, result) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add to CHANGES.md please.
|
||
stride = (numCompressed0 + numCompressed1) * sizeInBytes; | ||
|
||
return [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you run this through the formatter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we're using the same editor, so running it through "the formatter" probably doesn't make sense. But I moved the open curly to the same line as the open square bracket and stuff.
@@ -156,7 +156,7 @@ defineSuite([ | |||
}); | |||
} | |||
|
|||
it('reprojects web mercator images', function() { | |||
it('reprojects web mercator images when necessary', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are any other new unit tests needed, e.g., request completely inside +/- ~85 latitude and completely outside?
This could be done at runtime with quick reject tests, right? Do you think that would be cleaner than the current approach, which is...complicated. Or are you suggesting a breaking terrain spec change and doing this offline? The later is not out of the question, it would just have to be longer-term. |
@bagnell can you please also review this when you are available? |
Here are some ideas:
|
Or maybe by using a separate buffer for the heights when rendering in this view. |
I think it can be reasonably done at runtime. For heightmap terrain it's easy, for quantized mesh it's a bit of work, but not too hard. I'm not sure the overall complexity would go down here though. ;) |
Diff (used https://huddle.github.io/Resemble.js/): It's most obvious in contrasty bits, so the labels mostly in these screenshots. Save the two images and flip back and forth between them to really see it. On contrastier maps (like Bing Maps Roads for example), lots of map features look noticeably sharper. Overall, it's admittedly fairly subtle, though. |
Ok I think this is ready. Of course, it's up to you guys if you think the improvement is worth the extra float. I tried and failed to measure any performance or memory usage difference with this change. Actually, the memory usage of the GPU process in Chrome was consistently 10 meg (out of 500+!) lower after this change, possibly just because there's less texture creation now and perhaps Chrome doesn't clean up old ones very aggressively? I'd be interested in the options I mentioned above for eliminating the height or the two sets of texture coordinates in order to reduce the amount of vertex data, but it's not straightforward and I think it's more important to do some other things first, like improve the tile load process. |
I modified the Path example to fly over the continental U.S. with the camera pointed straight down to test performance. I ran MSI Afterburner in the background to watch results, keeping as many other things constant as I could (no other windows open, opening from an empty chrome, etc.). VRAM usage was ~10mb lower on the new version, but RAM usage was ~100mb higher. GPU and CPU usage was about the same. |
@bagnell could you please evaluate this at the bug bash? |
This looks good to me. For the extra float, I'll add the ideas from @kring above to an issue. |
Thanks again @kring. I moved the CHANGES.md update to 1.27 in |
Previously, Cesium would reproject all Web Mercator imagery tiles to Geographic on load. This had two costs:
And then, of course, Cesium would reproject those Geographic images onto the globe with the normal 3D perspective projection. So effectively, Cesium reprojected imagery tiles twice.
After this PR, Cesium includes Web Mercator texture coordinates with the terrain tiles, so Web Mercator tiles can be projected directly onto the screen without going via Geographic in most cases. Some notes:
height
attribute in most cases, especially when using 3D only. And I wrote some really hairy code to support this (in theterrain3
branch if you want to gaze upon the horror). But in the end it was just too hard and I gave up.