• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Calculate object distance by 2D coordinates only

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

No replies to this topic

### #1Meltac  Members

Posted 22 May 2012 - 08:55 AM

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?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.