How can I get the 3D position of a point corresponding to the point on 2D camera view?

Hi all, I was wondering if you have some great ideas about this: what I want to do is, for every point (or pixel) my mouse stays on a 2D camera view, I would like to get its corresponding 3D position. The following picture might help to explain my goal:

Like when my mouse stays at a blue point on the red cube (right side), I want to know what the point in the 3D scene is (left side). I tried to do ray casting, but failed because I do not correctly understand the mapping between the 3D and 2D for the perspective camera view.

I would greatly appreciate any help!

2 Likes

Hi Lurking-Ninja, thanks for sharing the material! Very helpful.