Physics Related Sound Systems: implementation of procedural sounds for different materials in video games
Usually the realism of an interactive experience is based on these main components: graphics, physics & AI, and audio. After more than 30 years of computer graphics enhancements, modern 3D games such as Sony’s God of War, or Ninja Theory’s “Hellblade: Senua’s Sacrifice” can deliver a stunning and near-photorealistic image at interactive rates. This is not only related to graphics, for example games like Valve’s Half Life 2 or Rockstar’s Red Dead Redemption have developed a complex integrated physics system, including objects which interact one with another in a realistic way (N. Raghuvanshi, C. Lauterbach: ACM Press, 2007)
Propagation of Sound Waves on different materials
Sound is a sequence of pressure waves (called acoustic waves), which propagates through compressible medium (gaseous, liquid or solid). During the propagation the acoustic waves can be reflected, refracted or attenuated by the medium.
When particles in the medium vibrate parallel to the direction in which the sound wave is traveling, we have a longitudinal wave. On the contrary in some materials, it is possible to transmit transverse waves, characterised by having the vibrations moving perpendicular (transverse) to the direction of wave travel. Transverse waves travel horizontally (from left to right) — the vibration direction is perpendicular (at right angles) to the direction in which the wave travels or propagates. Waves in water and on strings are two good examples.
In air, sound is transmitted by pressure variations from its source to the surroundings. The sound level decreases, as it gets further and further away from its source. While absorption by air is one of the factors attributing to the weakening of a sound during transmission, distance plays a more important role in noise reduction during transmission.
The reduction of a sound is called Attenuation. The effect of distance attenuation depends on the type of sound sources. Most sounds or noises we encountered in our daily life are from sources, which can be characterised as point or line sources.
“For a point source, the noise level decreases by 6dB per doubling of distance from it.” If the sound source produces cylindrical spreading of sound such as stream of motor vehicles on a busy road at a distance, it may be considered as a line source. “For a line source, the noise level decreases by 3dB per doubling of distance from it”. (Wiener and Keast, 1959)
Properties affecting the behaviour of sound propagation
All media have three properties, which affect the behaviour of sound propagation:
- A relationship between density and pressure: this relationship, affected by temperature, determines the speed of sound within the medium
- The motion of the medium itself: example winds. Independent of the motion of sound through the medium, if the medium is moving, the sound is further transported
- The viscosity of the medium: this determines the rate at which sound is attenuated. For many media, such as air or water, attenuation due to viscosity is negligible.
— Practical Implementation of sound on different materials with Unreal —
Setting up Surface Types
Unreal Engine 4 allows to associate physical material types with shaders, so a snowy material can tell other systems which material it is made of. A wooden floor can be categorised as wood, and a grass material can behave as Grass when an object or a character is interacting with it.
In order to do this, it is needed to declare which material type are used inside the level. As shown in Figure 2, these settings are in project’s Edit > Project Settings Screen > Physics Section.
Next, it’s good to set up some “Physical Materials” that will refer to the surface types added in the project settings and then assign them to Floor materials. As shown in Figure 3 in the content browser, right-click and add Physics > Physical Material. Create and name physical material for each surface type it’s added in Project settings.
Applying Physical Materials to the Shaders
After creating physical material it is needed to open each flooring material and inside the details panel, select the right material from the drop-down menu. See Figure 4.
Setting Up Sound Cues
For the footsteps example I created different sound cues that will trigger procedural sounds for surface type. See Figure 5
What has the player stepped on?
After completed the sound cues, it’s time to modify the blueprint in the Player Character. First, it is essential to find a way of detecting the surface type the player is walking over. To do this it needs to run a line-trace from the player character to the surface below and querying the material it hits, as shown in figure 6.
It is clear that implementing physics based sound systems can definitely increase the realism of the game. With this technique is possible to create procedural systems which interact with different material types.
- References -
- N. Raghuvanshi, C. Lauterbach, A. Chandak, D. Manocha: Real-Time Sound Synthesis and Propagation for Games, (ACM Press, 2007)
- How Sound Propagates, Princeton University Press https://assets.press.princeton.edu/chapters/s9912.pdf
- Olu Ola Ogunsote: Propagation of sound, Its travel path, travel mediums and behaviour in the mediums, University of Technology Akura, Ondo State. https://pdfs.semanticscholar.org/6284/47715135215337497cbbba02e54a85b43fb6.pdf
- Marshall Long: Architectural Acoustics(Second Edition), Pag. 383–415, 2014 https://www.sciencedirect.com/book/9780123982582/architectural-acoustics
- Cyril Harris, “Absorption of Sound in Air versus Humidity and Temperature,” Journal of the Acoustical Society of America, 40, p. 148.
- Wiener and Keast, “Experimental Study of the Propagation of Sound Over Ground,” Journal of the Acoustical Society of America, 31, p.724