Wwise Version
arrow_right Table of Contents
Wwise SDK 2021.1.5
Using the Geometry API for Simulating Diffraction and Transmission

Introduction

The geometry passed to Wwise Spatial Audio may be used to simulate diffraction and transmission of sound. As such, it can completely replace your game engine's raycasting methods for computing obstruction.

When an emitter is hidden from a listener by an object, Spatial Audio computes paths along its edges and, if some are found, computes the diffraction coefficient resulting from the sound bending around these edges. The apparent angle of incidence of the emitter is modified accordingly, and the diffraction value is sent to Wwise where you may control how it ultimately affects the sound. Typically, diffraction results in low-pass filtering.

Additionally, Spatial Audio computes sound paths going through geometry. Sound transmitting though an obstacle has a transmission loss coefficient applied to it, resulting from the surface properties assigned to the geometry via the API. Typically, transmission loss is modeled with a low-pass filter and a volume attenuation.

The image below is a screenshot of the Game Object 3D Viewer in Wwise. It shows a sound with a diffraction path, diffracting around the edges of a thin wall, and a transmission path with a transmission loss of 100%.

Warning: Geometric diffraction and transmission can be used to entirely replace your game engine's raycasting method for computing obstruction, however the performance cost grows with the complexity of the geometry. Geometry passed to Spatial Audio should be kept as simple as possible. Also, it is good to use the efficient Rooms and Portals abstraction (see Rooms and Portals) in conjunction with Geometric Diffraction in order to reduce the computational complexity of the latter.

Geometric diffraction can be used to affect the direct sound propagation path between the emitter and listener, but also the path of its early reflections, when used in conjunction with Wwise Reflect.

Setting Up Geometry for Diffraction

Each geometry set that is passed to Spatial Audio needs to say explicitly whether it should be considered for calculating diffraction paths. This is done via the AkGeometryParams::EnableDiffraction flag. This flag enables generation of edge data that is necessary for diffraction calculations, and is used for both geometric diffraction on the direct path and for diffraction of reflections.

Also, consider whether or not you want the boundary edges of a mesh to be able to diffract sound. For a given mesh, a boundary edge is defined as an edge that is connected to only one triangle and, therefore, exists on the boundary of the manifold. The complexity of the diffraction calculation increases with the number of edges, so the option should be disabled if your mesh contains boundary edges that should not diffract sound.

Finally, note that acoustic textures assigned to acoustic surfaces do not have any effect on diffraction because edge materials don't absorb energy. Edges simply bend sound.

Setting Up Geometry for Transmission

There are no additional steps required to set up geometry for sound transmission, however it may be desirable to adjust the transmission loss coefficient for various geometry types. For example, a concrete structure is likely to block almost all sound transmission, whereas geometry composed of plywood may block significantly less sound.

Each AkTriangle in the AkGeometryParams::Triangles array contains AkTriangle::surface, an index into the AkGeometryParams::Surfaces array. The AkAcousticSurface::transmissionLoss field describes how much transmission loss to apply to a sound transmitting though a triangle that references it. It is expressed as value between 0 and 1. The transmission loss is converted to a percentage and then used to evaluate the occlusion curve (assuming AkSpatialAudioInitSettings::bUseOcclusion is enabled). The final volume attenuation and filter value applied to a sound with a given transmission loss will depend on the occlusion curves defined in the Wwise Project Settings. Transmission loss may also be applied as a built-in parameter and can be mapped to an RTPC.

Geometric Diffraction of the Direct Path

You are invited to review the Geometric Diffraction demo in the Integration Demo sample (in SDK/samples/IntegrationDemo) for an example of using geometry for the purpose of geometric diffraction of the direct path. Look for Demo Positioning > Spatial Audio: Geometry.

Setting up a Sound for Diffraction and Transmission

In the Positioning tab in the Wwise Authoring tool, ensure that Enable Diffraction and Transmission is checked. This box enables Spatial Audio features related to diffraction and transmission, including:

  • Computation of the diffracted path of the sound through geometry and/or portals, if applicable. The path calculation is performed by Spatial Audio on each game object that is currently playing a sound with diffraction and transmission enabled. If multiple diffraction-enabled sounds are playing on the same game object, the path calculation is only performed once.
  • Computation of the transmission path of the sound, through geometry and/or between rooms. The final transmission loss coefficient is always taken as the largest transmission loss value encountered along the transmission path, whether it comes from a room's AkRoomParams::transmissionLoss or a triangle's associated AkAcousticSurface::TransmissionLoss.
  • Generation of virtual positions for diffraction paths, which are sent to the Sound Engine for rendering the sound, assuming Spatial Audio's initialization setting AkSpatialAudioInitSettings::bCalcEmitterVirtualPosition is set.
  • Application of the obstruction curve according to the diffraction coefficient, assuming Spatial Audio's initialization setting AkSpatialAudioInitSettings::bUseObstruction is set. In the case that the game has also set an obstruction value via AK::SoundEngine::SetObjectObstructionAndOcclusion, the maximum of the two values is used.
  • Application of the occlusion curve according to the transmission loss coefficient, assuming Spatial Audio's initialization setting AkSpatialAudioInitSettings::bUseOcclusion is set. In the case that the game has also set an occlusion value via AK::SoundEngine::SetObjectObstructionAndOcclusion, the maximum of the two values is used.

