cesium: Performance degradation with large point clouds and show condition on M1 Mac

Hello!

I observed a performance degradation when rendering large points clouds that use the conditional show attribute. I’m certain that the performance was much better, in a project I’m using such a technique to filter for attributes from the tileset’s batch table and now the framerate drops a lot when the filters are applied. Maybe it only affects macOS / arm architecture — on a Linux / Intel workstation with NVIDIA GPU it works fine.

A quick performance monitoring in the dev tools showed that readPixels consumes a lot of time which is called for scene picking. Is there a way to turn off picking for Cesium3DTileset ? That might help in my case.

I can reproduce this in a sandcastle with the Melbourne point cloud, and you can see the framerate drops from ~100 fps to ~10 fps when zooming in:

https://user-images.githubusercontent.com/449600/236436953-c1d84f1b-3a67-4a1e-a663-8de8214e834a.mov

Sandcastle example: https://sandcastle.cesium.com/#c=hVNha9swEP0rRxiNA0FO10K71AkbKYyMjkBT9slfFPkai8m6IJ2TuiX/vXJsZ0nZmMFg3b33dO9JjmP47qRlmKHXZfFjCVIp9B6YoKLSgSYL0ntkn1pF1jNsNe7QwQQs7lqa+HWoRWlPHdYzsiy1RZf2BnepTW0kfWUVRAOYTOEttQDsquYDWkGBL4w2i1rFptgsru6ftEE/t36Disn91C/a1sI1uxmKawBymErupO7siDM+snh2VMzJfqsNzbPo+urLzW0n1EqIDWnLM0Nltsxlpu06iLaThkdymLKUHHIZBxMlDo8trPCeCnzQ65wD7T/tJTu0a87HcPlPzGPYv/R/EPu7s8S8Qoti43ShWW/RC5llUWujc9XE0RJeiYon+gjpjHuuDJ6f62l+y7odHZM4xLTUrziG66MBRYbcGPpuvYo+j0bD9h30jwif0y4APr3NFg+Lx71wMIWRuIGLCzipJaF2229NN3PuQUlWOUToHLlBdyT18ZNBYWjddhp0aveDqP7uDXvJwdm0rn/VxYYcQ+lMJETMWGyMZPTxqlS/QwbK+5qUxB0lyfQWdDb5y9UGZcKfETrPpTF1EmlvmsQBf0YzdLhEiy06I6sAqcdI8svpQ9MQQiRxWNabfuQykVlJd6L7Dg

Browser: Google Chrome Version 113.0.5672.63 (Official Build) (arm64)

But similar experience with Safari / Firefox

Operating System: macOS 13.3.1 (a) on M1 Max

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 21 (9 by maintainers)

Most upvoted comments

I have a similar observation with a large performance hit on integrated Intel graphics (in particular Intel® UHD Graphics for 10th Gen Intel® Processors as in the i7-10510U). The issue does not show on the dedicated GPUs I have access to.

I have found a one-line fix, that improves the performance a lot in my case:

In packages/engine/Source/Shaders/Model/CPUStylingStageVS.glsl in cpuStylingStage(), comment out the following line:

void cpuStylingStage(inout vec3 positionMC, inout SelectedFeature feature)
{
    float show = ceil(feature.color.a);
    //positionMC *= show; // this line causes the performance hit

    #if defined(HAS_SELECTED_FEATURE_ID_ATTRIBUTE) && !defined(HAS_CLASSIFICATION)
    filterByPassType(positionMC, feature.color);
    #endif
}

Note that you may need to re-build Cesium to re-generate the CPUStylingStageVS.js file. Otherwise the changes won’t take effect.

To anyone who is able to reproduce this performance issue, please check if this improves the performance for you.

My theory is as follows:

  • the line sets positionMC to zero, in case it is hidden (i.e. show is zero)
    • I think this was intended to move it off-screen, skipping the rasterizer and making it invisible
    • however, this is the wrong place to do it: positionMC is in model coordinates (not screen space yet), so we just move the points to the origin of the tile / tileset, which is likely to still be in view
  • the “hidden” points all get rasterized in one position, causing significant overdraw, which causes the performance hit
  • the “hidden” points finally get discarded in the fragment shader

A proper fix for that would be to actually move the hidden points off-screen, i.e. setting gl_Position accordingly.

Thanks @ulrichson ! I’ll try to take a look by the end of this week 😃

Hey @ulrichson,

Sorry about the delay. This completely slipped my radar. I’m happy to take a look – I should have a moment by the end of this week.

There was a fairly large refactor that went in with that change. @j9liu would you be able to recommend a place to start looking regarding changes from ModelExperimental related to performance picking point clouds?