by henriquecm8 · 2y ago · 0 comments
Ever since I first read about steam audio, I've wondered if it would be possible to use the sound propagation to determine if a npc has heard a sound. There are probably better ways to do this. And not always the most realistic approach is the best approach.
But I've always found that some games are very inconsistent about how npcs hear you. Sometimes you are in a closed room and make very little sound, and they hear you from outside, other times you are in an open place and they don't hear anything. It seems like some games only check the distance to sound origin, without taking occlusion/attenuation into consideration.
One total hack I would imagine would work alright is to render the scene twice, once displayed to the player and the other where the only light sources are the player's sound and walls/windows/etc just have some opacity changed. If the light around the enemy is above a threshold the player is detected. You wouldn't need to render the whole scene, just the area immediately around the player, and avoid doing it if there are no enemies.
Another hack that would be more involved would be to compute a kind of graph for the whole level and when a player makes noise, you propagate it through the graph using precomputed weights. You'd have to handcraft a graph for every level. But I could imagine this getting the best results in terms of performance and gameplay, since you could tune it per scene.
And stealth games especially will probably rely a lot on shadows and other visual things, which make rendering more expensive.
- Thief Gold, sound was important, each surface would make a certain amount of noise, and you could damp the noise by covering the ground in moss, or reduce it by walking slower.
- Splinter Cell Chaos Theory: which had a sound-meter with 2 indicators, one for the noise you are making and the background noise. I specially like this system because of how it allows you to make much more well-informed decisions.
- Sniper Elite: you can cover the sound of your rifle with loud background noise in some maps, they are regular, and they have cue moments before the loudest part.
You could also render the player sound separately from environmental sounds. So the NPC only hears the player if their sound exceeds the environmental noise.
You could get real fancy and do some directional processing on the NPC so they’ll go in the apparent direction.
It’s probably overkill though. You could probably do a much cheaper approximation and it would feel about the same to the player. It would be fun to test it out and see though!
Since they have a full sound engine built-in as well, I suspect they deal with attenuation, et al correctly.