Closest point on ray to AABB?

Started by
9 comments, last by s9ghost 12 years, 8 months ago

[quote name='The_Neverending_Loop' timestamp='1311968076' post='4842276']
Iam still going with my initial suggestion of find the value T or D from the Ray to the Walls of the AABB. The shortest one is closest to the screen.


I don't understand how that will work correctly. Forgive me if am being dim but a ray cast from the camera along its forward vector can easily miss a side of the AABB if that side is (almost) parallel to the ray.

What advantage does the ray to plane distance test have over the corner to near plane distance test in this case?
[/quote]

Seems like a problem of precision. (Precision of the order of how close is considered parallel, also the precision of the point of intersection is always +/- a small amount) However when thinking about an AABB (or any box), holding it in front of my face, if I get one side nearly parallel to my forward gaze, there seems to be another side which is orthogonal and shares an edge. Additionally, however, the (almost) parallel side is hardly seen (has little influence on the image seen). So I'm not sure if the (almost) parallel side effect would cause a problem (and could be "fixed" by using higher precision?)

So to sort transparent objects you want to know which are closer and do a front to back rendering effect. So you want to sort sides it seems, rather than objects. (What happens if two objects take up some of the same space? An object partially inside another object?) So you want to deal with the closest side, followed by the next closest side (which isn't guaranteed to be from the same object). I guess that's why it seems like sorting by closest side gives an advantage.

But I've never done transparency so I'm just taking a stab in the dark ^^ Goodluck!

This topic is closed to new replies.

Advertisement