Search Unity

Volumetric Audio

Discussion in 'Assets and Asset Store' started by Darkcoder, May 3, 2014.

  1. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412



    Take your game audio to the next level with Volumetric Audio. With just a few clicks you can turn your point audio sources into fully volumetric ones that emit from any kind of shape!

    >> Get Volumetric Audio <<


    Thank you for reading.
     
    Last edited: Apr 3, 2022
    Ony likes this.
  2. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412

    Version 1.0.1 changes:
    • Added the ‘Is Hollow’ setting to all volumetric shapes, allowing them to be treated as hollow.
    • Added Mesh Filter field to VA_Mesh.
    • Added more warnings to components when you use possibly incorrect settings.
    • Added the ‘Dynamic Mesh’ scene.
    • Improved the demo scenes.
     
    Last edited: Apr 3, 2022
  3. Danirey

    Danirey

    Joined:
    Apr 3, 2013
    Posts:
    548
    Hi darkcoder,

    Another great package! Good work!

    I'll try this for sure. I work with audio every day, and this is a huge feature to add in any game!

    Cheers!
     
  4. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Thanks!

    I just finished implementing mesh baking, which allows you to convert a volumetric mesh into a Bounding Volume Hierarchy for very fast calculation speeds (just click Bake Mesh in the VA_Mesh inspector). This feature will come with Version 1.0.2 whenever that gets accepted onto the store.
     
  5. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    This plugin is very interesting. We are using Master Audio for all the sounds and an integration between the two systems would be great.
    For example all the sounds are loaded by Master Audio with Dynamic Groups, and each group has it's own volume level settings. This allows to have environment sounds tuned all at the same time, independently from, for example, player interaction sounds, or weapons, etc.
    Master Audio has some option to specify the source of the audio. Probably could be enough to extend this.
    Do you think that could be possible?
     
  6. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Depending on how Master Audio works this may already be possible. To get Volumetric Audio working at the most basic level you just need to add the VA_AudioSource component to some GameObject that represents your audio source and it will position the sound at the right place (though the Pan Level adjusting feature would require an AudioSource attached).
     
  7. synapse21

    synapse21

    Joined:
    Sep 16, 2014
    Posts:
    2
    Hello Carlos! thank you for Volumetric Audio. One thing I cannot get to work: I created a VA Box shape to use on a building with the intention of using a 2D quad ambience sound file within the box.

    The 2D sound file actually had to be checkboxed to 3D since it never stopped playing throughout the entire space, so I did that with the hopes that the Pan and / or Spread will widen it back up when inside the building.

    I added the sound file to the Hierarchy and added the VA Audio Source component to it, using the VA Box as the Shape. The sound's icon appeared offset from the center of the VA Box, but after checking the Pan settings (default sound's Pan set to 1 and the Min Max Pan of the VA Audio Source component left at 0/5), I entered the building in Game mode but the sound only plays at the spot where the offset sound is positioned.

    Do I need to set the sound's radius properties separately from the VA Box? Does that not defeat the purpose of using the VA Box shape (with the sound itself only being spherical like default Unity game objects)?

    Your example showed two capsules set as a Compound shape and my guess was you were using a mono sound loop. Mine is quad and set to 3D.

    Can you help?

    - Rodney
     
  8. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    The way Volumetric Audio is designed is that you set up volumes (shapes) that you want sounds to emit from, you then assign a standard Audio Source to it. The standard sound Max Distance & Rolloff settings allow you to change how far away from the volume the sound can be heard from. Another way to think about it is that these standard distance settings blur the edges of the sound volume, for example:



    On the left: if the sound distance settings were ignored, then sound would only be heard from inside the volume.

    On the right: the green area shows you where the sound falls off as you move away from the volume.

    In addition to this, using 3D sounds also gives you Doppler shift as the sound or the listener move around, as well as directionality (e.g. if the sound volume is to your right then you'll hear it in your right speaker).

    If I understand you correctly, you have a specially designed 2D ambient loop that you want to hear when the camera enters inside a volume? If so, this isn't supported yet (because VA doesn't touch the sound volume setting). However, I'll work on adding this right now and I'll send you a build soon.
     
  9. synapse21

    synapse21

    Joined:
    Sep 16, 2014
    Posts:
    2
    Thank you, Carlos! Yes, that is essentially what I am looking for. I'd love to create a VA Box, for examples, and attach that to the Shape parameter of a VA Audio Source emitter, using a 2D sound (stereo or quad) to create a basic ambient bed sound when you're within a warehouse. I just want the sound to play when inside the warehouse (VA Box) and NOT play when I'm outside of it (with a little custom roll-off for the transition).
     
  10. maximo-olmos

    maximo-olmos

    Joined:
    Apr 9, 2015
    Posts:
    2
    Hi Carlos,
    I discovered your Volumetric Audio for Unity and wanted to know if it supports Unity vers 5.0.1f1 and if not when do you think you will have an ETA on a compatibility update?

    Thank you
    Maximo
     
  11. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Hey,

    The current version of Volumetric Audio supports Unity 5.x fine, but due to API changes there are a few warnings in the editor. I plan to release an update to remove all these warnings in the next few days once I test it more thoroughly.
     
  12. maximo-olmos

    maximo-olmos

    Joined:
    Apr 9, 2015
    Posts:
    2
    Thanks Carlos! for the quick response. I'm interested in using this tool. If you could please let me know when you have a version update that would be great! I can be reached at email maximo.olmos@gmail.com.

    Thank you
    Maximo
     
    Darkcoder likes this.
  13. buffalovision

    buffalovision

    Joined:
    May 31, 2013
    Posts:
    3
    Really interesting plugin. Is it compatible with any binaural plugins like 3dception, AstoundSound, or Oculus Audio SDK?
     
  14. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    If these plugins provide a component similar to Unity's AudioSource then it should be at least partially compatible. To make it fully compatible you would have to modify the VA_AudioSource component, particularly the parts that deal with the AudioSource's 2D/3D sound slider to do the equivalent.
     
  15. buffalovision

    buffalovision

    Joined:
    May 31, 2013
    Posts:
    3
    3dception can be used with it's own AudioSource type, or alternatively a filter component can be applied to a Unity AudioSource. (which is my current preferred workflow). Oculus also uses its own AudioSource type. It appears that both custom source types are derived from Unity's AudioSource but I'm not certain.

    Would be great if anyone out there knows if these plugins are compatible with certainty! Thanks!
     
    sneakSounds likes this.
  16. AlphaRalpha

    AlphaRalpha

    Joined:
    Dec 8, 2014
    Posts:
    1
    Hello,

    I'm very interested in your Volumetric Audio product but would like to know if it's supporting Wwise Audio Engine? Just want to be sure before buying it. Thanks !
     
  17. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    As I said earlier, as long as these other audio engines come with an equivalent to the Audio Source component it will mostly work. To get it to fully work you have to do some minor tweaks to the 2D/3D sound slider and volume settings if available.
     
  18. fanobi

    fanobi

    Joined:
    Oct 8, 2014
    Posts:
    1
    Can this be used in conjunction with FMOD? If so, I am a very happy man (and customer, as it is).
     
  19. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    By default it only fully supports Unity's built-in Audio Source. But it's very easy to extend to support more systems. All you need to do is modify VA_AudioSource.cs lines 125-143 to grab the AudioSource component from your alternative sound lib and modify the spatial blend/pan level, and volume.
     
  20. buronix

    buronix

    Joined:
    Dec 11, 2013
    Posts:
    111
    Hey Im thinking of use your volumetric sound asset on my project but Im not sure if it fits with my performance needs.

    Im thinking of use it in a Big world Sceneario, (objets rivers, ocean, sound Ambient zones, etc), so my main question is about how the detection system works, I have 2 main examples/questions:

    -I have a tiled-Island-Continent surrounded by an Ocean, I want to play a sound of waves for the ocean, So can I have a va shape for each tile ocean, and add/remove them in runtime to the ocean va compound audio source and it will work? Can I enable/disable in runtime a Va audio source and keep things working?.

    - Imagine I want to display bird sounds when the player aproachs to a tree, Can I have X number of VA Audio Sources (x for X random bird sounds) and add the va shapes to the va compound audio source in runtime?

    And over All which will be the performance/calculations made (Imagine an va Audio compund source with 150 shapes).

    Thanks in Advance.
     
  21. buronix

    buronix

    Joined:
    Dec 11, 2013
    Posts:
    111
    At the End I bought your asset, cause I can use it at least in two useful scenarios, I almost get mad until I found that my problem was the VA_Helper was caching the first AudioListener at the start of the scene (I switch between cameras), it will be appreciated to allow this on code with a function or something (I have no problem to modify myself).

    Also I understand better how this Asset works, I dont think I can use it for all my needs but its very useful.
     
  22. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Switching AudioListeners wasn't a scenario I considered, so I'll fix that in the next build.

    You probably already know, but for others reading: the size of the volumetric audio shapes or compound shapes doesn't matter, simply the amount and complexity of them. Mesh sound shapes are the slowest, but there is an optimization to compile them into a tree structure for faster calculations, but this would be unsuitable for objects that have animated vertices (e.g waves), so it should be used sparingly on such objects.

    VA wasn't really designed for the scenario where you have many separated objects (e.g trees of an island), so there is no spatial partitioning implemented. In this scenario it's probably best to just keep all the trees separate and temporarily enable the sound and shape on trigger enter, and rely on the pan level feature to make it sound more immersive.
     
  23. zORg_alex

    zORg_alex

    Joined:
    Mar 12, 2014
    Posts:
    20
    Hello. This is the thing I was listening in your tutorial intentionally. When the listener was inside the river bend the sound jumped from one side to another, when the listener crossed the middle. Your system lacks one thing: sampling closest points from all directions (more than 4 horizontal directions) and analysis of them to decide the pan. If samples are scattered on different sides then pan should be closer to 0. I hope it's not that complex. And may be you will think of that. It will drastically improve your system.

    But I personally seek for a realistic scattering of a sound. So this is quite nifty, but not enough for me. :(
     
  24. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    I would like to implement this too, but I can't think of an efficient way of doing it. Plus, Unity's sound API only gives access to left/right pan, so such a system would make it incompatible with surround sound (not such an issue maybe).

    The best solution I can think of is to render all the sound emitter shapes to a left/right render texture, and scan through them to find which sounds are 'visible' and adjust the pan & volume based on this. However, such a system would require me to rewrite everything, would be much more complex for users to set up, probably may introduce quirks where you can't hear sounds when you're in front of something, and may be too GPU expensive for many games. Plus, I don't think so many users are interested in this kind of audio asset, so the development time may not be worth it.
     
  25. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    366
    I just bought Volumetric Audio – very promising, powerful and easy to use – and I have a few questions regarding best practices regarding islands and ocean sounds.

    The idea is to simulate how ocean sounds are muted by distance from non-occluded water, with the terrain (multi-part) acting as the occluder.

    I've imported and assigned a 3D ocean sound to a special water plane GameObject (with rendering and collision turned off), assigned VA_Material components to the terrains, put the terrains in a Terrains layer, selected Raycast All and occlusion from the Terrains layer. I still can't get a directional result, and the volume is very low until the character controller actually touches the water sound plane.

    I'm guessing the terrain colliders aren't being picked up by the raycaster.

    I'd be grateful for any pointers or ideas. Thanks!
     
  26. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Sorry for the late reply.

    When you say water plane, is this shaped to exclude the land, or is it just a flat sheet of water? If it's the latter, then it won't work correctly, even with the Excluded Shapes feature, because it wasn't designed to handle intersections.

    I did some testing with this and the only scenario where I encounter issues is when the GameObject scale is non-uniform, e.g. 100,1,1. If it's like 5,5,5 or some other uniform number then it should work as expected though, just make sure the Spatial Blend setting is 1 (aka 3D) for it to work correctly. You should also check in the scene view (or enable Gizmos in the game view) to make sure the sound 3D/Max Distance setting appears to be correct.

    I'll submit a new version with a few fixes that should be unrelated to your issues, and try to make a demo scene that implements something like you describe.
     
  27. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    366
    It's a flat sheet. I don't know of any water asset which implements water surfaces differently, so my use case should be common. One way of handling this would be through raycasting. The terrains are procedurally generated, which means manual operations to produce masks aren't possible.

    Thanks for the information. I guess I'll have to use some other volumetric sound package for this.
     
  28. KillerNads

    KillerNads

    Joined:
    Jan 22, 2017
    Posts:
    70
    Hey,

    This looks like a great asset and very useful. Im developing my first game for VR platforms. I just wanted to know how this differs or would be more useful then something that Valve released for 3D Sound with VR Headsets:
    https://valvesoftware.github.io/steam-audio/

    Are they pretty much the same thing, or do they differ quite a bit in functionality and could be used to work in tandem with each other?

    thanks
     
  29. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    If you look at the features list on that page you can see Steam Audio deals with how sound gets modified as it passes through objects, reflects off objects, or based on the listener angle. While Volumetric Audio does have some basic features that do some of these things, the main focus is allowing your sounds to emit from different shapes or meshes, and not just the default sound spheres, which I don't think that system does. I imagine the two systems are compatible though.
     
    KillerNads likes this.
  30. KillerNads

    KillerNads

    Joined:
    Jan 22, 2017
    Posts:
    70
    Cool thank you, i had thought that too, but just wanted to make sure :D
     
  31. NotQuiteSmith

    NotQuiteSmith

    Joined:
    Oct 27, 2013
    Posts:
    92
    Hi,
    I thought I'd found the perfect asset! Worked great but then I noticed I was getting crazy spikes in the profiler that seem to be caused by VA. If I turn the VA objects on/off I see at least a 20fps difference very clearly between the two states (which is a problem in VR when I'm already pushing the scene).

    VA_mesh.LateUpdate" seems to cause a lot of garbage collection - maybe it's that?

    Are you still working on this asset - would be great to have your input on this!

    Thanks.
     
    Last edited: Feb 17, 2018
  32. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    If you want VA_Mesh to run fast then you must bake it by clicking 'Bake Mesh', or by calling the Bake() method. If you don't do this then it will read the mesh data every frame, which is very slow, but allows you to use it with procedurally animated meshes like in the 'Dynamic Mesh' demo scene. I could optimize non-baked meshes a bit by allowing a delay between each update, but if your mesh doesn't update then you should always bake it, and if it's dynamic you should always use a highly optimized low poly mesh.
     
  33. Keaneo

    Keaneo

    Joined:
    Mar 7, 2015
    Posts:
    99
    Hi,
    Finally got back to this. Baking the mesh improved its performance, but even the va_sphere and va_box scripts are just taking up too much CPU time - is there any way these can be further optimised - or is there anything I'm doing wrong?

    My game is VR and having to hit 11ms per frame is impossible currently when the profiler indicates that VA scripts are taking 10ms by themselves to run the LateUpdate method. Any chance you could take a look? I've had to disable them all - a real shame because this asset would have been great.

    FYI I had 2 mesh, 4 sphere and 4 box scripts in the scene.

    Thanks.
     
    Last edited: Mar 1, 2018
  34. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    I sent you a private message with an updated build which should improve performance about 60~% for VA_Mesh, and a bit less for the others.

    Let me know if things are better.
     
  35. Henry00IS

    Henry00IS

    Joined:
    May 20, 2015
    Posts:
    13
    This is awesome. Could you make it possible to hear an audio preview in the editor?
     
  36. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Thanks. Volumetric Audio itself works in the editor, that is, the sound values will update correctly. However, Unity doesn't allow playing of sounds outside of play mode, so there's not much I can do. Unity has the ability to preview a sound clip, but this is the raw clip and will ignore all sound settings like pan, volume, etc, so it's of no use.
     
  37. Henry00IS

    Henry00IS

    Joined:
    May 20, 2015
    Posts:
    13
    I would like to propose the following change (or a non-linq one if you prefer). I have an AudioListener that is disabled in my level and it would find that one every time instead of the active one. I changed VA_Helper.cs to:

    Code (CSharp):
    1.     public static bool GetListenerPosition(ref Vector3 position)
    2.     {
    3.         if (Enabled(cachedAudioListener) == false)
    4.         {
    5.             cachedAudioListener = Object.FindObjectsOfType<AudioListener>().Where(e => e.enabled).FirstOrDefault();
    6.         }
    7. ...
     
  38. Henry00IS

    Henry00IS

    Joined:
    May 20, 2015
    Posts:
    13
    Yeah I noticed it's querying the AudioListener position sometimes during edit mode. You can just enable audio here:

    upload_2018-5-2_19-30-43.png
     
  39. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    This is a good idea. In another asset I've recently added something similar, except it uses an additional component. In VA this would allow compatibility with non-native audio systems, and it also avoids the gc and overhead of using FindObjectsOfType. I'll add it to the next version.


    Wow, you learn something new every day! I'm not sure if VA updates enough for this to work for everything, and it doesn't allow for sound isolation, but it should work well for what you described earlier.
     
  40. Henry00IS

    Henry00IS

    Joined:
    May 20, 2015
    Posts:
    13
    I knew it! Haha, well it's all good. I come from the SabreCSG community so I know a couple tricks these days. You can subscribe to the "SceneView.onSceneGUIDelegate" to receive instant updates in the editor, it's called hundreds to thousands of times during every tiny update and frame, enough for you to make the sound behave the same as in-game.

    You can use "SceneView.onSceneGUIDelegate.GetInvocationList().Contains(myMethod)" to determine whether you are still subscribed to the delegate. Script reloads and coming out of play mode tends to unsubscribe you.

    And to make sure you are always subscribed you can add a special static constructor that's always called by the editor to initialize your scripts like this:

    Code (CSharp):
    1. [InitializeOnLoad]
    2. public class Startup {
    3.     static Startup()
    4.     {
    5.         Debug.Log("Up and running");
    6.     }
    7. }
    If the sound sticks to the player camera after play mode, add this script to your project:

    Code (CSharp):
    1.         /// <summary>
    2.         /// Toggles an audio listener off/on whenever the editor comes back from play mode.
    3.         /// This makes it the active audio listener that makes the audio preview work correctly in the editor.
    4.         /// </summary>
    5.         [ExecuteInEditMode]
    6.         [RequireComponent(typeof(AudioListener))]
    7.         public class AudioPreviewEditorFix : MonoBehaviour
    8.         {
    9.             public void Start()
    10.             {
    11.                 // always disable during play.
    12.                 GetComponent<AudioListener>().enabled = false;
    13. #if UNITY_EDITOR
    14.                 // enable when in editor mode to make this the active audio listener.
    15.                 if (Application.isEditor && (!Application.isPlaying || UnityEditor.EditorApplication.isPaused))
    16.                     GetComponent<AudioListener>().enabled = true;
    17. #endif
    18.             }
    19.         }
    By simply toggling some arbitrary AudioListener not connected to a camera, the editor camera will get the focus instead. It's a Unity bug.

    If you need any help making this work then please do get in touch.
     
  41. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    @Darkcoder
    Hi! I'm integrating Google's Resonance Audio in my project and so far it works very well with Volumetric Audio except for the solid (non hollow) audio volumes: The issue is the sounds rotate randomly around the listener until it completely stops. It only happens with non hollow audio volumes. I have noticed the audio source is set to 2D when into the volume but I think this is ignored once you have a spatializer assigned to the audio source.
    Any idea on how I could fix that?

    If you haven't already, you REALLY should check Resonance Audio: it's the only Unity audio spatializer completely free and open-source compatible with all Unity build targets. Also, it's very cheap on ressources since it internally renders every audio source to a single ambisonic field and computes the spatialization a single time instead of every time for every audio source, making it ideal for desktop, VR and mobile alike.
    It's free and it's fantastic. No reason to not integrate it with your Volumetric Audio, don;t you think? ;)
     
    Last edited: May 24, 2018
  42. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    I found the issue: Resonance Audio doesn't like the audio source and the listener to be in the same spot, and that's what the Spatial Blend 2D-3D makes in the audio source to make it "2D"
    The solution is to place the sound IN FRONT of the listener instead of the same spot.
    Placing the audio source 1cm in front of the listener fixes it.
    I have made a component for this.
    Once you put the component in an object with an Audio Source, it will make a parent object and manage the 3D position to mimic the Spatial Blend parameter in the audio source.
    It has a specific option to make it compatible with Volumetric Audio's "follow sound"

    Just copy the code and save it as "ResonanceAudioSpatialBlend.cs" somewhere in your assets folder and set the script order execution fo this script to be the last one in the list:
    Edit -> Project Settings -> Script Order Execution

    I hope it will be useful to others :)

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class ResonanceAudioSpatialBlend : MonoBehaviour {
    6.     [TextArea]
    7.     public string Note = "This script enables 2D-3D Spatial Blend with ResonanceAudio. It will automatically create a parent GameObject for a single AudioSource. Use ONLY this parent GameObject to move the audio source around.";
    8.     [TextArea]
    9.     public string IMPORTANT = "Change this script execution order to the last one in the list: Edit -> Project Settings -> Script Execution Order";
    10.  
    11.  
    12.     [Tooltip("Click this to remove the created parent object and remove this script.")]
    13.     public bool revertSetup = false;
    14.  
    15.     [Tooltip("Enables the use of Volumetric Audio from the assetstore.")]
    16.     public bool VolumetricAudioCompatibility = true;
    17.  
    18.     [HideInInspector]
    19.     public AudioSource audioSource;
    20.     [HideInInspector]
    21.     public GameObject parentObject;
    22.     [HideInInspector]
    23.     public GameObject childObject;
    24.     [HideInInspector]
    25.     public ResonanceAudioSpatialBlend script;
    26.     [HideInInspector]
    27.     public bool autoSetupDone;
    28.  
    29.     private bool autoSetup = true;
    30.  
    31.     void Start () {
    32.         audioSource = GetComponentInChildren<AudioSource>();
    33.         if (audioSource == null) {
    34.             Debug.LogError("Object " + gameObject.name + " has no child with an AudioSource! Make sure you have put the AudioSource in a child GameObject or use the AutoSetup button. \n SCRIPT DISABLED");
    35.             this.enabled = false;
    36.         }
    37.     }
    38.  
    39. #if UNITY_EDITOR
    40.     void OnValidate() {
    41.         if (autoSetup) {
    42.             if (!autoSetupDone) {
    43.                 autoSetup = false;
    44.                 audioSource = GetComponent<AudioSource>();
    45.                 if (audioSource!=null) {
    46.                     autoSetupDone = true;
    47.                     parentObject = new GameObject(gameObject.name + " Parent");
    48.                     parentObject.transform.SetParent(gameObject.transform.parent);
    49.                     gameObject.transform.SetParent(parentObject.transform);
    50.                     script = parentObject.AddComponent<ResonanceAudioSpatialBlend>();
    51.                     script.autoSetupDone = true;
    52.                     script.audioSource = audioSource;
    53.                     script.parentObject = script.gameObject;
    54.                     script.childObject = gameObject;
    55.                     parentObject.transform.position = transform.position;
    56.                     transform.localPosition = Vector3.zero;
    57.                     UnityEditor.EditorApplication.delayCall += () => {
    58.                         DestroyImmediate(this);
    59.                         UnityEditor.Selection.activeGameObject = parentObject;
    60.                     };
    61.                     Debug.Log(gameObject.name + " Resonance Audio Spatial Blend auto setup done.");
    62.                 }
    63.             }
    64.         }
    65.         if (revertSetup) {
    66.             revertSetup = false;
    67.             if (!autoSetupDone) {
    68.                 Debug.Log("Please use Auto Setup first.");
    69.             } else {
    70.                 childObject.transform.SetParent(transform.parent);
    71.                 childObject.transform.position = gameObject.transform.position;
    72.                 UnityEditor.EditorApplication.delayCall +=()=> {
    73.                     DestroyImmediate(gameObject);
    74.                     UnityEditor.Selection.activeGameObject = childObject;
    75.                 };
    76.                 Debug.Log(gameObject.name + " Resonance Audio Spatial Blend REMOVED.");
    77.             }
    78.         }
    79.     }
    80. #endif
    81.  
    82.     void LateUpdate () {
    83.         if (!VolumetricAudioCompatibility) {
    84.             if (audioSource.spatialBlend > 0.999f) {
    85.                 audioSource.transform.position = transform.position;
    86.             } else if (audioSource.spatialBlend < 0.001f) {
    87.                 audioSource.transform.position = ResonanceAudio.ListenerTransform.position + (ResonanceAudio.ListenerTransform.forward * 0.01f);
    88.             } else {
    89.                 audioSource.transform.position = Vector3.Lerp(ResonanceAudio.ListenerTransform.position + (ResonanceAudio.ListenerTransform.forward * 0.1f), transform.position, audioSource.spatialBlend);
    90.             }
    91.         } else {
    92.             if (audioSource.spatialBlend < 0.001f) {
    93.                 audioSource.transform.position = ResonanceAudio.ListenerTransform.position + (ResonanceAudio.ListenerTransform.forward * 0.01f);
    94.             } else if (audioSource.spatialBlend < 0.999f) {
    95.                 audioSource.transform.position = Vector3.Lerp(ResonanceAudio.ListenerTransform.position + (ResonanceAudio.ListenerTransform.forward * 0.1f), audioSource.transform.position, audioSource.spatialBlend);
    96.             }
    97.         }
    98.     }
    99. }
    100.  
     
    Last edited: May 25, 2018
  43. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    This is a terrific tool, but I just want to check on performance. I have an extreme case: five long (3000-5000m) rivers in my game scene, and I set this up on each one and baked them. At runtime, two rivers use only 0.05ms, but the other three use 0.3m, so it adds up to a full ms. I can't figure out why the two are so low and the others are somewhat higher. The low ones do have fewer polygons in the mesh, so that's probably it, right? Is there a way to optimize it so the baked thing has fewer polys? Any other suggestions?

    (But I'll definitely use this for other games, it's really nice!)
     
  44. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Yes, the performance of the baked mesh is related to the amount of polygons it contains. If your mesh contains a lot then I recommend you make an optimized version of it just for the audio mesh.

    There may be some things I can do to speed things up though, maybe you could send me the mesh so I can test it myself?
     
  45. therewillbebrad

    therewillbebrad

    Joined:
    Mar 2, 2018
    Posts:
    151
  46. therewillbebrad

    therewillbebrad

    Joined:
    Mar 2, 2018
    Posts:
    151
    Also has anyone gotten this to work with master audio?
     
  47. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
  48. davidsebek85

    davidsebek85

    Joined:
    Mar 18, 2018
    Posts:
    10
    Hello, I want to ask, in my game I use a giant scene where I have ocean and small islands. ocena, however, is not mash but shader. It could be fixed so that i would make a fake ocean from cube it across the terrain so it will imitate the edges where the water ends and the island begins. Question is if the sound will go under the terrain where is the fake ocean.
     
  49. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,412
    Yes it will, because there's no simple way to calculate where the shore is. You would have to cut the mesh up so there is no water under the island, and then the sound position can be calculated correctly.
     
  50. davidsebek85

    davidsebek85

    Joined:
    Mar 18, 2018
    Posts:
    10
    thx for your answer