Spatial audio occlusion — how are you handling walls and geometry?

36 views 3 replies

Been banging my head against this one for a couple weeks now and figured I'd see what everyone else is doing. I'm working on a third-person exploration game and the spatial audio setup has been mostly fine, but occlusion is killing me. When the player is on the other side of a wall from a sound source, I want that muffled, slightly absorbed quality you'd expect in real life, not just a volume dropoff, but an actual tonal change.

Right now I'm raycasting from the listener to the source and if the ray hits geometry I'm applying a low-pass filter with the cutoff frequency scaled by the number of hits and the estimated material thickness. Works okay for simple cases but it completely falls apart in rooms with lots of small props and furniture. I end up with this stuttery filter wobble as the raycast flickers in and out of partial occlusion.

I've read a bit about using multiple rays (like a cone sample or hemisphere approach) and averaging the results to smooth things out, but I'm not sure if that's the right call performance-wise, especially on lower-end targets. I've also seen some people talk about precomputed acoustic data baked into the level geometry, which sounds amazing but feels like a lot of pipeline work to set up.

A few specific things I'm trying to figure out: is there a reasonable middle ground between full raycast occlusion and something precomputed? How are you handling dynamic objects like doors that open and close, do you just invalidate the bake or do you handle those separately at runtime? And does anyone have recommendations for audio middleware that makes this less painful? I've looked at Steam Audio and FMOD's built-in spatializer but haven't committed to either yet.

Would love to hear what's actually working in shipped or near-shipped projects, not just what sounds good in theory. sound waves passing through wall

Steam Audio is worth the integration cost for exactly this problem. The convolution reverb and occlusion together give you something that feels physically plausible without you having to hand-tune every room. The bake times can get long on dense scenes but it's been solid for us.

The flickering you're describing with single raycasts is super common. We switched to casting 5 rays in a small spread pattern around the direct path and averaging the occlusion factor, smoothed things out a lot. You can also add a small lerp on the filter cutoff so it doesn't snap frame to frame. Not physically accurate but sounds way better in practice and barely touches performance.

seconding the lerp approach, we do like a 0.15 second smoothing window on the cutoff and it completely eliminates the chatter. also worth making sure your raycast is running on a fixed interval rather than every frame, we do ours every 3 frames and honestly cannot tell the difference