Skip to content
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

The positions from #scene.pickFromRay not on model surface #8439

Closed
criyson opened this issue Dec 5, 2019 · 9 comments · Fixed by #8850
Closed

The positions from #scene.pickFromRay not on model surface #8439

criyson opened this issue Dec 5, 2019 · 9 comments · Fixed by #8850

Comments

@criyson
Copy link

criyson commented Dec 5, 2019

Sandcastle example: link

Browser: Chrome 78.0.3904.108

Operating System: mac OS

WX20191205-235541@2x

Sometimes I can get the right intersection with ray and model, but most of time get the position is inside the model (Insufficient accuracy).

@lilleyse
Copy link
Contributor

Hm this seems to be hardware dependent. I see inaccurate positions like this on my 2015 Macbook with the AMD graphics card but not with the Intel integrated graphics nor on my linux desktop with an NVIDIA card.

@liyangis
Copy link

position outside the 3Dtiles model
link
image

@liyangis
Copy link

liyangis commented Mar 25, 2020

image
sometile it's ok

@lilleyse
Copy link
Contributor

@liyangis what GPU do you have? The accuracy issues seem to be hardware dependent.

@liyangis
Copy link

@liyangis what GPU do you have? The accuracy issues seem to be hardware dependent.

image

@liyangis
Copy link

image

@dennisadams
Copy link
Contributor

I managed to (sometimes) reproduce the inaccuracies in the examples of @criyson and @liyangis on my linux desktop.
It appears that the inaccuracies occur when the pick's orthographic frustum bounds are retained from the scene's prespective frustum bounds.
In @criyson's example, when the pick is accurate, the frustum splits are [0.1, 100, 2265.88...] (the last plane might vary, depending on resolution, due to SSE).
When it is inaccurate, the frustum splits are [0.1, 100000000, 100000000000000000], which is based on the logarithmicDepthFarToNearRatio (while it should use the farToNearRatio like in the previous case).
So I believe that in the second case the inaccuracies are caused by precision issues (possibly hardware dependent).

My attempted workaround was to force a frustum update by setting scene.view.updateFrustums = true in Picking.js's getRayIntersection.
But luckily this is unnecessary since I've found out that #8850 fixes the issue.
As @IanLilleyT wrote over there:

Problem is, the heuristics it was using to decide if the frustums needed to be adjusted was not triggered when switching to orthographic camera, resulting in the orthographic transform using near / far bounds meant for logarithmic depth (since perspective camera uses logdepth and we just switched away from it). This resulted in an extremely tiny value in the orthographic matrix which ended up becoming 0 by the time it was converted to float32 for the shader.

@lilleyse
Copy link
Contributor

@dennisadams great find. #8850 fixes this bug on my 2015 Macbook as well

@zouyaoji
Copy link

@lilleyse
The position from #scene.pickPosition not on a billboardGraphics surface, too, it throughs the billboard to the surface of the earth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants