Sign in to follow this  
phaelax

line of sight

Recommended Posts

I have a line of sight between two ellipsoids, thats not my problem. I want find out how much (what percent) of the ellipsoid is visible to the other. I'm not really sure where to start with such a thing.

Share this post


Link to post
Share on other sites
Hopefully, this will explain better.
Here, 50% of the player is visible to the bot. All I know to do really is just cast a line between the two objects and get a simple yes or no on an objects visibility to another.

[IMG]http://img.photobucket.com/albums/v204/phaelax/visibility.jpg[/IMG]


The idea is so that a bot won't see a player who has a toe sticking out from around a corner 1000 yards away.

10% -> bot thinks it sees something, takes caution
20% -> bot spots an object and goes to investigate
50% -> bot runs to attack

I hope this gives you a better idea what I'm trying to do.

Share this post


Link to post
Share on other sites
All I can think of is casting a number of rays across the object's surface and counting how many are stopped by obstacles.

Share this post


Link to post
Share on other sites
Well this is just an idea to throw out there and I'm not familiar with modern graphics hardware but I think it may be possible to implement.

When you determine line of sight render three snap shots (of what would be the bots vision).

1. With the object in the scene.
2. With the object removed.
3. Only the object.

Use image 3 to mask off an area in images 1 and 2 then subtract image 1 from 2. You can use the total pixels that aren't blank in image 3 and the total number of pixels remamining in the final image to determine a % visiblity.

I suspect you could do this very quickly in hardware. Remember you only need to render the shaders that affect visibility. The snapshot could be rendered to a small surface also.

Not a maths solution though.

Share this post


Link to post
Share on other sites
Quote:
Original post by Metorical
When you determine line of sight render three snap shots (of what would be the bots vision).

1. With the object in the scene.
2. With the object removed.
3. Only the object.

Use image 3 to mask off an area in images 1 and 2 then subtract image 1 from 2. You can use the total pixels that aren't blank in image 3 and the total number of pixels remamining in the final image to determine a % visiblity.


This would seem to require 3 passes, plus that image subtration thing...
On top of this, multiply whatever it costs by the number of enemy bots active in game.
That gets expensive very fast, I'd say no.

This %visible concept is overkill I'd say. You don't need that kind of accuracy to determine if the player is hiding or not.
As suggested, doing several line of sight tests for different parts of the player's body is a good idea. It's a heck of a lot cheaper than finding the exact % of pixels visible, and you should get similar results.
How about a 3 ray test? middle of body, then the extreme left and right edges of the player silhouette?
That should give you enough stages of visibilty to work with.
just one edge ray visible - an arm sticks out around a corner
one edge and the center ray - player is half peeking around corner
all 3 rays visible - player is totally exposed

Share this post


Link to post
Share on other sites
I agree with that answer. It's not mathematically 'nice', but it's sure as hell practical and fast for game purposes. I'd use five rays, one in the middle and one at each 'corner', to allow for people half-hidden behind low boxes etc.

Share this post


Link to post
Share on other sites
From what I got reading the distance is also an issue, you could setup a view cut of distance so if the target is beyond X feet/metres or what ever measure you dont check as many rays, or no rays at all ... you can also have this be progressive with multiple cutoff disances for the differing rays

Share this post


Link to post
Share on other sites
1. You are only rendering a small chunk of the scene with minimal options e.g. 50x50 pixels with no FSAA or AA, no fancy shaders etc. The only hit you might take is the oclusion but there's ways to cut this down. Therefore it's not an extra 3 passes but probably an extra 0.1 passes in terms of processing speed.

2. The operations are very quick. You're ray-elipse intersection tests are going to start to add up in operations. This is just a heap load of additions.

It's an accuracy vs speed arguement. For low accuracy ray casting will be quicker, For high accuracy using *dedicated* hardware to do the calculations for you will be quicker.

Share this post


Link to post
Share on other sites
Thanks for the insight. I think I may end up going with the 3 rays idea, as well as taking the distance into consideration. If any of you have played Thief, thats basically the kind of system I'm after. So I don't need an exact percentage or perfect accuracy.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this