How to Pass Geometry to Wwise Spatial Audio
The game's geometry is passed to Wwise Spatial Audio via AK::SpatialAudio::SetGeometry()
, and is described by the AkGeometryParams structure. Here is a high-level view of what it consists of:
- Vertices (AkVertex) are defined in an array,
AkGeometryParams::Vertices
, which is separate from the triangles, and each triangle in the triangle array AkGeometryParams::Triangles
references indices in the vertex array.
- Each triangle also includes an index to an
AkAcousticSurface
structure, which defines the acoustic texture and description string.
- The correspondence between acoustic surfaces and triangles is up to the user. For example, the user may choose to have one surface for each triangle, a single surface for all triangles, or something in between.
- Defining acoustic surfaces is optional. If it is not desired to customize the acoustic properties of a surface, the triangles may be left as AK_INVALID_SURFACE and NULL may be passed into
AkGeometryParams::Surfaces
and AkGeometryParams::NumSurfaces
set to zero.
Additional Considerations
Generally, any triangle mesh can be used with Wwise Spatial Audio, however there are a number of important considerations.
- The mesh should be as simple as possible. Acoustic calculations involve a large number of ray tracing operations and can get expensive. The smallest number of triangles that can be used to represent a scene is best.
- All triangles are double-sided. Acoustic reflections occur off of both sides of the triangle, therefore it can be beneficial to create meshes that have no interior volume. For example, a wall could be a plane rather than a box.
- Duplicate vertices should be “welded” together in order to create a continuous mesh. In other words, two connected triangles should reference the same two vertices in the vertex array. This is important for diffraction calculations, otherwise it is possible for sound to leak through the mesh.
- All vertex coordinates are in world space.
- Meshes that are sent to spatial audio via multiple calls to set geometry cannot reference the same vertices, and therefore are not considered connected or continuous. In this case, diffraction edges will not be generated for edges that span multiple meshes.
- Meshes must not have any degenerate triangles. All triangles must have an area greater than zero.
- Additional rules apply if you wish to use Geometric Diffraction with your geometry. Refer to Using the Geometry API for Simulating Diffraction and Transmission for more details.