How to determine if one billboard is in front of another?

Started by
5 comments, last by Muhammad Haggag 19 years, 3 months ago
When using a billboard system, what would be the best way to determine whether one billboard is in front of another from a given viewpoint? I have thought about using raytracing, but to do this i dont know how to find the vertices for each triangle for each billboard. Any ideas/help/suggestions would be appreciated? Khaine
Advertisement
Well one way of doing this would be to take the average distance that each vertex of the billboards is away from the user. Then compare one average to another.

It really depends on what you mean by '1 in front of the other'.

What about intersecting billboards, do they matter?

If ur not familiar with the maths then

Let A be the user and B be the billboard and D be the distance

D = sqrt( (Ax - Bx)^2 + (Ay - By)^2 + (Az - Bz)^2 )

I think this is right.

Ace
I'll see if I can clarify what im trying to do...

Imagine that you've got a viewport and two billboards, A & B.

We'll say that A is closer to the viewport than B.

What I want to be able to figure out is, when looking at B, is A in the way?

I know how to setup a ray between the viewport and B, and i can use D3DXIntersectTri to see if the ray intersects with a triangle, but how would I get the vertices out of A to test with?
What you can do to see if one is COMPLETELY behind another is to test whether rays going from the biewpoint to the four corners of one go through the other billboard.

ace
Quote:Original post by ace_lovegrove
What you can do to see if one is COMPLETELY behind another is to test whether rays going from the biewpoint to the four corners of one go through the other billboard.

ace


Except when the one completely encloses the other.

Isn't this just a simple bounding box check problem?
Khaine, I think that the simplest way to determine if a billboard occludes another is to take the vertices of both billboards and manually transform them to screen space. (multiply by world, view & projection matrices) Then you only check that if the two 2D-space bounding boxes intersect. Note that the tranformed vertices most probably create a shape of a diamond or another non-square form.
What you want to do is generally referred to as "Occlusion culling" - Finding whether one object occludes another or not. This is a very broad subject, but you specifically want billboards, so it's a lot more simple.

1. Project both billboards to screen space
2. If their projected rectangles intersect, then one occludes the other

This topic is closed to new replies.

Advertisement