I have a single mesh with up to about 25000 thinInstances that are just spheres. I have access to both the thinInstance matrices and the positions.
What is the best way to find the closest (depth from screen) thinInstance/position to a screen coordinate?
I thought about using GetFinalMatrix from the viewport and camera view then TransformCoordinates on each position with that single matrix. Finally, iterate and test each result within a square or radius (in screen coordinates). If I iterate in depth order, then I think I end up with a depth-ordered list of picked positions (or stop at the first). If this works, I like that I can choose the size of the (virtual) “picking ray” (via the square size or radius).
Is there a faster/better way?
I don’t really have a need to test all triangles of each thinInstance sphere.