本教程将展示如何结合 Spatial Audio 使用 Room 和 Portal。以下章节会详细讲解相关步骤:
A. Wwise Project(工程)
对于本教程,为了在发声体被障碍物阻挡时通过 Portal 传播衍射声音,我们需要添加 Reverb Effect,并修改 Obstruction 曲线。
- 在 Master Audio Bus 下添加两个 Auxiliary Bus:SmallRoom 和 LargeRoom。在 Auxiliary Bus Property Editor 中:
- 在 Effects 选项卡中,添加 Wwise RoomVerb 效果器。分别为 SmallRoom 和 LargeRoom 选择不同的出厂预设:Rooms/Room_Medium 和 Cathedrals/Medium。
Auxiliary Bus Property Editor Effects tab for rooms
- 在 Positioning 选项卡中,选中 Listener Relative Routing,并将 3D Spatialization 设为 Position + Orientation。通过在此 Auxiliary Bus 上添加衰减,可自定义声音穿过 Portal 时的衰减效果。
在 Auxiliary Bus Property Editor 的 Positioning 选项卡中设置 Wwise RoomVerb
- Project > Project Settings > Obstruction/Occlusion
- 根据需要调节 Obstruction Volume 和 Obstruction LPF 曲线。比如,我们在 Wwise Unity Demo Scene 工程中使用了如下曲线:
曲线 |
点 1 |
点 2 |
X |
Y |
X |
Y |
Obstruction Volume |
0 |
0 |
100 |
-3 |
Obstruction LPF |
0 |
0 |
100 |
60 |
- Obstruction Volume 曲线如下图所示:
Wwise Project Settings 中的 Obstruction/Occlusion 曲线
- 保存工程。
B. Spatial Audio Emitter
为了使用新创建的 Reflect 辅助总线,我们需要修改 Spatial Audio Emitter。
- 在 Wwise Picker 中刷新 Wwise 工程:Windows > Wwise Picker
- 生成 SoundBank
Wwise Picker
- 修改每个按钮的 AkSpatialAudioEmitter 组件。
- 将 Room Reverb Aux Bus Gain 参数设为 1。
- 在 Debug Draw 下选中 Draw Diffraction Paths。
在 AkSpatialAudioEmitter 组件中设置 Room 和 Portal
- 我们将在下面章节使用房间,所以需要将 Rigidbody 组件添加到发声体(如 AkGameObj 组件中警告消息所述)。
- 请单击 Add Rigidbody。
AkGameObj 组件
C. Room
我们需要指定 Room 在场景中的位置。为此,我们将使用 AkRoom 组件。
- 在 Wwise Unity Demo Scene 的教程场景中,我们添加了 Cube Mesh 来代表建筑中每个 Room 的内侧。假如您刚完成 Surface Reflector 教程 ,可使用带有 AkSurfaceReflector 组件的 GameObject。
- 添加 Cube (GameObject > 3D Object > Cube)
- 移除 Mesh Renderer 组件。
- 在 Box Collider 组件中选中 Is Trigger。
- 添加 AkRoom 组件。
- 为 Reverb Aux Bus 选取相应的 SmallRoom 或 LargeRoom Auxiliary Bus。
- 若已将 Rigidbody 添加到发声体,则此处无需再行添加。若尚未添加,请单击 Add Rigidbody。
AkRoom 组件
- 启动游戏,然后连接 Wwise,并转到 Game Object Profiler 布局(快捷键 F12)。
- 在 Game Object 3D Viewer 中,应会看到对应 Room 中的每个听者。下图为场景的俯视视图。听者和 Button Outside 不在房间内,因此被默认放在了 Outdoors 房间。
Emitters in their respective rooms and the Listener Outdoors
- 将听者移动到某个 Room,并在 Game Object 3D Viewer 中的“听者”游戏对象下查看 Room 名称变化。在下图中,听者处在 Large Room 内。
Emitters in their respective rooms and the Listener in the Large Room Interior
- 按下其中一个房间中的按钮,来试听混响效果。
- 在 Small Room 中,Voices Graph 应如下图所示:
Voices Graph 中显示 Button Small Room 应用有 Wwise RoomVerb 效果器
- 在听者与发声体在不同房间内时,声音会被完全遮蔽。为了通过所需开口传播来自房间的声音,我们需要添加门户。
info |
备注: |
若要在房间外部添加混响效果器,则可围绕整个区域添加一个 Room。确保 Room 的优先级低于场景中的其他 AkRoom 组件。 |
D. Portals(门户)
每个 Room 都需要通过 Portal 与其他区域连通。在 Wwise Unity Demo Scene 中,我们需要两个 Portal:一个设在外部区域和 Small Room 之间的开口上,另一个设在两个 Room 之间。
- 创建两个 AkRoomPortal 组件 (GameObject > Wwise > Room Portal),并将其放在开口附近。
- 在 Scene 窗口中,Portal 周围显示有黄色条带(用来指示门户大小)及其所应设置的朝向。红色线条用来划分 Portal 的前后区域。其中,局部 Z 轴所指方向为前部。
在 Scene 窗口中创建 AkRoomPortal 组件
- 在 AkRoomPortal 组件中:
- 将 Open On 设为 Start。
- 将 Close On 设为 Nothing。
- 确保 Back Room 和 Front Room 显示正确的 AkRoom 组件。
- Small Room 和外部区域之间的 Portal 的 AkRoomPortal 组件应如下图所示:
AkRoomPortal 组件
- 启动游戏。
- 在 Scene 窗口中,应可看到一条代表声音穿过 Portal 的路径(显示为绿色)。衍射点处会显示应用于声音的衍射百分比。
衍射路径穿过 Portal – 俯视图
- 连接 Wwise 并转到 Game Object Profiler 布局(快捷键 F12)
- 确保在 Game Object 3D Viewer Settings 中启用 Diffraction Paths(如尚未启用)。
在 Game Object 3D Viewer Settings 中为 Portal 启用 Diffraction Paths
- 在 Game Object 3D Viewer 中,应会看到来自不同发声体的衍射路径穿过 Portal 到达听者所在位置。注意图中以绿色虚像标识的虚声源,其代表声音的实际听感位置。
Game Object 3D Viewer 中显示穿过 Portal 的衍射路径
- 移动位置,使隔壁 Room 内正在播放的发声体处于视线内和视线外,从而试听声音的衍射效果。在听者相对于门户的角度不同时,您会听到或多或少的衍射声音。
info |
备注: |
此时,若更改 Room 的位置或对 Portal 进行多项编辑,则只有分别打开各个 AkRoomPortal 检视器,才能更新 Portal 前后的 Room。在场景中包含大量门户时,这样会很不方便。为此,可使用本教程中作为示例添加的 Portal Baker 窗口。您可以从 Wwise > AkRoomPortal Baker... 菜单打开该窗口。然后,单击 Bake 按钮来更新场景中所有门户的前后房间。 |
E. Portals(门户)和 Reverb(混响)
通过 Portal 传播的声音还可使用来自听者所在 Room 的混响效果器。
- 打开 SmallRoom Auxiliary Bus Property Editor,并在 General Settings 选项卡中选中 Use game-defined auxiliary sends。这样可以将小房间的混响效果发送到场景中的其他混响中去。
Auxiliary Bus Property Editor General Settings tab to send room reverb to other reverbs
- 假如在播放小房间发声体时走进大房间,将会看到小房间的混响效果被馈送到了大房间的混响效果中来。
Voices Graph 中显示将 Small Room 混响效果器发送到了 Large Room 混响效果器