Direct Path Diffraction and Transmission in Wwise

Diffraction and transmission may be observed in the Game Object 3D Viewer, provided the proper profiling settings and view options are set (see the following images).

The calculated diffraction factor on a path from emitter to listener is displayed for each diffracting edge. This diffraction factor is conveyed to Wwise via either the Built-In Game Parameter called Diffraction or via the emitter's Obstruction value, if AkSpatialAudioInitSettings::bUseObstruction is enabled. Built-in Game Parameter values may be profiled by adding the bound Game Parameter to the Game Sync Monitor, and Obstruction and Diffraction may be profiled in the Profiler's Obs/Occ tab.

The calculated transmission loss factor is displayed beside the corresponding transmission path in the Game Object 3D Viewer. If the source of the transmission loss is from geometry, a hit point is indicated, with the accompanying transmission loss percentage. If the source of the transmission loss is from a room, the transmission loss percentage is displayed with the text "(Room)" appended below.

Like with Portals, the Diffraction value is 0 when the emitter is in direct sight of the listener, and it begins to increase as the emitter penetrates the shadow zone (see Diffraction). Also, please refer to Rooms and Portals' Diffraction for more details on shadow zone diffraction and for a discussion about using the Built-in Diffraction Game Parameter versus Obstruction.

Direct Path Diffraction Interaction with Spatial Audio Rooms and Portals

With Spatial Audio Rooms and Portals (Rooms and Portals), Portals also model diffraction of direct sounds in adjacent rooms. The two systems complement each other in that no geometry-driven diffraction paths are searched for emitters that are not in the same room as the listener. Provided that Rooms and Portals are much more efficient to calculate than geometry, it is beneficial to use both systems together to reduce computational complexity.

Geometric Diffraction of Early Reflections

As was noted above, early reflections may diffract off of edges, and Spatial Audio supports modeling this phenomenon when emitters are routed to Wwise Reflect.

Prior to explaining how to do it, we need to define view zone diffraction.

Consider the figure below. The emitter is in direct sight of the listener, but the listener is not hit by specular reflections. It is thus in the view zone. As was said in Diffraction, diffraction occurs in the view zone as well. However, in Wwise Spatial Audio, neither the Rooms and Portals or Geometric Diffraction of direct path models consider diffraction in the view zone, as it is negligible compared to the actual direct path. However, for reflections, view zone diffraction has a dramatic impact. Without diffraction, early reflections are heard in the reflection zone only, where they are purely specular. As soon as the listener enters the view zone, reflections become silent. With diffraction enabled, the edge contributes to diffract the reflected wave. Thus, the listener perceives the reflection, albeit with additional filtering and attenuation as they go around and away from the reflection zone.

In the reflection zone, no diffracted path and, therefore, no diffraction value is calculated, because the specular reflection is assumed to take over. The calculated view zone diffraction of a given edge is 0% at the boundary between the reflection zone and the view zone, and 100% at the boundary between the view zone and the shadow zone.

With higher orders of early reflections, both view and shadow zone diffraction come into play.

Enable Reflections on Applicable Sounds

In the Wwise Authoring Tool, set the desired early reflections send to an aux bus containing Wwise Reflect for all sounds requiring reflections. Refer to Wwise project setup for more details. There is no specific setting needed to enable diffraction for the purpose of reflections' diffraction, apart from enabling diffraction on the geometry.

Settings in Wwise Reflect

Reflections that undergo diffraction effects will appear as image sources in Wwise Reflect. You may design the effect of diffraction on reflections with the three curves that depend on diffraction: Diffraction Attenuation, Diffraction LPF, and Diffraction HPF. See Wwise Reflect's documentation for more details.

Combining the Geometric APIs with Rooms and Portals

Rooms and portals in Wwise Spatial Audio work in conjunction with the geometric APIs for reflection and diffraction. The rooms and portals network can be thought of a high level abstraction (or as a low level-of-detail version) of the surrounding geometry. With care, the combination of rooms and portals with level geometry can result in a acoustic simulation that is both detailed and efficient.

