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

This topic is 5019 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
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

##### Share on other sites
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?

##### Share on other sites
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

##### Share on other sites
Quote:
 Original post by ace_lovegroveWhat 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?

##### Share on other sites
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.

##### Share on other sites
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

1. 1
Rutin
26
2. 2
3. 3
4. 4
5. 5

• 9
• 11
• 10
• 13
• 20
• ### Forum Statistics

• Total Topics
632948
• Total Posts
3009391
• ### Who's Online (See full list)

There are no registered users currently online

×