-
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
Clipping planes weird behavior on certain Android devices #9023
Comments
Thanks for the detailed write up @dennisadams @likangning93 could you confirm that adding a small epsilon is an ok fix here? |
Sorry for the slow response! The packing/unpacking technique didn't look familiar enough to me despite what There's some reference to "discussions offline" but I wasn't able to find a link to anything explaining how this works. Fortunately I'm able to reproduce this combination (planes moving backwards + no float texture support) on an @dennisadams out of curiosity, what device are you testing on? |
I put together a smaller Sandcastle for testing this, it's here on the current deployment and here on my branch's deployment. On the
[EDIT] ignoring the alpha weirdness on the props, this is looking much closer to what I see when testing either link on desktop (well, Intel UHD 630/Linux). Sadly no dice on the @dennisadams can you confirm? |
In my case the two screenshots look pretty much the same:
But that's because they are both good. Probably my problems were with the clipping plane in a different position. |
Awesome, nice quick fix @likangning93. Could you open a PR? |
@likangning93
This isn't the best place for this discussion, but I didn't want to split it across all issues. A couple of general questions:
It may be your lucky day. |
We should profile to see, but performance is a lesser concern if
Yes, and that's something we're not checking everywhere. See https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices#Be_precise_with_GLSL_variable_precision_annotations |
@dennisadams could you open a PR and copy your notes over there? I don't have a good device to test with but @likangning93 does. Thanks for looking into this. I hope we can knock out as many mobile rendering bugs as possible. |
I tried the clipping planes sandcastle on an Android device and got this bug where at the top part of the model, the clipping plane is clipping in the wrong direction.
There already is an open issue - #8061 about clipping planes not working on certain Android devices, but in my case it does technically work and seems like a different issue.
This device doesn't support float textures, and so it uses getClippingPlaneUint8.
The glsl code from
getClippingPlaneUint8
callsczm_unpackFloat
in which the problem occurs, right here:cesium/Source/Shaders/Builtin/Functions/unpackFloat.glsl
Line 21 in 952ad67
If I add a small epsilon value inside
floor
, e.g.float exponent = floor(temp + 0.01);
everything works well.From my understanding, before the "flooring"
temp
should either be an integer or an integer + 0.5.My current guess is that because of precision issues on my device,
temp
's value turns out to be slightly less than the integer it's supposed to be, and this messes up the exponent and consequently the sign of the float.The only other place using
czm_unpackFloat
(if float textures are not supported) isBatchTable.js
. I wonder if this can cause other issues on some devices.The text was updated successfully, but these errors were encountered: