Virtual oclussion culling for AI in multiplayer game

Anyone know of a ready to use system for a server to determine if any player sees a bot?

I could develop something custom,but it feels a common problem that someone should have fixed already

iirc, I used custom raycast system for this - but i think the easiest way is just use renderer isvisible.

Raycasting (not baked) is too expensive for oclussion culling. renderer isvible requires a camera

edit: If I do it custom I will use a quad tree in combo with navmesh and raycasting to determin viability between quads

Why do you think raycasting is too expensive? You’re looking at how many players?

2 Likes

12 players 200 bots maybe, plus our server is also a client, potentially

Is this where I point to Unity DOTS? :stuck_out_tongue:

Umbra is not using racasting for a reason. Its not viable for that kind of task.

edit: We use ECS already btw

Oh, thats a ton of bots. Yeah, you need a more robust/high performance system.

I wouldn’t expect this to be an off the shelf problem, since dealing with visibility between 200+ dynamic element pairs is a kind of unique situation.

You would probably need to bake a lot of raycasts to build out culling volumes. Use that to filter batches, then use minimal raycasts to verify the pairings that cleared your initial filters.

Yeah, I need something like Umbra but without the camera. I can recreate a crude umbra system with a quadtree and raycast every other cell in the tree at baketime.

Well, you still probably want to bake camera - you have dynamic fov or fixed?

its a FPS shooter, camera is completely dynamic. But I can use the navmesh plus 2.5 meters up to get a good queryable area.

edit: so a 2d quad tree is enough, but baked with 3D raycasting at bake time

I mean, when you’re testing visibility - do you need to actually do proper camera rotation check + frustum cull, or are you just testing for obstructions?

Frustum cull is peanuts? :smile: Its the occlusion part that is hard :smile:

edit: At runtime I just need a crude visublity check like umbra, it needs to be inclusive. like umbra

edit2: if we had access to Umbra API Im sure they support virtual cameras. But the entire umbra API is hidden for us :confused:

Yeah thats true, frustum cull would just be a quick filtering check.

Was about to say the same thing - its really a shame there’s no umbra access.

I’d actually be interested in this kind of thing, hand rolling occlusion probably isn’t super complex, but I’d like to follow a real effort to implement a solid system.

So if you really dive in, share some progress here! :smile:

1 Like

Give each bot a camera; render players as red, environment as black, and other bots as white; render to a texture; convert the rendertexture to texture2d; use a for loop with GetPixel() for each texture/bot. Easy-peasy.

1 Like

First of all I think that what he need is to know if particular bot sees the particular player.
And his post is just a mistake.

And rendering to texture is just not viable option.

The fact is that visibility is super difficult problem
You will have a hard time finding such a system, I was looking for one myself.
I was more lucky since I have a tower defence kind of game. So I can store visibility for my towers once calculated.

The biggest question is how big is your environment and how precise your visibility must be. Is the center point of bot/player satisfactory ?

No, AI detection is already implemented so it’s not a mistake, here is a demo of that.

This is so we only send AI state info to relevant players and alos disable animation etc for bots that are irrelevant

One possible optimization would be to come up with a way to create a bunch of zones in the map, and then only send individual players data based on which zones they should be able to see. This could be done using bounding volumes or it could be done using a simple 2D grid. This approach would not be perfect, but it would at least cull the data activity for many of the units. In the simplest form, you could simply use this to disable animations for units behind the player, but enable the animations for all of the units in front of the player regardless of actual ability to see the specific units.

Actually, since this is for checking to see if a player can see other units, this idea could actually work well as an additional hidden camera in the game client.

These suggestions are bad.

The best bad suggestion would be having clients send visibility data to server (you distribute the work here). But that’s also bad.

Anders is correct that building out proper occlusion system w a quad tree or spatial hash is right direction. I dont think using navmesh raycasts as optimization will help (but it depends on specifics)