
WiresAcoustics
Ray traced sound for Valheim.Wire's Acoustics
Sound physics.
Inspired by the video Physically-based audio: why most games sound fake [Voxel Devlog #31], on ray traced audio.
Showcase video
Coming later, sorry lol. If you want, you can record your own, I guess.
How it works
The mod traces rays through the world, the way light is traced in a renderer, but for sound. A few times a second, rays go out from the camera in every direction and find out what's around you: how closed in you are, how big the space is, what it's made of, and where the openings are. Every sound you hear is then shaped by that space and by everything between it and you.
You hear from the camera. Where the camera is, that's where you are.
Wherever I could, the numbers come from real measurements and standards instead of being made up. The sources are at the bottom.
Features
Reverb from the real space
The reverb is worked out from what the rays hit: how big the space is, how closed in, and what it's made of. A stone hall rings, a log cabin sounds warmer, a cave sounds like a cave, and a furnished room is drier than an empty one. Windows, doors and gaps let sound out instead of counting the sky behind them as part of the room. Open ground is dry.
Walls block sound like real walls
Walls, floors, roofs and doors block sound as much as real ones measure, by material and thickness. A wood wall is like a solid timber wall, a door leaks more, stone is like a brick wall. Through a wall you hear a muffled but still recognisable sound, not just a rumble.
Sound goes round things
A sound behind a wall also reaches you through the openings: a window, a door, a hole in the roof, round a corner, or bouncing off a surface. You hear it from where it comes through, so a deer outside is heard at the window much more clearly than through the wall. Going round a corner costs what it really costs, more of the highs the longer the detour. Hills, rocks, trees and furniture in the way muffle by their size: a trunk barely matters, a boulder takes the highs off, a hill cuts a sound depending on how high it rises.
Bounces
Sound reaching you off a wall is as loud as the reflection would really be: what the surface doesn't absorb, mirrored where the angle is right and scattered elsewhere, depending on how rough the material is.
Material matters
Every surface absorbs the lows and highs by published data for what it is. Snow swallows sound, moss and forest floors soften it, grass a bit less, paving and stone reflect it, water reflects almost everything. Just like IRL. Cool, right?
Distance and air
Sounds fade with distance the way real sound does, instead of cutting out after a few metres. The air takes the highs off far sounds as the international standard says it does, with the weather: warm, cold and freezing are matched to the real Norwegian weather Valheim is modelled on.
Wind
Downwind a sound carries a few dB further; upwind it can drop a lot from about 100 m away, as measured outdoors. You also hear the wind in your ears from the way it's blowing.
Sound takes time
Sound travels at the speed of sound. A tree falling far away is heard after you see it.
Doppler
Moving sounds rise in pitch as they come toward you and drop as they go away. Ships' wakes too.
HRTF (headphones)
HRTF stands for head-related transfer function: how your head and ears change a sound depending on where it comes from. A sound on your left reaches your right ear a tiny bit later and duller, sounds behind you lose some brightness, and your outer ear colours sounds from above and below. The mod models this itself, for every sound, so you can tell front from back and up from down, not just left from right. Best with headphones. I'd recommend turning HRTF off on speakers, as your real head already produces ACTUAL HRTF. For the mod's own HRTF to sound its best, turn off Windows Sonic or Dolby Atmos spatial processing on your output device while playing Valheim; running both spatializers together can reduce directional clarity.
Sounds come from where they're made
The game plays a lot of sounds at a character's feet or at the base of a piece. Here, weapon swings come from the weapon and follow the swing, a bow's draw from the bow, holstering from your back, eating from your head. Creatures roar from their head, claw with their arm and stomp with their feet. Chests sound from the lid, fires from the flame, crafting from the station. Anything that moves takes its sounds with it, and big sources (a hearth, a cart, a troll) sound as wide as they look.
Weather and the sea
Indoors, rain, wind and birds come in through the windows and doors from their direction; through closed walls only a faint rumble gets in. The sea is heard from the actual shore and fades like a long shoreline does. Under water, the world above is about 30 dB quieter, as the physics of the water surface says.
Portals
Going through a portal, its hum doesn't stop and restart: it carries through with you and keeps playing from the exit portal. More of an extra than sound physics, but it's audio-related so it's here.
Also
- No pitch drop in the Mistlands mist (fog doesn't do that to sound, and I don't like it).
- The main menu's sounds get the HRTF too. Barely noticeable there, tbh, but it's there.
Works with
- Proximity Voice Chat (Azumatt): voices get the walls, openings and HRTF like any sound.
- Wire's Stackify: its chest sounds come from each chest.
- (kinda) Immersive Weather & Acoustics: set its
EnableAudioOcclusion = falseso only one audio system runs; its visual weather can stay on.
Performance
The ray tracing runs on Unity's worker threads, and the per-sound processing runs on the audio thread. The game's audio update does a small amount of bookkeeping on the main thread. Paths round walls and second bounces are only traced for sounds that are blocked, and rooms that don't change are scanned less often, with a refresh when something is built, removed or a door opens.
Settings
- General: Enabled, Room reverb, Muffling, HRTF (headphones), Realistic distance.
- Tuning: Reverb strength, Muffling strength, HRTF strength.
- Debug: Debug log: the measured space, muffled sounds and the mod's costs, every few seconds.
- Turning the mod off restores the game's own reverb zones, listener position and sound placement without a reload (for whatever is still loaded).
Sources
- Air absorption: ISO 9613-1, Attenuation of sound during propagation outdoors, part 1. Weather: Bergen (Florida) July and Finsevatn January climate normals, 1991-2020.
- Barriers, corners, hills, obstacles: Maekawa's barrier chart in Kurze and Anderson's formula; capped at 20 dB as in ISO 9613-2.
- Walls and doors: WoodWorks, Mass Timber Acoustics (cross-laminated timber, STC 33 to 38); Commercial Acoustics (solid-core wood door, STC 30 to 35); Engineering ToolBox (brick wall STC 55, and the average shape of a wall's loss over frequency). Iron and ice: the mass law.
- Surface absorption: Sengpiel's table of absorption coefficients; the pyroomacoustics materials database; heyizhou.net's absorption coefficient tables (steel decking).
- Ground: the Nord2000 ground classes (flow resistivity), as listed in d&b NoizCalc technical white paper and in Bies, Hansen and Howard, Engineering Noise Control; turned into absorption with Delany and Bazley's model (1970).
- Trees: Li, Van Renterghem, Kang, Verheyen and Botteldooren, Sound absorption by tree bark, Applied Acoustics 165 (2020).
- Bounces and scattering: Vorländer and Embrechts (2004) on scattered reflections; ODEON's scattering coefficients (Zeng, Lynge and Rindel, 2006); Lambert's cosine law.
- Room size and reverb: Sabine's reverberation formula; the critical distance (Hopkins and Stryker, as given by Arup).
- Wind: Waddington and Lam's outdoor measurements of wind and sound; the US National Weather Service's blizzard definition to match the game's wind to real wind speeds.
- HRTF: Woodworth's formula for the delay between the ears.
- Under water: DOSITS (Discovery of Sound in the Sea), the air and water impedances.
- The sea as a line source: Hong Kong Environmental Protection Department, noise basics.
Disclaimer: development is AI assisted. Not fully human or AI. Donations: ko-fi.com/krosshair