버전

menu_open
Wwise SDK 2023.1.3
Raytracing Engine Geometry Guide

Introduction

Raytracing is a technique for efficiently evaluating nth-order reflection and diffraction. 기본 개념은 리스너로부터 랜덤으로 레이를 캐스팅해 일련의 반사와 회절 경로를 따라가는 것입니다. 이 기술은 그래픽 렌더링 기술에서 영감을 받았습니다. Maximum Reflection order [1-4] and diffraction order [1-8] values are defined in the AkSpatialAudioInitSettings structure of AkSpatialAudio.h. Refer to AkSpatialAudioInitSettings for more details.

Concepts

  • 주요 레이 (primary ray): 리스너로부터 직접 캐스팅되는 레이
  • 반사 (reflection): 사운드가 표면에 부딪혀 나오는 것
  • 회절 (diffraction): 사운드가 물체를 돌아 굽어지는 것
  • 경로 (path): 리스너에서 이미터까지 이어지는 일련의 반사/회절

Settings

In order to tweak spatial audio CPU performance and quality, the raytracing engine uses several parameters. For a detailed description of the spatial audio settings, see AkSpatialAudioInitSettings().

CPU Limit Mode

Tweaking the number of primary rays can be tricky as it depends on the complexity of the scene (for example, the number of triangles and 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 the user-defined number of primary rays (see AkSpatialAudioInitSettings). When the number of primary rays drops 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 CPU Limit Mode doesn't have a significant effect on portal ray tracing. Portal ray tracing increases the CPU load and might therefore force the CPU Limit Mode to temporarily reduce the number of primary rays.

Load Balancing

Load balancing provides a way to flatten CPU peaks by distributing spatial audio task computation over several frames. Spatial audio executes different types of tasks, such as ray casting and path validation, to compute the sound propagation paths (reflections and diffraction). Whenever one of these tasks needs to be performed, it is placed in a priority queue for further processing instead of being executed immediately. The tasks in the queue are then executed over the number of frames specified in the load balancing spread setting.

Load Balancing Use Cases

There are several ways to tweak spatial audio performance: you can apply a CPU limit, change the order of reflection, enable or disable diffraction and diffraction on reflections, and adjust the motion threshold setting. You can combine load balancing with the other settings to achieve the desired balance between quality and performance.

Although load balancing can be used in any scenario, it is most appropriate for scenes that involve multiple active emitters. Load balancing behavior is controlled through the AkSpatialAudioInitSettings::uLoadBalancingSpread setting (see AkSpatialAudioInitSettings). A spread of 1 frame is equivalent to disabling the feature, because every task is executed immediately. Higher values increase CPU performance, but can lead to less accurate results. For example, a spread of 4 frames for a frame buffer of 1024 samples (around 21ms at 48kHz) executes the tasks over a period of 84 ms. Spread values under 10 should not noticeably affect quality.

Load Balancing Example

The following example compares the performance in the same scene with three different spread values: 1 (disable), 4, and 10. The scene has 944 triangles and 649 diffraction edges. The number of emitters is 4. Reflection order is set to 4 and diffraction is enabled.

An urban environment with several emitters.

The following table shows the effect of different load balancing values on the scene.

SpreadAverage CPU %Max CPU %
Disabled 4.8 52.76
4 3.16 23.26
10 1.71 10.22


With load balancing disabled, the number of emitters in a frame can go up to 4, which leads to high CPU peaks.


With a spread of 4, a maximum of 2 emitters are processed in a given frame, which lowers the CPU peaks.


With a spread of 10, only 1 emitter is processed in a given frame, which reduces CPU peaks even more.


Load Balancing FAQ

  • Does load balancing cause delays?

    Not exactly. It can introduce a "delay" in updating path information, but does not add latency to the audio signal. For instance, the same rays might be used until the next update. The paths are still computed at each frame, but are not validated at each frame. This means that some paths might be less accurate. For instance, specular reflection positions might be slightly inaccurate.

  • Does the load balancing improve the average CPU performance?

    Although load balancing primarily focuses on decreasing CPU peaks, it can also decrease CPU averages because it prevents the same type of task from appearing in the queue multiple times. If a task is in the queue, it must be executed before another task of the same type can be added to the queue.

  • Does load balancing improve CPU performance when there is only one emitter?

    Not significantly. Path validation is the most CPU-intensive spatial audio task. Given that one path validation task is executed for each emitter, load balancing is more appropriate for situations that involve several emitters. However, it can slightly improve single-emitter scenarios by preventing redundant computations.

Load Balancing in Depth

Whenever a spatial audio task needs to be performed, it is placed in a priority queue for further processing instead of being executed immediately. If the task is already in the queue, it is not placed in the queue again. This prevents redundant computation and reduces CPU consumption. At each frame, the number of tasks to process (N) is computed based on the number of elements in the queue and the load balancing spread settings. The first N priority tasks are pulled from the queue and executed.

In general, task priority is determined by the time at which the task was created (inserted): older tasks are executed first. For some tasks, such as the path validation tasks, the priority might be different. Whenever an emitter becomes active, the path validation task priority is increased to force the validation of the new paths. This is important to prevent delays in path creation.

A task is placed in the queue if it is not already scheduled.


At each frame, N tasks are pulled from the queue for execution.


There are 7 elements in the queue and the load balancing spread is set to 3. The number of tasks (N) that will be executed in this frame is CEIL(7/3) = 3. The tasks T1, T2, and T3 will be executed in the same frame. The process is repeated in the next frame.

Limitations

There are a few limitations when defining geometries for the raytracing engine. 이 한계에는 결과물의 성능과 품질이 모두 고려되었습니다.

Geometry visible angle

When a triangle is smaller than the sampling density, the raytracing engine is less likely to find it.

지오메트리의 가시 각도(visible angle) 알파는 리스너의 관점에서 지오메트리가 보이는 각도입니다. 주요 레이의 개수에 따라 두 레이 간 평균 각도(감마)는 달라질 수 있습니다. 알파와 감마 간 관계는 오브젝트와의 교차점(반사나 회절)을 찾아낼 수 있는 확률에 영향을 끼칩니다. 만약 감마가 알파보다 작을 경우, 교차점을 찾을 수 있는 확률은 높아집니다. 만약 감마가 알파보다 클 경우, 교차점을 찾을 수 있는 확률은 낮아집니다.

이 예시에서는 감마가 알파보다 작습니다. 따라서 오브젝트와의 교차점을 찾을 확률은 높습니다.
이 예시에서는 알파가 감마보다 작습니다. 따라서 오브젝트와의 교차점을 찾을 확률은 낮습니다.

Number of triangles

지오메트리 안의 삼각형 개수는 엔진의 CPU 사용과 직접적으로 연관돼있습니다. 즉, 삼각형 개수가 많을수록 CPU 사용량이 높아집니다. 이는, 해당 오브젝트에 대해 더 많은 교차점 검사가 필요하기 때문입니다. 보통 소리 전달에는 그렇게 상세한 지오메트리가 필요하지 않습니다. 삼각형의 개수를 줄이면 품질을 희생시키지 않고 성능을 높일 수 있습니다.

이 비행기에는 삼각형이 4개 있습니다: 각 삼각형에 대해 레이를 검사해야 합니다.

Geometry shape

다른 것보다 처리하기가 좀 더 까다로운 지오메트리가 있습니다. 일반적으로, 비행기나 상자같은 지오메트리는 처리가 단순하고 소리 전달 측면에서 봤을 때 가장 좋은 결과물을 냅니다. 구체와 원기둥은 오류를 발생시킬 확률이 더 높습니다. 이는 구체나 원기둥의 곡률 때문입니다. 일부 회절 경계를 찾지 못하면 회절 경로를 누락할 수 있습니다. 이 알고리즘은 몇몇 휴리스틱을 시행해 대부분의 이 문제를 해결합니다. 주요 레이 개수를 늘리거나 지오메트리를 단순화하는 방식으로도 이 문제를 해결할 수 있습니다.

여기서는 L, E2, E3, E4, E를 통과하는 L에서 E까지의 회절 경로가 나오게 됩니다. 아쉽게도 E1과 E2 간 표면이 작아 회절 경계 E2를 제공할 교차점을 찾기가 매우 어렵습니다. 이 경우, 대부분 E1의 교차점이 됩니다. L은 E1의 음영 영역(shadow zone) 안에 있지 않아 알고리즘이 E2로부터의 회절 경로를 찾지 못합니다.

Performance Tweaking

The following table provides information you can use to tweak parameters for different use cases.

SymptomsPossible solutions
Spatial Audio - General CPU issues
  • Decrease the order of reflection: 1st and 2nd order of reflection are sufficient in most cases.
  • Disable diffraction or reflection on diffraction if not needed: computing diffraction is CPU intensive. Instead of completely disabling diffraction, reduce the number of diffraction edges in the scene if possible.
  • 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 validate reflection and diffraction paths too often. Consider setting this to the highest possible value that maintains good quality results. Low values might introduce some inaccuracy in the reflection and diffraction paths. Some examples of inaccuracy: reflections might not be perfectly specular, some paths might be discovered with some delay, some invalid paths might be removed later than expected.
  • 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 5 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.
Spatial Audio - Path Validation CPU is high and there is only one emitter
  • Disable diffraction or reflection on diffraction if not needed: computing diffraction is CPU intensive. Instead of completely disabling diffraction, reduce the number of diffraction edges in the scene if possible.
Spatial Audio - Path Validation CPU is high and there are multiple emitters
  • Enable load balancing: start with a value lower than 10 and adjust if necessary. Values lower than 10 should not noticeably affect quality.
Spatial Audio - CPU is high (path validation and ray tracing are both involved) and there is only one emitter
  • Enable load balancing: use a value of 2. It will spread the computation of ray tracing and path validation on different frames and thus reduce the peaks. Higher values won't help much.
  • Increase the motion threshold: in this case, it reduces average CPU consumption more than it reduces the peaks.

이 페이지가 도움이 되었나요?

지원이 필요하신가요?

질문이 있으신가요? 문제를 겪고 계신가요? 더 많은 정보가 필요하신가요? 저희에게 문의해주시면 도와드리겠습니다!

지원 페이지를 방문해 주세요

작업하는 프로젝트에 대해 알려주세요. 언제든지 도와드릴 준비가 되어 있습니다.

프로젝트를 등록하세요. 아무런 조건이나 의무 사항 없이 빠른 시작을 도와드리겠습니다.

Wwise를 시작해 보세요