• Advertisement
Sign in to follow this  

Calculate object distance by 2D coordinates only

This topic is 2072 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone!

I'm looking for an EASY way to calculate the approximate distance from the camera to an object (in 3D world space) whose ground surface starts at a specific y-coordinate in 2D screen space (in a pure pixel shader).

It's sufficient for a start to assume that the viewer and the object in question both are located on a flat horizontal plane and the eye direction is horizontally parallel to that plane.

Most articles I found do complex matrix transformations which is way over the top in my opinion. There must be a simple formula instead in the form object_distance = myfunction(uv.y) where uv is the current screen texel coordinate. I'm fairly sure it's some polynomial function but I didn't find the exact factors / exponent for it.

Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement