This repository was archived by the owner on Feb 11, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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.