Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


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.

  • You cannot reply to this topic
No replies to this topic

#1 Meltac   Members   -  Reputation: 461

Like
0Likes
Like

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?

Sponsor:



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.



PARTNERS