-
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
GroundPolylinePrimitive and Ground Primitive materials render poorly on newer mobile devices #6735
Comments
There seems to be a problem with materials on ground polygons too... maybe this is depth buffer related? |
At least part of this is weird depth buffer stuff: Sandcastle to reproduce. |
Part 2 of the problem (aka the part that's probably my fault): Sandcastle. I'll keep updating with notes. |
Actually, to reduce noise I'm going to move tracking for this into a separate issue. I'm pretty confident it's a similar problem under the hood. |
Another problem: Sandcastle on a deployed branch
On the iPad, going to a view like this seems to sometimes ignore that depth testing is supposed to be disabled: The depth test also seems to be against the "weird" depth buffer observed above. |
So that's fixable, but depth texture problems are... still a problem. |
Some additional reading:
Maybe the problem is that we're packing the depth ( [EDIT] This is what /**
* Packs a depth value into a vec3 that can be represented by unsigned bytes.
*
* @name czm_packDepth
* @glslFunction
*
* @param {float} depth The floating-point depth.
* @returns {vec3} The packed depth.
*/
vec4 czm_packDepth(float depth)
{
// See Aras Pranckevičius' post Encoding Floats to RGBA
// http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * depth;
enc = fract(enc);
enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);
return enc;
}
|
@chris-cooper in the meantime, you might be able to adjust the near/far ratio in your scene to get better results for the specific use case.
I'm seeing that a near/far ratio of 50 seems ok for viewing lines at distances of centimeters to a couple meters. For further distances it seems to depend on the view angle. It might also depend on the terrain complexity at the particular view location. But having to tweak far/near ratios for a specific platform really isn't ideal, I'll dig deeper on if we're unintentionally causing precision issues. |
Now I have learned two things:
So copying globe depth to a float texture instead of the current packing isn't going to work. @bagnell also proved out that the packing isn't at fault here by providing the globe depth stencil texture directly to this on an experimental branch, we still had artifact problems. |
So I guess the conclusion is, depth texture precision on modern iOS devices just isn't sufficient. One more idea that @bagnell suggested is re-rendering all the terrain (and eventually 3D Tiles) to produce a depth texture instead of relying on the depth texture feature. If it worked this would also be an awesome addon for enabling support on platforms like Internet Explorer and lower-end mobile devices that don't have depth textures builtin, and it would also impact a lot of other Cesium features that depend on the depth texture. Could also be a lot of work to implement, so unfortunately I don't know how soon I'll be able to evaluate this. |
@chris-cooper another development: polyline-on-terrain problems don't seem to be as severe on the iPad 4. We've been testing (and reproducing the problem) on a first-generation iPad Pro, which supposedly has a similar SoC [EDIT] similar to the MP2F2LL/A iPad 5 mentioned above. If you have older hardware available for your use case, that might also be an option. |
Relevant issue on three.js: mrdoob/three.js#9092 |
Thanks for the extra info @likangning93 |
Also reported by @Spec1alFx in #7377 |
Just since it hasn't been written down here yet, fallback possibility: use the regular multi-pass algorithm with the polyline geometry + vertex shader, disallow materials beyond color. |
Some notes from the couple odd times I got to play around with this:
On Sandcastle, with a custom shader on a primitive (Updated 2020-07-28) The above Sandcastle computes UVs using depth from just drawing a Rectangle geometry, this is NOT going through our depth packing code or even using a depth texture. The shader splits the display to show computed UVs on the bottom and a diff between depth-by-varying and depth using |
I put together a small example of this here: https://likangning93.github.io/webgl-examples/tests/depthPrecision/, code at https://github.com/likangning93/webgl-examples/blob/gh-pages/tests/depthPrecision/webgl-demo.js. Similar to the above, the right third of the webgl display here is a diff between depth-by-varying and The red bands indicate a discrepancy here across the depth range. For comparison, here it is on my Qualcomm 425/Adreno 308 Android device: |
Posted to the webgl dev list: https://groups.google.com/forum/#!topic/webgl-dev-list/O34GBqZBfmk |
Really encouraging to see some activity on this, good luck @likangning93 |
I'm testing #9064 this on a Lenovo IdeaPad Duet Chromebook. Good results so far. There's subtler discontinuities on frustum switches but it's so much better than before. I tested every Sandcastle in this issue (@likangning93 whew -- lotta work went into this github issue). Note: I don't see the banding artifacts in #6735 (comment) so this device must have good enough depth texture precision. Need to test on the iPad pro next. |
@lilleyse I hope the polylines gifs got mixed up.
I've also noticed some frustum artifacts in entities and in classification. |
@dennisadams that's a different issue that @IanLilleyT started looking into: #8953. |
Actually this bug appears to predate #8953 as described there. |
These lines dance as the camera moves. This is on an MP2F2LL/A.
The text was updated successfully, but these errors were encountered: