The effect of using Baked data in SteamAudio C API for reflection is different from using runtime reflection.
Hi
I've encountered some issues while using the C API, specifically regarding reflection.
I generated baked data for my static sound sources, and that went smoothly—I'm glad it worked properly. However, when I used the baked data to apply reflection effects, I noticed that the reflected sound didn’t sound quite the same as when reflection is handled at runtime. In my scene, there’s a large room with two small cube geometries acting as obstacles. The baked data seems to only capture the reverberation of the large room, without the reflective sound from the small cube obstacles. But with runtime reflection, the effect is clearly audible.
I initially thought this might be because the parameters I used for baking were different from the runtime reflection parameters. So, I lowered the baking reflection parameters to match the runtime settings, but the result was still the same.
I’m not sure why this is happening. Could anyone offer some advice?
Thank you so much!
The code I baked is like this, I don't know if there are any parameters that are not set correctly:
static unsafe void BakingProbes()
{
// Generate probes
IPL.ProbeArray array;
IPL.Matrix4x4 matrix = new IPL.Matrix4x4();
var tempM = new float[] {
100.0f, 0.0f, 0.0f, 0.0f,
0.0f, 100.0f, 0.0f, 0.0f,
0.0f, 0.0f,100.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
for (int i = 0; i < tempM.Length; ++i)
matrix.Elements[i] = tempM[i];
IPL.ProbeGenerationParams pgp = new IPL.ProbeGenerationParams();
pgp.Type = IPL.ProbeGenerationType.UniformFloor;
pgp.Spacing = 2;
pgp.Height = 1;
pgp.Transform = matrix;
IPL.ProbeArrayCreate(iplContext, out array);
IPL.ProbeArrayGenerateProbes(array, Scene, ref pgp);
IPL.ProbeBatch pb;
IPL.ProbeBatchCreate(iplContext, out pb);
IPL.ProbeBatchAddProbeArray(pb, array);
IPL.ProbeBatchCommit(pb);
IPL.BakedDataIdentifier id = new();
id.Type = IPL.BakedDataType.Reflections;
id.Variation = IPL.BakedDataVariation.StaticSource;
id.EndpointInfluence.Radius = 100;
// Start baking
IPL.ReflectionsBakeParams rbp = new();
rbp.Scene = Scene;
rbp.ProbeBatch = pb;
rbp.SceneType = IPL.SceneType.Embree;
rbp.Identifier = id;
rbp.BakeFlags = IPL.ReflectionsBakeFlags.BakeConvolution;
rbp.NumRays = 4096 * 8;
rbp.NumThreads = Environment.ProcessorCount;
rbp.NumDiffuseSamples = 1024;
rbp.NumBounces = 64;
rbp.SavedDuration = rbp.SimulatedDuration = Duration;
rbp.Order = NumOrder;
rbp.IrradianceMinDistance = 1;
IPL.ReflectionsBakerBake(iplContext, ref rbp, null, IntPtr.Zero);
MessageBox.Show("Size" + IPL.ProbeBatchGetDataSize(pb, id).ToString());
// Serialize and save probes
IPL.SerializedObject sObject;
IPL.SerializedObjectCreate(iplContext, new IPL.SerializedObjectSettings(), out sObject);
IPL.ProbeBatchSave(rbp.ProbeBatch, sObject);
var l = IPL.SerializedObjectGetSize(sObject);
Span<byte> data = new Span<byte>((void*)IPL.SerializedObjectGetData(sObject), (int)l);
File.WriteAllBytes("Baking.dat", data.ToArray());
// Release resources
IPL.ProbeArrayRelease(ref array);
IPL.ProbeBatchRelease(ref pb);
IPL.SerializedObjectRelease(ref sObject);
}
The location of the source is at 0,0,0, so the default location is correct, so I did not set it. There is one more thing I would like to ask by the way. When I bake the Routing data, the baking will crash directly. I am using the same scenario and the baking parameters are set according to the document. I don't know why this is happening.
Okay, let me further verify. It seems that the baking data only has an effect on reverberation in large rooms, but it does not have any reflection effect on geometric block occlusion in the room. Is this because my baking parameter settings are incorrect? And during runtime reflection, when I move outside the large room, there is no sound from the reflection. However, when using baking data, there is still a sound from the reflection when I move outside the room. Is this inconsistency normal?
Okay, it's really a problem with my parameter settings. I can solve the problem by setting the spacing to 1, which may be because my obstacle size is only 2. But I have a new question. If my room is double layered or even more, it seems that only the top layer has probes. How can I solve this problem? Does it mean that the probe falls down from the source position and hits the floor to generate the probe? If that's the case, this problem won't exist.