Hiding AI that player can't see.
by penbit · in Torque 3D Professional · 11/10/2009 (4:46 pm) · 6 replies
Is it feasible to implement a system like groundcover but for ai?
When the player is faraway, the character meshes will be hidden, but will pop-up/fade in when the player is close to them. Or just simply trigger them on/off when the player is not near.
Number of character meshes do have negative impact on performance as it seems. I have like 10 patrolling ai, behind a house, I don't see them at all but still the performance drops naturally. If I delete all of them, from the same position, performance gain is obvious. So it would be nice to delete/insert these 10 patrolling ai at positions that I can't see.
So I'm talking about like a crowds system that you can see in most rpg(oblivion, risen). What would be best way to handle them? Since, at the moment I can't work with zones in outdoor scenes, I'm thinking of best possible alternatives.
When the player is faraway, the character meshes will be hidden, but will pop-up/fade in when the player is close to them. Or just simply trigger them on/off when the player is not near.
Number of character meshes do have negative impact on performance as it seems. I have like 10 patrolling ai, behind a house, I don't see them at all but still the performance drops naturally. If I delete all of them, from the same position, performance gain is obvious. So it would be nice to delete/insert these 10 patrolling ai at positions that I can't see.
So I'm talking about like a crowds system that you can see in most rpg(oblivion, risen). What would be best way to handle them? Since, at the moment I can't work with zones in outdoor scenes, I'm thinking of best possible alternatives.
#2
But I'm having a hard time understanding how would a lodded(is that even a word) mesh would help even it is not on the screen? I though lods help for longer viewing distances. So if there is an ai behind a wall, player doesn't see, the engine is rendering the lowest possible lod? In this particular example, the player is a few feet away from the ai, only a thin wall is blocking them?
An Alert structure depending on distance does really make sense. Or maybe a coming up an occluder solution that doesn't render the ai behind it. Which brings me the question which one is more expensive, clever ai or good looking ai?...(even with the lods)
Still though, I'm trying to understand how assassin creed's crowd structure is possible. It doesn't look like there is streaming....anyway...
11/10/2009 (5:21 pm)
Hmmmm....interesting stuff you've there, Steve, thanks a lot.But I'm having a hard time understanding how would a lodded(is that even a word) mesh would help even it is not on the screen? I though lods help for longer viewing distances. So if there is an ai behind a wall, player doesn't see, the engine is rendering the lowest possible lod? In this particular example, the player is a few feet away from the ai, only a thin wall is blocking them?
An Alert structure depending on distance does really make sense. Or maybe a coming up an occluder solution that doesn't render the ai behind it. Which brings me the question which one is more expensive, clever ai or good looking ai?...(even with the lods)
Still though, I'm trying to understand how assassin creed's crowd structure is possible. It doesn't look like there is streaming....anyway...
#3
You'd be surprised at just how many polys you can lose in a LOD quite close up and not really notice.
As for how expensive a think() cycle is, that really depends on what you've got it doing. Lots of on the fly checks, radius area raycasts (they have to be fired, resolved, listed, processed) and steering behaviours is pricey.
The majority of game AI is carefully faked to look like it's doing something that it isn't. I remember how shocked I was when I first modded CoD, I couldn't believe that the AI were really that dumb, because they had appeared okay in the game. Careful scripting, if you tell an AI what to do, it limits it's capacity for doing something really stupid.
11/10/2009 (5:41 pm)
Without occluders they'll render regardless of whether they are behind a wall or not. The engine will draw the AI then draw the wall of them (that's not the greatest description but ...)You'd be surprised at just how many polys you can lose in a LOD quite close up and not really notice.
As for how expensive a think() cycle is, that really depends on what you've got it doing. Lots of on the fly checks, radius area raycasts (they have to be fired, resolved, listed, processed) and steering behaviours is pricey.
The majority of game AI is carefully faked to look like it's doing something that it isn't. I remember how shocked I was when I first modded CoD, I couldn't believe that the AI were really that dumb, because they had appeared okay in the game. Careful scripting, if you tell an AI what to do, it limits it's capacity for doing something really stupid.
#4
The problem is CoD ai even won't cut in my case, I'm prototyping for something stealth along the lines of Thief. Ai has to check for player visibility/how well lit he is, as if that's not enough it will also check how loud/quiet player is...hopefully...
Yep, I agree, careful scripting and writing even. If the ai walks up to a certain point, plays an animation at an acceptable standart and makes a funny joke, most players can be tricked how "clever" ai is.
11/10/2009 (6:02 pm)
Well there is one occluder resource, I'll look into that. The problem is CoD ai even won't cut in my case, I'm prototyping for something stealth along the lines of Thief. Ai has to check for player visibility/how well lit he is, as if that's not enough it will also check how loud/quiet player is...hopefully...
Yep, I agree, careful scripting and writing even. If the ai walks up to a certain point, plays an animation at an acceptable standart and makes a funny joke, most players can be tricked how "clever" ai is.
#5
As Steve mentions slowing down how often they think is a key one, it also helps make them more natural.
11/11/2009 (10:51 am)
The rendering performance will be the largest drain on your performance for getting many crowds like assassins creed or others, there are hundreds of tricks that can be done with A.I. to ease the burden of it on the system.As Steve mentions slowing down how often they think is a key one, it also helps make them more natural.
#6
[psuedocode]
if(player_in_trigger1 == 1)
{
%these_guys = getObjects_in_triggers(2, 3, 4)
{
%these_guys.setallmesheshidden(1);
}
}
[/psuedocode]
Tell it what to hide and what to show precisely.
11/11/2009 (11:58 am)
Also triggers. Cover the place in triggers, with something like -[psuedocode]
if(player_in_trigger1 == 1)
{
%these_guys = getObjects_in_triggers(2, 3, 4)
{
%these_guys.setallmesheshidden(1);
}
}
[/psuedocode]
Tell it what to hide and what to show precisely.
Associate Steve Acaster
[YorkshireRifles.com]
1. (obviously) Instances - the more stuff there is, the more stuff to render or process.
2. LOD everything - especially AI. Skinned, animated meshes are a big hit for Torque (apperently). "Aggressively" LODing helps here. You can leave your last LOD as fully empty, thus it won't render anything at all at distance.
3. Think() ticks take processing power, if you can string out those thinks(), then there is less to process. Also, getting things to spawn or think at the same time creates a bit of a bottleneck, try staggering them. Perhaps try creating an alert structure, were the think() time will change depending on how far away the player/threats are.
4. The way that the stock preferences are set up for sending/receiving information isn't exactly high-tech, and hasn't changed since TGE and dialup. I'd expect on single-player/one-box this should be changed. Try changing those, but beaware that they are connection dependant if online.
For single-player/same-box this can be a real boost.
So #2 really answers your question directly I think, it's certainly what I use. (though currently none of my skinned, animated meshes are LODed 'cos I'm in the middle of redoing them all)