CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.73k stars 3.45k forks source link

Globe atmosphere does not work on Android/Chrome #10442

Open gilmotta opened 2 years ago

gilmotta commented 2 years ago

Hi,

I am testing CesiumJS to use it in my mapping project. CesiumJS works well on my desktop it seems but on my Android Galaxy S21 with Chrome version 102.0.5005 I can't see the globe. I only see a black ball. The same with Firefox version 101.1. on the same device.

I don't know if this is a good comparison but WebGL Earth demo works fine.

Thanks, Gil

ggetz commented 2 years ago

Hi @gilmotta, could you visit https://webglreport.com/ with the android device and take a screenshot of the results?

Also what CesiumJS demo are looking at? Do you have a link?

AndresPozo commented 2 years ago

Hi, I have the same problem in a Samsung Galaxy Tab S7 with Android 12 and an old LG G6 with Android 8. When the viewer is zoomed out to show the full globe it only draws a blue outline and black globe. If the viewer is zoomed in to show a country or smaller areas the visualization is correct. This happens for all the examples in Sandcastle, including the "Hello World" example.

The results of https://webglreport.com/ are attached to this message. Screenshot_20220610-183537_Chrome Screenshot_20220610-183639_Chrome Screenshot_20220610-190143_Chrome

AndresPozo commented 2 years ago

Hi again, I have another clue: I think this problem is related to the GroundAtmosphere effect. After disabling it with "viewer.scene.globe.showGroundAtmosphere = false" the globe gets rendered right. This can also be tested with the example Atmosphere in Sandcastle.

ggetz commented 2 years ago

Thanks @AndresPozo.

@sanjeetsuhag Is it possible this has to do with the latest atmosphere updates?

sanjeetsuhag commented 2 years ago

@ggetz Yeah, it's likely linked to the recent changes.

@AndresPozo In the Atmosphere Sandcastle, in the Ground Atmosphere settings, would you be able to try increasing the values of Lighting Fade Out Distance and Lighting Fade In Distance and see if that affects the result at all.

AndresPozo commented 2 years ago

@AndresPozo In the Atmosphere Sandcastle, in the Ground Atmosphere settings, would you be able to try increasing the values of Lighting Fade Out Distance and Lighting Fade In Distance and see if that affects the result at all.

It doesn't change anything Screenshot_20220613-182641_Chrome

sanjeetsuhag commented 2 years ago

Based on some additional testing, the problem may be somewhere in core scattering loop of the atmosphere because the rayleighColor and mieColor are both black.

sanjeetsuhag commented 2 years ago

The only problem here seems to arise from the usage of per-fragment ground atmosphere. The following causes have been ruled out:

sanjeetsuhag commented 2 years ago

Source: https://deviceatlas.com/blog/most-used-smartphone-gpu

image

From my limited testing so far, this issue affects devices with Adreno GPUs. PowerVR GPUs show up more often, in lower end devices.

image

In the US, however, Adreno GPUs are slightly more popular.

andersan commented 1 year ago

@sanjeetsuhag any idea how to fix this issue? is there a feature I can turn on/off that will cause this not to happen?

sanjeetsuhag commented 1 year ago

@andersan No fix for this yet. Setting scene.globe.showGroundAtmosphere should disable the atmosphere effect on the terrain.

andersan commented 1 year ago

@sanjeetsuhag thanks, that fixed the bug for my use case! (Android chrome, oneplus android device, using Cesium via Resium+React.js)

ggetz commented 1 year ago

@AndresPozo or @gilmotta, could you give this a try using the latest version? We had some performance improvements go in related to atmosphere

AndresPozo commented 1 year ago

@AndresPozo or @gilmotta, could you give this a try using the latest version? We had some performance improvements go in related to atmosphere

Still does not work using Cesium 1.105.1

ggetz commented 1 year ago

Thanks for testing @AndresPozo!

epiphyllumbl commented 10 months ago

Still does not work using Cesium 1.110.0

arinmodi commented 6 months ago

Facing the same issue, is any one found any fix ? I don't want to disable the showGroundAtmosphere. Thanks

na9da commented 5 months ago

I suspect the drop in precision for structs described here is what is causing it. For affected GPUs, numeric values within a struct have only half the precision of regular non-struct values.

They also have a page which lets you test the struct precision on your devices. My Pixel5a reports 10 for struct floats in fragment shader and 23 for regular float values.

image

The relevant code path might be especially sensitive to change in precision as it computes exponentials in a few places.

To test the theory, I tried swapping structs with plain fields along the code path and the globe gets rendered ~correctly~. AFAICT the change hasn't short circuited any code path, so must be correctly handling the precision. (You can test the change by building the code and opening the sandcastle home, the globe should be visible if it worked.)

I'm not sure what a correct fix could look like as it also could affect other code paths that are sensitive to precision and replacing structs might not be easy. In this ThreeJS thread they talk about working around by selectively replacing structs with plain fields where they find it to be a problem.

na9da commented 5 months ago

With the changes, although the globe is fully visible - the rayleighColor and mieColor does not match what I see in desktop. So there could be more to it?

desktop: image

mobile (with the changes): image

na9da commented 5 months ago

I have pushed some more changes to replace the return struct in czm_rayEllipsoidIntersection function and now the rendering in mobile seems to match the desktop.

mobile (with latest changes): image