バージョン

menu_open
Wwise SDK 2024.1.0
レイトレイシングエンジンのジオメトリガイド

はじめに

レイトレイシングは、n次のリフレクション(反射)やディフラクション(回折)を効率的に評価するテクニックです。リスナーからランダムにキャストされたレイ(ray)を追って、リフレクションやディフラクションを続けて受けたときのパスを、確認するというのが基本的な考え方です。この技術の発想は、グラフィックレンダリング技術からきています。Maximum Reflection order [1-4] and diffraction order [1-8] values are defined in the AkSpatialAudioInitSettings structure of AkSpatialAudio.h. 詳細は AkSpatialAudioInitSettings を参照してください。

概念

  • Primary rays: リスナーから直接キャストされたレイ
  • Reflection: サウンドの、面からの跳ね返り
  • Diffraction: サウンドの、物体周りの回折
  • Paths: リスナーからエミッタまでの、一連のリフレクションまたはディフラクション

設定

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. CPU Limit Modeを有効にすれば、Primary rayの数はレイトレイシングエンジンで自動調整され、CPU使用量はユーザーが事前に定義した目標値付近で維持されます。このモードを使うと、CPU使用量の急上昇は抑えられますが、単発で急なピークを完全に排除することはできません。 目標値を高く設定すると、品質(リフレクションパスやディフラクションパスの認知数)は上がりますが、パフォーマンスは下がってしまいます。一方、目標値を低く設定すると、パフォーマンスは向上しますが品質が犠牲になります。 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. ただし、すでにある音の伝播パスは、引き続き検証され更新されます。その結果、レイトレイシングエンジンによる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.

Path Sorting

Reflection path validation can become expensive when the total number of rays and/or emitters is high. However, in most cases, a few reflection paths are relevant to the perception of early reflections. Path sorting is an experimental feature that attempts to validate a user-specified number of reflection paths (see AkSpatialAudioInitSettings()). Path sorting can significantly reduce the CPU load.

Path Sorting Overview

In the first phase, path sorting estimates the cost (length and diffraction) of each potential reflection path based on the results of the raytracing. The paths are then processed in ascending order until a maximum of n (the user-specified number of reflection paths) paths are validated. To reduce flickering (switching between paths), the previous paths are also validated. In the second phase, the best n paths are selected from the current and previous validated paths based on their final real costs.

Path Sorting Overview


Path Sorting Limitations

The selection of the n best reflection paths is global to all emitters. This means that, depending on the user-specified number of paths and the number of emitters, some emitters might not have any associated reflection paths. The cost in the first phase is an estimate of the real cost, so in some cases the selected paths are not the best overall paths, and some flickering might still occur.

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.

制限

レイトレイシングエンジンのためにジオメトリを定義する際に、考慮すべき制限事項がいくつかあります。パフォーマンスと結果の質の両方に関する制限事項です。

ジオメトリの見える角度

三角形がサンプリング密度よりも小さいと、それをレイトレイシングエンジンが見つけづらくなります。

ジオメトリの見える角度α(アルファ)とは、リスナー視点からジオメトリが見える角度のことです。Primary rayの数によって、2つのレイの間の平均的な角度 γ(ガンマ)は異なります。αとγの相対関係によって、オブジェクトとの交点(リフレクションまたはディフラクション)が見つかる確率が変わります。γがαより小さければ、交点が見つかる確率が上がります。γがαより大きければ、交点が見つかる確率が下がります。

この例ではγの方がαより小さいです。よって、オブジェクトとの交点が見つかる確率は高くなります。
この例ではαの方がγより小さいです。よって、オブジェクトとの交点が見つかる確率は低くなります。

三角形の個数

ジオメトリ内の三角形の数が、エンジンのCPU消費量と直接関係し、三角形が増えれば、それだけCPUの消費量が増えます。これは、オブジェクトに必要となる交点テストが増えるからです。一般的に音の伝播に高度なジオメトリは必要ありません。そこで三角形の数を減らせば、品質を犠牲にすることなくパフォーマンスを向上できます。

この平面は、4つの三角形から構成されているので、レイのテストを、それぞれの三角形に対して行います。

ジオメトリの形状

ジオメトリ形状は、処理しやすいものと、しにくいものがあります。一般的に、平面やボックスなどは簡単に処理でき、音の伝播の観点では一番良い結果を出します。球体や円柱は、エラーが発生しやすくなります。球体や円柱には曲面が伴うからです。場合によって、見落とされる回折エッジが出てしまい、そうすると一部の回折パスが抜けてしまいます。アルゴリズムにヒューリスティックをいくつか導入しているので、多くのケースでこの問題に対処できます。Primary rayの数を増やしたり、ジオメトリを簡略化したりすることでも、この問題を解消できます。

このような状況では、LからEへと向かう回折パスは、途中でL、E2、E3、E4、Eを通過すると予想されます。ところが、E1とE2の間の面が狭いので、回折エッジE2を出すために必要な交点が見つけづらくなっています。この場合は、E1が見つかる確率の方が高くなります。Lは、E1のシャドーゾーンに入っていないので、アルゴリズムは、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.
  • 回折(ディフレクション)や、回折の反射を、不要であれば無効にします: 回折の計算はCPUに負荷がかかります。回折をすべて無効にする代わりに、可能であればシーン内の回折エッジ数を減らします。
  • ルームやポータルを使います: あるシーンが独立した複数のセクションで構成されている場合は、ルームやポータルを利用して分離することを検討してください。
  • Increase the motion threshold: small values might validate reflection and diffraction paths too often. 質の良い結果を保てる範囲で、最も高い値に設定することを検討してください。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.
  • 可能であれば三角の数を減らします: ディテールの凝ったオブジェクトはCPU負荷が大きくなり、全体の品質を下げてしまう傾向があります。
  • Decrease the maximum number of reflection paths: validation of a high number of paths increases CPU cost. Low values might affect the overall quality.
Spatial Audio - Raytracing CPU is high
  • Decrease the number of primary rays: values as low as 5 can still produce good results.
  • CPUリミット( CPU Limit Mode )を有効にします: CPU率()を希望値に設定すれば、CPUが指定値付近で維持されるように、Primary rayの数が自動的に制御されます。なお、これはポータルのレイトレーシングに影響しません。
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. 回折をすべて無効にする代わりに、可能であればシーン内の回折エッジ数を減らします。
  • Decrease the maximum number of reflection paths: validation of a high number of paths increases CPU cost. Low values might affect the overall quality.
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.
  • Decrease the maximum number of reflection paths: validation of a high number of paths increases CPU cost. Low values might affect the overall 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.
  • Decrease the maximum number of reflection paths: validation of a high number of paths increases CPU cost. Low values might affect the overall quality.

このページはお役に立ちましたか?

サポートは必要ですか?

ご質問や問題、ご不明点はございますか?お気軽にお問い合わせください。

サポートページをご確認ください

あなたのプロジェクトについて教えてください。ご不明な点はありませんか。

プロジェクトを登録していただくことで、ご利用開始のサポートをいたします。

Wwiseからはじめよう