diff --git a/include/Loaders/SteamAudioMapMeshLoader.hpp b/include/Loaders/SteamAudioMapMeshLoader.hpp index 1b7a926..23e48e7 100644 --- a/include/Loaders/SteamAudioMapMeshLoader.hpp +++ b/include/Loaders/SteamAudioMapMeshLoader.hpp @@ -45,9 +45,10 @@ namespace MetaAudio // Transmission details: // SteamAudio returns the transmission property of the material that was hit, not how much was transmitted - // We should calculate ourselves how much is actually transmitted. The unit used in MetaAudio is actually - // the attenuation `dB/m`, not how much is transmitted per meter. - std::array materials{ {0.10f, 0.20f, 0.30f, 0.05f, 0.100f, 0.050f, 0.030f} }; + // We should calculate ourselves how much is actually transmitted. + // The unit used in MetaAudio was the attenuation `dB/m`, not how much is transmitted per meter. + // However, SteamAudio >4 now clamps to 1.0f so this was changed back to transmitted per meter. + std::array materials{ {0.10f, 0.20f, 0.30f, 0.05f, 0.800f, 0.200f, 0.100f} }; public: SteamAudioMapMeshLoader(SteamAudio::Context sa_context, IPLSimulationSettings simulSettings); diff --git a/src/Effects/SteamAudioOcclusionCalculator.cpp b/src/Effects/SteamAudioOcclusionCalculator.cpp index e468e68..995de8b 100644 --- a/src/Effects/SteamAudioOcclusionCalculator.cpp +++ b/src/Effects/SteamAudioOcclusionCalculator.cpp @@ -88,7 +88,8 @@ namespace MetaAudio simulator.SourceRemove(source); simulator.Commit(); - if (result.direct.occlusion < 0.5f) //more than half occluded, add transmission component based on obstruction length + // More than half occluded, add transmission component based on obstruction length + if (result.direct.occlusion < 0.5f) { pmtrace_s tr; @@ -108,9 +109,12 @@ namespace MetaAudio if ((tr.fraction < 1.0f || tr.allsolid || tr.startsolid) && tr.fraction < 0.99f && !tr.startsolid) { auto distance = obstruction_first_point.getDistance(tr.endpos) * AL_UnitToMeters; - result.direct.transmission[0] = alure::dBToLinear(-distance * result.direct.transmission[0]); - result.direct.transmission[1] = alure::dBToLinear(-distance * result.direct.transmission[1]); - result.direct.transmission[2] = alure::dBToLinear(-distance * result.direct.transmission[2]); + if (distance > 0) + { + result.direct.transmission[0] = std::clamp(result.direct.transmission[0] / distance, 0.0f, 1.0f); + result.direct.transmission[1] = std::clamp(result.direct.transmission[1] / distance, 0.0f, 1.0f); + result.direct.transmission[2] = std::clamp(result.direct.transmission[2] / distance, 0.0f, 1.0f); + } } } }