Skip to content
This repository was archived by the owner on Feb 11, 2024. It is now read-only.

Volumetric Audio for SabreCSG #240

Merged
merged 1 commit into from
Dec 10, 2019

Conversation

Henry00IS
Copy link
Collaborator

In light of RealtimeCSG dropping all financial interest (besides donations) I too decided to do the same and make Volumetric Audio for SabreCSG open source as part of the SabreCSG project. This also allows me to port it to Chisel in the near future. I do wish to thank the people that purchased it in the past.

The wiki page about volumes has been updated accordingly.

I hope this is useful to a lot of people, please think of me when you are rich! 😁

Please note that the minimum Unity version requirement to use this feature is 5.6.0.

Volumetric Audio Volume

Volumetric Audio Introduction

The problem with default Unity audio sources is that they are emitting sound from a fixed position. If you have a large sewer pipe with water streaming through it you should be able to hear it coming from the sewer pipe itself no matter where you stand. By default you’d have to place multiple sound sources and then it may appear to come from the side as illustrated in this image:

For our player the sound would appear to come from the right and at the center of each pipe segment. It’s unrealistic, doesn’t make much sense and it takes him out of the immersion of the game.

Volumetric Audio solves this problem by having a sound source that follows the player along the exterior of the pipe. By doing so it appears that the sound comes from the pipe no matter where he stands. It even blends the sound to 2D if he were to enter the pipe so that the sound surrounds him completely (similar to the music), allowing the player to truly immerse in the vast environment of sound with great realism.

The volumetric audio volume inspector

Property Description
Audio Clip The audio clip played by the volumetric audio source.
Output Mixer Group Set whether the sound should play through an Audio Mixer first or directly to the Audio Listener.
Bypass Effects Bypass/ignore any applied effects on the volumetric audio source.
Bypass Listener Effects Bypass/ignore any applied effects from the Audio Listener.
Bypass Reverb Zone Bypass/ignore any reverb zones.
Priority Sets the priority of the volumetric audio source. Note that a sound with a larger priority value will more likely be stolen by sounds with smaller priority values.
Volume Sets the overall volume of the sound.
Pitch Sets the frequency of the sound. Use this to slow down or speed up the sound.
Reverb Zone Mix Sets how much of the signal this volumetric audio source is mixing into the global reverb associated with the zones. [0, 1] is the linear range (like sound volume) while [1, 1.1] lets you boost the reverb mix by 10 dB.
Doppler Level Specifies how much the pitch is changed based on the relative velocity between the audio listener and the volumetric audio source.
Spread Sets the spread of a 3D sound in speaker space (prevents having sound all in one ear sometimes).
Volume Rolloff Which type of volume rolloff curve to use for the volumetric audio source.
Min Distance The minimum distance where the volumetric audio source volume stays the loudest possible. Outside of this minimum distance it begins to attenuate.
Max Distance The maximum distance the volumetric audio source stops attenuating at.
Spatial 2D Distance The spatial 2D distance affects the distance from the volume before the volumetric sound fully transitions to 2D (inner radius).
Spatial 3D Distance The spatial 3D distance affects the distance from the volume before the volumetric sound fully transitions to 3D (outer radius).

Playing Some Volumetric Sound

To immediately hear the amazing volumetric sound all you have to do is assign the “Audio Clip” in the inspector.

Live In-Editor Audio Preview

You do not have to enter play mode as this extension features live audio preview in the editor. It’s important that you disable/enable the scene view audio icon often as it tends to be a little buggy, this is not our fault.

If you wish to mute the audio you must use the “Mute Audio” button in the Game tab.

Hot Reloading Support

C# recompilations during play are fully supported.

Visualize Volumetric Audio Source

When you have the Volumetric Audio Volume brush selected you can see several spheres, blue, red and possibly even green. In the center of them is the audio source (it doesn’t have the usual speaker horn icon). When you fly around in the scene you can see that it tries to follow you and when you enter the volume you will be inside of the spheres. The next chapter will go into more details on what these spheres mean.

Spatial 2D and 3D Distance

The spatial 3D distance is indicated by the red sphere around the volumetric audio source. When the audio listener is outside of this sphere the sound will be completely 3D (usually changed using the “Spatial Blend” property in the inspector) and will appear to come from a point in space.

The spatial 2D distance is indicated by the green sphere around the volumetric audio source. When the audio listener is inside of this sphere the sound will be completely 2D (usually changed using the “Spatial Blend” property in the inspector) and will appear to surround you, similar to the music, just a stereo sound played equally in both speakers.

The blue spheres are the default Unity spheres. They display attenuation. When the audio listener is inside of the small sphere the sound will play at full volume and anything outside of the large sphere will no longer be heard.

Similar to how the audio fades away when you get further away from it as indicated by the blue spheres, the 2D sound fades into 3D sound when you get further away from it as indicated by the green and red spheres.

Combining Volumes

You can combine multiple volumetric audio volumes together so that they will share the same audio source. This is useful for complex shapes like pipelines that shouldn't play the same sound multiple times at every twist and turn (SabreCSG only supports convex shapes so a pipeline would have to exist out of multiple brushes). To begin, simply parent volumetric audio volumes that you wish to combine under this one in the hierarchy.

The inspector will change to indicate that the child volumetric audio volume brush no longer has its own audio source, as this is now simply additional geometry used by the parent volume.

Select one of the brushes and have a look at the volumetric audio source while you fly around the scene, it will jump between them or smoothly follow along the geometry that you have created. This allows for realistic long curvy hallways or large ocean bodies without any intersections where you’d suddenly hear the same sound twice. Please note that you cannot parent a child volume to a child volume.

@Henry00IS Henry00IS merged commit 7a932f1 into sabresaurus:master Dec 10, 2019
@Henry00IS Henry00IS deleted the VolumetricAudio branch December 10, 2019 20:06
@Dadaskis
Copy link

Oh. Thanks :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants