Wwise SDK 2021.1.2
Raytracing is a technique for efficiently evaluating nth-order reflection and diffraction. The basic idea is to randomly cast rays from the listener and follow their paths through a series of reflections and diffraction. The technique is inspired by graphic rendering techniques. The current implementation supports up to 4th order of reflection and diffraction on the listener and emitter sides.
- Primary rays: the rays directly cast from the listener
- Reflection: bouncing of sound on surfaces
- Diffraction: bending of sound around objects
- Paths: series of reflections/diffractions from the listener to an emitter
- Emitter receptor: bounding box or bounding sphere centered around an emitter
- Number of Primary Rays (uNumberOfPrimaryRays): The number of rays cast from the listener. Increasing the number of primary rays gives better results but costs more CPU time. The default value is usually good for most applications.
- Maximum Reflection Order (uMaxReflectionOrder): The maximum number of times the ray will successively bounce off surfaces. Increasing the maximum order of reflection leads to a more detailed acoustic simulation but can highly impact the CPU performance.
- Direct Diffraction Path (bEnableGeometricDiffractionAndTransmission): A direct diffraction path between the listener and an emitter is a path composed exclusively of diffraction segments. Enabling direct diffraction path computation increases significantly the CPU cost.
- Diffraction on Reflections (bEnableDiffractionOnReflection): Enables diffraction at the beginning and the end of a reflection path (a path composed only of reflection segments). Enabling diffraction on reflections prevents the simulation to unexpectedly drop reflections when the emitter or the listener moves behind an obstacle. As with direct diffraction path, it significantly increases the CPU cost.
- Maximum Path Length (fMaxPathLength): Maximum length of a path segment. High values compute longer paths but increase the CPU cost.
- CPU Limit Mode (bEnableCPULimitMode): If enabled, the raytracing engine automatically limits the number of primary rays to ensure CPU usage remains around the CPU Limit Percentage.
- CPU Limit Percentage (fCPULimitPercentage): The target percentage (expressed as a percentage of an audio frame) used by the raytracing engine to compute reflections and diffractions.
Tweaking the number of primary rays can be tricky as it depends on the complexity of the scene (number of triangles, number of diffraction edges...) and the number of emitters. When CPU Limit Mode is active, the raytracing engine automatically adapts the number of primary rays to ensure CPU usage remains around the target value defined by the user. Although this mode minimizes peaks in CPU usage it cannot completely remove short and sudden peaks. Setting a high target value increases quality (number of reflection and diffraction paths found) at the cost of performance. While setting a low target value increases performance at the cost of quality. When CPU Limit Mode is active, the number of primary rays is capped at 500. When the number of primary rays drops down to 0, the raytracing engine stops scanning the environment. However the existing sound propagation paths are still validated and updated. As a consequence, the raytracing engine still consumes CPU.
There are a few limitations when defining geometries for the raytracing engine. The limitations concern both the performance and the quality of the results.
When a triangle is smaller than the sampling density, the raytracing engine is less likely to find it.
The geometry's visible angle alpha is the angle at which the geometry is seen from the point of view of the listener. Depending on the number of primary rays, the average angle (gamma) between two rays varies. The relation between alpha and gamma influences the probability of finding an intersection (a reflection or a diffraction) with the object. If gamma is smaller than alpha, the probability of finding an intersection is high. If gamma is bigger than alpha, the probability of finding an intersection is low.
The number of triangles contained in the geometry is directly related to the CPU usage of the engine: the more triangles, the higher the CPU usage. This is due to the fact that more intersection tests are required on the object. Usually, sound propagation does not require highly detailed geometry. Reducing the number of triangles can help increase the performance without sacrificing quality.
Some geometry shapes are more difficult to process than others. Usually, geometries like planes and boxes are simple to process and give the best results in terms of sound propagation. Spheres and cylinders are more prone to errors. This is due to the curvature introduced by the sphere and the cylinder. Some diffraction edges may not be found, which would cause some diffraction paths to be missed. The algorithm implements several heuristics to overcome this issue in most cases. Increasing the number of primary rays or simplifying the geometry can solve the issue as well.