0
\$\begingroup\$

I can't find any information about Unity's performance difference between 3D and 2D audio.

If I'm targeting low-performance mobile devices, should I avoid using 3D audio?

How expensive (performance overhead) is 3D audio compared to 2D?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Performance questions are usually best answered by profiling. Something that was too expensive for one game on mobile might be just fine for yours because you have fewer audio sources than they had, or less CPU contention. So the best way to find out for sure what performance options are best for your game is to try them and profile them in your game. \$\endgroup\$
    – DMGregory
    Commented Jan 25, 2023 at 12:24

2 Answers 2

3
\$\begingroup\$

I have optimised and shipped 6 mobile games in Unity and have never had to do any audio optimisations. (Except changing music tracks to be streaming instead of decompress on load, and tweaking audio import settings for load time/memory improvements)

I can almost guarantee that your performance problems will be elsewhere, and worrying about something like audio with no indications that it's going to be a performance issue is likely going to distract your attention from other things that are more likely to be performance issues, eg scripts, garbage collection, draw calls, shaders, etc.

However, I would consider if positional audio is even a good idea for a mobile game. Many players may mute sound entirely. Does knowing where a sound comes from actually help the game, or does it just make the audio harder to distinguish?

I would say that using 2D vs 3D audio will make basically no difference, it's unlikely Unity would have some kind of check to skip some processing if an audio source is only 2D, as the savings would be extremely miniscule. (A distance check to calculate volume falloff is very simple and easily optimizable and cache-able, so it's likely highly optimised by Unity/Fmod anyway)

\$\endgroup\$
2
\$\begingroup\$

Audio optimisation techniques involve practices that are often shared among different engines. Many concepts and terms are standard in the audio domain, such as listeners, files, clips, and sources.

Unity's audio profiler is your to-go tool when searching for performance bottlenecks and issues you can't see (well, hear) when playing. It shows you how many audio sources are in your scene, different CPU consumption percentages per task, memory usage. These depend on the audio settings for your project, which you define according to what devices you're targeting.

Simple 3D audio is just audio where panning and volume depend on the direction and distance from the listener respectively. Unity does this automatically, letting you define additional parameters on a per-Audio Source basis:

  • Panning: you can control the Spatial Blend parameter to prevent left-only or right-only audio in certain cases. The performance cost is negligible.
  • Attenuation: you can define an attenuation function (or roll-off curve, which computes an audio source's volume depending on its distance from the listener. The performance cost depends on the function you set.

A logarithmic roll-off curve behaves differently from a linear roll-off curve: the former is more realistic, but the latter is less expensive to compute (especially if you have many sounds playing at once). All these computations are done by the CPU. While low-end devices are okay with rendering some 3D audio, overloading them with unnecessary instructions is definitely not what you want.


You can use 3D audio on low-end devices, as long as there isn't too much work for the processor. You can:

  • Use linear fall-off curves for 3D audio.
  • Limit the number of real voices (i.e. total count of audio clips actually played at the same time) in the Project Settings.

And use the Audio Profiler to check for possible bottlenecks in your audio performance. 3D audio works fine if there aren't too many audio files to stream/store in memory.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .