-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ray casting in Unity without prebaking #375
Comments
@LVamos Could you provide a little more information about which features of Steam Audio you are currently using? The feasibility of doing everything at runtime depends on this. In general, you would have to use a C# script to call the same function that the Steam Audio Unity plugin calls when you try to export a scene in the editor. This is One potential complication is that if your project is using static batching for optimizing mesh rendering, the geometry data may not be accessible at run-time, so you may have to use run-time static batching to work around this: https://docs.unity3d.com/Manual/static-batching.html. If all you need is occlusion (and not reflections, reverb, etc.), then you can also consider using Unity's built-in ray tracer, which does not require anything to be exported in the editor. See https://valvesoftware.github.io/steam-audio/doc/unity/settings.html for more. Hope this helps! |
@lakulish All steps, except setting up the mixer, were done programmatically in an editor script. The script runs only once, as I placed a return statement at the start after execution.
Then, at runtime:
I tried disabling reverb on the |
Hi! We're sort of going through a similar issue where a lot of stuff has to be performed at runtime. I'm not sure how much I'll be able to help, but I wanted to provide a sanity check.
It's not just you, nor do I believe it's your geometry. From our experience, the Unity implementation for real-time reverb appears to be very weak or non-existent. What you're likely hearing is just reflections. We ran into the exact same issue with our FMOD/Unity 2021 implementation. As soon as we switched to baked (and we added a baked listener/probe batches to the scene "before" runtime), reverb started working great. Obviously, that's a problem when you're trying to build something that handles everything at runtime. I'm finding it difficult to do what you're describing (as intended by the current implementation, there isn't a lot of info on how to do this programmatically in the docs).
SteamAudioManager is automatically created, so you might have two managers in your scene if you're doing this. What would be helpful is if we can clarify if real-time is supposed to sound exactly the same as baked reverb. The difference for us was night and day. I can try to get a small test project to demonstrate/double check but I might need some time. |
@bytecauldron |
@bytecauldron I tried to add a SteamAudioProbeBatch into the scene, generating probes and baking but the Unity editor crashed right after game startup. |
Yeah, I figure you're trying to get things to bake via a script. I just don't think that will work out of the box. I couldn't get it to work either, but I'm pretty new to Steam Audio myself. The only way I was able to get baked reverb to work was by utilizing the Generate Probes and Bake buttons available on the Probe Batch component itself, not programmatically. So, I'm not sure how useful it would be to list off the steps for you if you're trying to do that exclusively through scripting. |
@bytecauldron |
So, from my limited testing (grain of salt, I'm using fmod), I'm finding that regardless if you use real-time or baked, reverb in isolation is just extremely subtle. The reason why it's more pronounced in baked is because of pathing, which is only available with probes. Without reflections and pathing, it can be much more subtle depending on the sound and surrounding geometry. I have to really crank the reverb mixer to hear any noticeable changes. |
@bytecauldron |
Ok, couple of things. You're correct in saying that using both native Unity reverb alongside Steam Reverb in the mixer leads to unrealistic sounds. More like, it just sounds muddier to me, at least when I did it with FMOD. However, I would say there's nothing wrong with using the native Unity option combined with the Steam Spatializer (without Steam Reverb) in cases where you really want to ham up the reverb but do not have the surrounding geometry/reflections/materials to justify it. If you have dynamic sounds where the surrounding geometry changes, then I would just use Steam Reverb. No idea how helpful this will be to you since I set this all up via scene view and dragging components in, but maybe it will give you a baseline of what I think it's supposed to sound like.
dry_no_reverb.mp4
realtime_reverb_reflections.mp4
baked_reverb_reflections_pathing.mp4Pathing really doesn't have "that" big of a change when comparing baked reverb to realtime. It seems to help a lot with occluded sounds reaching the listener more accurately, and updating reflections reaching the listener when it changes its orientation quickly, but it isn't going to have a dramatic effect on reverb. Sorry I can't be more helpful, I'm not familiar with other audio plugins. I'm sure someone smarter can chime in, but I would say you're better off trying to get realtime to work first and foremost with scripting, because the extra steps necessary to get other forms of baking (probe batches and static source baking) to work via scripting at runtime is a tall order. |
@LVamos @bytecauldron There seems to be some confusion here regarding how various Steam Audio features work together, so I'll try to clarify. First, a couple of potential issues I noticed in the files you provided:
Also, there seems to be some confusion about what reflections, reverb, and pathing do. Briefly:
So you usually don't want to combine reflections with either reverb or pathing. You can combine reverb and pathing, of course. As for why baked reverb might sound different from real-time reverb: the ray tracing involves calculated repeated reflections of rays off of geometry. Each extra bounce we model increases the CPU usage. So in real-time reverb, we model far fewer bounces (by default), whereas in baked reverb, we model many more bounces. Again, these are just the default settings, so you can change the number of bounces used by real-time reverb (by setting "Real-Time Bounces" to be equal to "Baking Bounces"), and see if that helps. |
@lakulish This is extremely helpful and clears up a lot, thank you so much. Definitely check your
I have no idea why I thought you could mix and match these, but it makes sense. Two separate strategies for sound propagation. |
@lakulish @bytecauldron
I’m really short on time, and my game development is stalled because of these issues, so I’ve been experimenting with Meta XR Audio and Resonance Audio at the same time. But I still think Steam Audio is the best tool. Hopefully, I’ll get the hang of it soon. |
@LVamos I'm attaching an updated mixer file that should match the setup I described. Let me know if you run into any issues. Reverb and reflections are similar in that the fundamental computations needed for both are the same: ray tracing. They are different in that reflections are source-to-listener, and reverb is listener-to-listener. So in your example, assuming footsteps can be considered to be emitted from the listener's position, you need reverb + occlusion + pathing. The occlusion and pathing will model how sounds get from distant sources to the immediate vicinity of the listener, and the reverb will model how sounds bounce off of geometry around the listener. Note that the tail length of a reverb is a function of how many times sound bounces around within a space, so you will need to increase the number of bounces in order to get a more realistic reverb for spaces like a cathedral. Hope this helps! |
@lakulish Thanks a lot! Now it sounds beter. We'll see how it behaves once I create the geometry for each game object. I still have a few questions.
|
@LVamos To answer your questions:
Hope this helps! |
@lakulish Does it mean that the objects with SteamAudioSource should alway move gradually without big leaps? I use object pooling for all sounds in the game. Whenever I want to play a sound, I pick up a GameObject from the pool, set appropriate Steam Audio parameters, move the containing object to the target position and start the playback. So it is likely that a particular SteamAudioSource will be moved over long distances. |
@LVamos Strictly speaking, it's fine for an object with a Steam Audio Source component to move with big leaps, as long as it's the same game object. So it's fine for a teleporting NPC, but you shouldn't use the same Steam Audio Source for different NPCs that are active at the same time. Note that there will be some smoothing of audio parameters to prevent glitches and artifacts due to the sudden change. Having said that, the Steam Audio API also provides functions to allow the same audio effects to be reused for different objects, which is needed when using pooling. However, there is a bug/limitation with Unity where it does not correctly call these API functions. I reported this issue to Unity, but was told that this was by design. So if you're using Unity's built-in audio engine, it will be difficult to get completely artifact-free pooling to work. |
@lakulish I’ve been trying to follow all your advice, but the reverb still sounds super unrealistic to me. The sound is oddly choppy, with the reverb tail quickly bouncing between the left and right channels, and the echoes repeat way too frequently and keep the same volume most of the time instead of gradually fading out. Plus, I can’t seem to get a smooth, gradually fading reverb tail, even in a geometry that’s supposed to match a long, empty corridor. Instead, I’m hearing something that sounds more like a simple repeative echo effect. |
Hi,
I'm blind and due to big accessibility issues in Unity editor, I have to create all game objects programmatically at runtime. For the same reasons I'm not able to perform pre-baking. Is it possible to make all objects dynamic and let the Steam Audio do all the calculations at runtime? I'm desperate, I asked this question in several discussions but noone was able to help me with this.
The text was updated successfully, but these errors were encountered: