Calculating 3D position from 2D mouse coordinates

Started by
0 comments, last by Sergi_ 14 years, 3 months ago
Hi, I would like to map 2d coordinates to a 3d plane where z=0. I realise that transforming viewspace coordinates using an inverse of the projection matrix will give me this, but the problem is getting the screen z depth at any given x,y point. There is no z-buffer to read from, so this must be calculated just from the mouse coordinates.
Advertisement
Nevermind I got the answer. Casting a ray from viewspace where z=0 to a far away point will give me the z distance (if it intersects).

This topic is closed to new replies.

Advertisement