Version

menu_open
Wwise SDK 2021.1.14
Raytracing Engine Geometry Guide

Introduction

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.

Concepts

  • 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

Settings

  • 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.

CPU Limit Mode

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. Note that the CPU Limit Mode has no effect on portal ray tracing.

Limitations

There are a few limitations when defining geometries for the raytracing engine. The limitations concern both the performance and the quality of the results.

Geometry visible angle

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.

In this example, gamma is smaller than alpha. Hence, the probability of finding an intersection with the object is high.
In this example, alpha is smaller than gamma. Hence, the probability of finding an intersection with the object is low.

Number of triangles

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.

Here the plane is composed of 4 triangles: the rays have to be tested against each triangle.

Geometry shape

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.

In this situation, we expect to find the diffraction path from L to E that goes through L, E2, E3, E4, and E. Unfortunately, the surface between E1 and E2 is small and thus it is difficult to find the necessary intersection that will provide the diffraction edge E2. In this case, the intersection with E1 is more likely. L is not in the shadow zone of E1, preventing the algorithm from actually finding the diffraction path from E2.

Improving Performance

The Performance Monitor can be configured to display many counters related to spatial audio CPU usage. Refer to Performance Monitor Settings for details. The following table provides information you can use to improve spatial audio performance depending on the values of these counters when profiling.

Symptoms Possible solutions
All spatial audio-related counters are high
  • Decrease the order of reflections: 1st and 2nd order of reflections are sufficient in most cases.
  • Disable diffraction and/or reflection on diffraction if not needed: Computing diffraction is CPU intensive. Turn off bEnableGeometricDiffractionAndTransmission and/or bEnableDiffractionOnReflection.
  • Reduce the number of edges in the scene:Objects with a high level of detail increase CPU cost and tend to decrease overall quality.
  • Use rooms and portals: If your scene is composed of independent sections, consider using rooms and portals to isolate them.
  • Increase the motion threshold: Small values might "scan" the environment too often, depending on the size of the geometries. Consider setting this to the highest possible value that maintains good quality results.
  • Decrease the number of triangles if possible: Objects with a high level of detail increase CPU cost and tend to decrease overall quality.
Spatial Audio - Raytracing CPU is high
  • Decrease the number of primary rays: Values as low as 20 can still produce good results.
  • Enable CPU limit (CPU Limit Mode): Set your desired CPU percentage, and the feature will automatically control the number of primary rays to keep the CPU around the specified value. Note that this will have no effect on portal ray tracing.
  • Increase the motion threshold: Small values might "scan" the environment too often, which reduces the average performance CPU but does not noticeably affect the peaks.
Spatial Audio - Path Validation CPU is high
  • Disable diffraction and/or reflection on diffraction if not needed: Computing diffraction is CPU intensive. Turn off bEnableGeometricDiffractionAndTransmission and/or bEnableDiffractionOnReflection.
  • Reduce the number of edges in the scene: Objects with a high level of detail increase CPU cost and tend to decrease overall quality.
Spatial Audio - CPU is high (path validation and ray tracing are both involved)
  • Increase the motion threshold: In this case, increasing the motion threshold reduces the average CPU consumption more than it reduces the peaks.

Was this page helpful?

Need Support?

Questions? Problems? Need more info? Contact us, and we can help!

Visit our Support page

Tell us about your project. We're here to help.

Register your project and we'll help you get started with no strings attached!

Get started with Wwise