0

I have a camera projected vertex of four components:

screen_space_vertex4 = local_vertex4 * world_view_projection_matrix

// Homogeneous coordinates to Cartesian coordinates.
screen_space_vertex4.x /= screen_space_vertex4.w
screen_space_vertex4.y /= screen_space_vertex4.w
screen_space_vertex4.z /= screen_space_vertex4.w

This puts screen_space_vertex4.z in the -1;1 range.

I try to get the world space distance between my camera and my vertex, but a simple mapping of near and far to -1;1 doesn't work.

What are the math for this?

I know there are near, far, fov and ratio involved, but I can't find the proper equation.

Narann
  • 670
  • 2
  • 7
  • 17
  • for perspective projection like gluProjection see: [glReadDepth](https://stackoverflow.com/a/51130948/2521214) ... – Spektre Apr 15 '22 at 13:43

0 Answers0