I used the depth map to pick up the coordinates, but it didn't work

I used the depth map to pick up the coordinates, but it didn’t work. Can someone help me see the problem in this example?

What do you mean with it didn’t work?

Perhaps my description is not very clear, and the effect it produces is not what I want. I want him to have the scene. pick method but with the effect of pickedPoint, but the pickedPoint I calculated is always at the camera position.

maybe this example can help you to find the picked point on the mesh
Colorize facet mesh | Babylon.js Playground (babylonjs.com)

In this example, the scene. pick method is used to pick up the scene coordinates when the mouse is moving. Considering the performance of scene. pick, I used depth maps to calculate the scene coordinates. I have seen this GPU picking point and normal example And I only need to obtain the position, no normals. So I calculated coordinates from the depth map based on the code in the example, but it was not successful.

DepthPick | Babylon.js Playground (babylonjs.com)
I’ve fixed this example for you, and you’ll know why by comparing the centerDistance output from line 36 to line 37.
In addition, GPU pickup and ray pickup have their own advantages, and GPU pickup may not necessarily be faster than ray pickup in some scenarios. For example, if the space is divided.

3 Likes