Geometric Diffraction Through Portals

In the case where an emitter (assuming it is playing a sound that has been set up correctly for geometric diffraction, see Setting up a Sound for Diffraction and Transmission), is not in the same room as the listener, the geometric path is calculated as follows:

  • The sound propagation paths from the emitter to the listener are calculated using the rooms and portals network.
  • For each path, the segment of the path between the emitter and the portal closest to the emitter is calculated using the geometric diffraction algorithm, as if the portal were the listener. Unless the emitter is directly behind a single portal from the perspective of the listener, only one geometric path is calculated (the shortest one found). Calculating additional paths between the emitter and the portal would not result in unique virtual positions, and is therefore unnecessary.
  • Path segments that are between two portals are also calculated using geometric diffraction if there is no direct line of sight between the portals. These calculations are done each time geometry and/or portals are added to or removed from the scene, and reused when required. In most cases, only the shortest path between the two portals is used. The exception being when the listener is directly behind one of the portals, in which case multiple paths are used to avoid discontinuities should the listener transition through the portal.
  • For each path, the segment of the path between the listener and the portal closest to the listener is calculated using the geometric diffraction algorithm, as if the portal were the emitter.
  • The resultant paths are taken as the combination of the above paths, branching and appending paths together where necessary.

Reflections Through Portals

Reflections are able to pass through portals, even if there are up to two planes intersecting the opening of the portal. Since the portal itself describes an acoustic opening, it is not necessary to also "cut holes" in the triangle geometry to allow a sound to pass through, which would greatly increase the number of triangles. One example is a room where the geometry is described by a box, with two triangles for each of the six sides. If users would like sound to be able to propagate outside the box, then they simply add a portal intersecting one of the walls along the portal's z-axis. As usual, the game is responsible to distinguish which game objects are inside the room and which are outside using AK::SpatialAudio::SetGameObjectInRoom (see Rooms and Portals Overview). In the case where an emitter (which is playing a sound that has been set up correctly for reflections, see Wwise project setup) is not in the same room as the listener, and as long as the sound is reachable on the sound propagation network, then reflection simulation is performed. The reflections are calculated as follows:

  • A reflection calculation is performed between the emitter and each portal connected to the emitter's room, as if the portal were the listener.
  • The diffraction path between the portal and the listener is calculated as described in Geometric Diffraction Through Portals and appended to the reflection path between the portal and the emitter.
  • The reflection calculation is not performed if the diffraction path exceeds 100% diffraction and the calculation is abandoned if at any point it does so.

Tips for Orienting Portals Between Rooms with Geometry

The following image shows an example of a correctly oriented portal.

  • Geometry cut-outs allow reflection and diffraction paths to pass through the portal.
  • A rectangular opening is subtracted from up to two planes overlapped by the portal. A single plane is defined by one or more coplanar triangles, passed to the Spatial Audio Geometry API.
  • Geometry cut-outs are drawn in the Game Object 3D Viewer with a dark green outline.
  • For correct cut-out detection, the two planes must be non-intersecting (but not necessarily parallel), and they both must span the entire width (X) and height (Y) of the portal.
  • A gap is permitted between the two planes, as well as between the two rooms joined by the portal. However, a game object is only permitted to enter a portal if it was previously in one of the adjoining rooms.
  • When a game object is transitioning through a portal, the room containment result passed to AK::SpatialAudio::SetGameObjectInRoom is used only as a hint. The exact room is determined by projecting the game object's position onto the portal's Z-axis, and then testing if the game object is in the front-half or back-half of the portal, corresponding to the front and back rooms respectively.
  • The portal does not need to be perfectly aligned and centered between the two rooms.
  • The middle of the portal is always the transition point between the two rooms.
  • Ensure that a portal is deep enough along the Z-axis to allow for a smooth transition between two rooms.
  • Abrupt transitions between two rooms can often be resolved by lengthening the portal along the Z-axis.

Tagging Geometry for Specific Rooms.

As an optimization to limit the search space for ray-triangle intersection test and surfaces which may generate reflections, it is possible to manually assign geometry to specific rooms. To do so, set AkGeometryParams::RoomID to the ID of a particular room. This indicates to Spatial Audio that the geometry in that room is only visible from other rooms through portals and not directly. Since a single geometry set can only be associated with one room ID, a room can not have geometry that should be visible in multiple rooms unless AkGeometryParams::RoomID is left invalid. Also note that if any geometry set is associated with a particular room ID, then that room can not longer "see" geometry that has not been explicitly associated with that room. After assigning a geometry set to a room, Spatial Audio will only look for geometry that is specifically associated with that room ID when simulating reflection and diffraction in that room.