• Advertisement
Sign in to follow this  

Find minimum z where object is fully visible.

This topic is 1772 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

Hello all, I am having trouble with a math problem, and I was hoping someone could shed some light or push me in the right direction.  The problem is as follows:

 

Suppose I have a bounding box, which axis-aligned, and lies on the XY plane.  I would like to find the minimum z-position at which this object is full visible on screen, with no parts of it intersecting the view frustum planes.  

 

Of course, one could take the naive approach of just continually incrementing the z position of the camera until the frustum test passes, but this seems like a very bad approach.  Does anyone have any other ideas for how to solve this problem?

 

Thanks.

Share this post


Link to post
Share on other sites
Advertisement

I read you can do that by doing the projection in the CPU. You use a view matrix to project something into the 2D screen space. You can project the bounding box like you'd inside a vertex shader and check its size, if it's less than a pixel you're done.

 

I've seen it used in terrain rendering algorithms, where you check the seams between different level of details by projecting the points where they intersect and comparing them against a maximum error margin.

 

EDIT: NVM, I totally missed the point of the thread. 2nd time this day :D

Edited by TheChubu

Share this post


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

  • Advertisement