OpenXROpenXR

OpenXR logo

OpenXR 是 Khronos的開放免權利 API 標準,提供可在 混合現實範圍內原生存取各種裝置的引擎。OpenXR is an open royalty-free API standard from Khronos, providing engines with native access to a range of devices across the mixed reality spectrum.

您可以在 HoloLens 2 上使用 OpenXR 或在電腦上使用 Windows Mixed Reality 沉浸式頭戴裝置進行開發。You can develop using OpenXR on a HoloLens 2 or Windows Mixed Reality immersive headset on the desktop. 如果您沒有耳機的存取權,您可以改用 HoloLens 2 模擬器或 Windows Mixed Reality 模擬器。If you don't have access to a headset, you can use the HoloLens 2 Emulator or the Windows Mixed Reality Simulator instead.

為什麼要 OpenXR?Why OpenXR?

有了 OpenXR,您就可以建立以這兩種全像攝影裝置為目標的引擎,例如 HoloLens 2 和沉浸式裝置,例如桌上型電腦的 Windows Mixed Reality 耳機。With OpenXR, you can build engines that target both holographic devices, like HoloLens 2, and immersive devices, like Windows Mixed Reality headsets for desktop PCs. OpenXR 可讓您撰寫程式碼一次,然後在各種不同的硬體平臺上進行移植。OpenXR lets you write code once that's then portable across a wide range of hardware platforms.

OpenXR API 會使用載入器,將您的應用程式直接連接到耳機的原生平臺支援。The OpenXR API uses a loader to connect your application directly to your headset's native platform support. 使用者可以取得最大效能和最小延遲,不論它們是使用 Windows Mixed Reality 還是任何其他耳機。End users get maximum performance and minimum latency, whether they're using a Windows Mixed Reality or any other headset.

什麼是 OpenXR?What is OpenXR?

OpenXR API 提供核心的預測、框架時間和空間輸入功能,您必須建立可將全像全像全像全像裝置的引擎。The OpenXR API provides the core pose prediction, frame timing, and spatial input functionality you'll need to build an engine that can target both holographic and immersive devices.

若要瞭解 OpenXR API,請參閱 OpenXR 1.0 規格API 參考快速參考指南To learn about the OpenXR API, check out the OpenXR 1.0 specification, API reference, and quick reference guide. 如需詳細資訊,請參閱 Khronos OpenXR 頁面For more information, see the Khronos OpenXR page.

若要以 HoloLens 2 的完整功能集為目標,您也會使用跨廠商和供應商專屬的 OpenXR 延伸模組,以啟用 OpenXR 1.0 核心以外的其他功能,例如明確的手追蹤、眼睛追蹤、空間對應和空間錨點。To target the full feature set of HoloLens 2, you'll also use cross-vendor and vendor-specific OpenXR extensions that enable additional features beyond the OpenXR 1.0 core, such as articulated hand tracking, eye tracking, spatial mapping, and spatial anchors. 如需詳細資訊,請參閱下面的「 藍圖」一節 ,以瞭解今年稍後推出的延伸模組。For more information, see the Roadmap section below on the extensions coming later this year.

OpenXR 本身不是混合的現實引擎。OpenXR isn't itself a mixed reality engine. 相反地,OpenXR 能讓 Unity 和 Unreal 等引擎撰寫可移植的程式碼一次,之後就可以存取使用者全像或沉浸式裝置的原生平臺功能。Instead, OpenXR enables engines like Unity and Unreal to write portable code once that can then access the native platform features of the user's holographic or immersive device, whatever vendor built that platform.

藍圖Roadmap

OpenXR 規格定義了延伸機制,可讓執行時間實作者在基底 OpenXR 1.0 規格中定義的核心功能之外公開其他功能。The OpenXR specification defines an extension mechanism that enables runtime implementers to expose additional functionality beyond the core features defined in the base OpenXR 1.0 specification.

有三種類型的 OpenXR 延伸模組:There are three kinds of OpenXR extensions:

  • 廠商擴充 (例如, MSFT) : 可在硬體或軟體功能中提供每一廠商的創新。Vendor extensions (for example, MSFT): Enables per-vendor innovation in hardware or software features. 任何執行時間廠商都可以隨時引進並交付廠商延伸模組。Any runtime vendor can introduce and ship a vendor extension at any time.
    • 實驗性廠商延伸 (例如 MSFT_preview) : 要預覽的實驗性廠商延伸模組,以收集意見反應。Experimental vendor extensions (for example, MSFT_preview): Experimental vendor extensions being previewed to gather feedback. MSFT_preview 擴充功能僅適用于開發人員裝置,並會在真正的延伸模組發行時移除。MSFT_preview extensions are for developer devices only and will be removed when the real extension ships. 若要進行實驗,您可以 在開發人員裝置上啟用預覽延伸模組。To experiment with them, you can enable preview extensions on your developer device.
  • 跨廠商 EXT 延伸模組: 多個公司所定義和實行的跨廠商擴充功能。Cross-vendor EXT extensions: Cross-vendor extensions that multiple companies define and implement. 有興趣的公司群組隨時都可以引進 EXT 延伸模組。Groups of interested companies can introduce EXT extensions at any time.
  • 官方 KHR 延伸模組: 正式 Khronos 延伸模組會在核心規格版本中核准。Official KHR extensions: Official Khronos extensions ratified as part of a core spec release. KHR 延伸模組是與核心規格本身相同的授權所涵蓋。KHR extensions are covered by the same license as the core spec itself.

從2020年7月起,Windows Mixed Reality OpenXR 執行時間支援一組和延伸模組,可 MSFT EXT 為 OpenXR 應用程式帶來一組完整的 HoloLens 2 功能:As of July 2020, the Windows Mixed Reality OpenXR Runtime supports a set of MSFT and EXT extensions that brings the full set of HoloLens 2 features to OpenXR applications:

功能區域Feature area 延伸模組可用性Extension availability
系統 + 會話Systems + sessions OpenXR 1.0 核心規格:OpenXR 1.0 core spec:
XrInstance, XrSystemId, XrSessionXrInstance, XrSystemId, XrSession
參考空間 (view、local、stage) Reference spaces (view, local, stage) OpenXR 1.0 核心規格:OpenXR 1.0 core spec:
XrSpace
(mono、身歷聲) 視圖設定View configurations (mono, stereo) OpenXR 1.0 核心規格:OpenXR 1.0 core spec:
XrView...
Swapchains + 畫面格時間Swapchains + frame timing OpenXR 1.0 核心規格:OpenXR 1.0 core spec:
XrSwapchain... + xrWaitFrame
組合圖層Composition layers
(投射,四) (projection, quad)
OpenXR 1.0 核心規格:OpenXR 1.0 core spec:
XrCompositionLayer... + xrEndFrame
輸入和 hapticsInput and haptics OpenXR 1.0 核心規格:OpenXR 1.0 core spec:
XrAction...
Direct3D 11 整合Direct3D 11 integration 正式 KHR 擴充功能已發行:Official KHR extension released:
XR_KHR_D3D11_enable
Direct3D 12 整合Direct3D 12 integration 正式 KHR 擴充功能已發行:Official KHR extension released:
XR_KHR_D3D12_enable
無限制的參考空間
(世界規模的體驗)
Unbounded reference space
(world-scale experiences)
MSFT 發行的延伸模組:MSFT extension released:
XR_MSFT_unbounded_reference_space
空間錨點Spatial anchors MSFT 發行的延伸模組:MSFT extension released:
XR_MSFT_spatial_anchor

上互動 (把手/目標姿勢、碰點、抓住)
Hand interaction
(grip/aim pose, air-tap, grasp)

僅 HoloLens 2HoloLens 2 only

MSFT 發行的延伸模組:MSFT extension released:
XR_MSFT_hand_interaction
手錶達 + 手形網格Hand articulation + hand mesh

僅 HoloLens 2HoloLens 2 only

EXT 執行時間102中發行的延伸模組:EXT extension released in runtime 102:
XR_EXT_hand_tracking

MSFT 執行時間102中發行的延伸模組:MSFT extension released in runtime 102:
XR_MSFT_hand_tracking_mesh
眼睛目光Eye gaze

僅 HoloLens 2HoloLens 2 only

EXT 發行的延伸模組:EXT extension released:
XR_EXT_eye_gaze_interaction
與其他 HoloLens Sdk InteropInterop with other HoloLens SDKs
(例如, QR) (for example, QR)

僅 HoloLens 2HoloLens 2 only

MSFT 執行時間102中發行的延伸模組:MSFT extension released in runtime 102:
XR_MSFT_spatial_graph_bridge

MSFT預覽執行時間 104中的延伸模組:MSFT extension in preview runtime 104:
XR_MSFT_perception_anchor_interop_preview

混合實境擷取
(PV 攝影機的第三個轉譯)
Mixed Reality Capture
(third render from PV camera)

僅 HoloLens 2HoloLens 2 only

MSFT 執行時間102中發行的延伸模組:MSFT extensions released in runtime 102:
XR_MSFT_secondary_view_configuration
XR_MSFT_first_person_observer
使用 UWP CoreWindow API 進行 InteropInterop with UWP CoreWindow API
例如鍵盤/滑鼠) 的 ((for example, for keyboard/mouse)
MSFT 執行時間103中發行的延伸模組:MSFT extension released in runtime 103:
XR_MSFT_holographic_window_attachment
移動控制器互動設定檔 (Samsung 電影對白和 HP 迴響 G2) Motion controller interaction profiles (Samsung Odyssey and HP Reverb G2) MSFT 執行時間103中發行的延伸模組:MSFT extensions released in runtime 103:
XR_EXT_samsung_odyssey_controller
XR_EXT_hp_mixed_reality_controller
移動控制器轉譯模型Motion controller render models MSFT預覽執行時間 104中的延伸模組:MSFT extension in preview runtime 104:
XR_MSFT_controller_model
場景理解 (平面、網格) Scene understanding (planes, meshes)

僅 HoloLens 2HoloLens 2 only

預覽執行時間102或更新版本中:In preview runtime 102 or later:
搭配 XR_MSFT_spatial_graph_bridge 場景理解 SDK使用Use XR_MSFT_spatial_graph_bridge with Scene Understanding SDK

MSFT_preview 未來預覽執行時間中的延伸 模組 (計畫的)MSFT_preview extension in future preview runtime (planned)

其他跨廠商擴充功能Other cross-vendor extensions

正式 KHR 推出的延伸模組:Official KHR extensions released:

XR_KHR_composition_layer_depth
XR_KHR_visibility_mask
XR_KHR_win32_convert_performance_counter_time

EXT 發行的延伸模組:EXT extensions released:

XR_EXT_win32_appcontainer_compatible
XR_EXT_debug_utils

雖然其中有些擴充功能可能會隨著廠商專屬的延伸模組而開始 MSFT ,但 Microsoft 和其他 OpenXR 執行時間廠商會共同合作, EXTKHR 許多這些功能領域設計跨廠商或延伸模組。While some of these extensions may start out as vendor-specific MSFT extensions, Microsoft and other OpenXR runtime vendors are working together to design cross-vendor EXT or KHR extensions for many of these feature areas. 跨廠商擴充功能可讓您撰寫的程式碼在執行時間廠商之間可移植,如同核心規格。Cross-vendor extensions will make the code you write for those features portable across runtime vendors, as with the core specification.

開始使用 OpenXRGetting started with OpenXR

使用者佩戴混合現實耳機時所播放 minecraft 的螢幕擷取畫面

Minecraft 的新 RenderDragon 引擎正在使用 OpenXR 建立其桌上型電腦 VR 支援Minecraft's new RenderDragon engine is building its desktop VR support using OpenXR

Microsoft 一直在使用 Unity 和複雜的遊戲,以確保混合現實的未來已開放使用,而不只是為了 HoloLens 2,還能橫跨電腦 VR 的完整廣度,包括 HP 的新的「回音」 G2 耳機Microsoft has been working with Unity and Epic Games to ensure the future of mixed reality is open, not just for HoloLens 2, but across the full breadth of PC VR, including HP’s new Reverb G2 headset. 如需有關開發 HoloLens (第一代) 的詳細資訊,請參閱 版本資訊。For more information on developing for HoloLens (1st gen), see the release notes.

若要瞭解如何在 Unity、Unreal Engine 或您自己的引擎中開始使用 OpenXR,請繼續閱讀!To learn how you can get started with OpenXR in Unity, Unreal Engine or your own engine, read on!

Unity 中的 OpenXROpenXR in Unity

現今 HoloLens 2、HoloLens (第一代) 和 Windows Mixed Reality 耳機的支援 Unity 開發路徑,是現有的 WinRT API 後端的 unity 2019 LTSToday, the supported Unity development path for HoloLens 2, HoloLens (1st gen), and Windows Mixed Reality headsets is Unity 2019 LTS with the existing WinRT API backend. 您可以 使用 Unity跳到 OpenXR;如果您將目標設為 Unity 2019 應用程式中的新 HP 回音 G2 控制器,請參閱我們的 Hp 的「 回音」輸入檔。You can jump into OpenXR with Unity; If you’re targeting the new HP Reverb G2 controller in a Unity 2019 app, see our HP Reverb G2 input docs.

unity 2020 LTS 開始, unity 將會寄送 OpenXR 後端 ,以支援 HoloLens 2 和 Windows Mixed Reality 耳機。Starting with Unity 2020 LTS, Unity will ship an OpenXR backend that supports HoloLens 2 and Windows Mixed Reality headsets. 這包括對 OpenXR 延伸模組的支援,這些擴充 功能可讓 HoloLens 2 和 Windows Mixed Reality 耳機的完整功能,包括手上/眼睛追蹤、空間錨點和 HP 等號 G2 控制器。This includes support for the OpenXR extensions that light up the full capabilities of HoloLens 2 and Windows Mixed Reality headsets, including hand/eye tracking, spatial anchors and HP Reverb G2 controllers. MRTK-Unity 對 OpenXR 的支援目前正在 mrtk_development 分支 中進行開發,並可與該 OpenXR 預覽套件一起使用。MRTK-Unity support for OpenXR is currently under development in the mrtk_development branch and will be available alongside that OpenXR preview package.

Unity 2021 開始,OpenXR 接著會畢業為目標 HoloLens 2 和 Windows Mixed Reality 耳機的唯一支援 Unity 後端。Starting in Unity 2021, OpenXR will then graduate to be the only supported Unity backend for targeting HoloLens 2 and Windows Mixed Reality headsets.

Unreal 引擎中的 OpenXROpenXR in Unreal Engine

Unreal 引擎 4.23,HoloLens 2 和 Windows Mixed Reality 耳機的完整支援可透過 Windows Mixed Reality (WinRT) 外掛程式取得。As of Unreal Engine 4.23, full support for HoloLens 2 and Windows Mixed Reality headsets are available through the Windows Mixed Reality (WinRT) plugin.

Unreal Engine 4.23 也是第一個提供 OpenXR 1.0 預覽支援的主要遊戲引擎版本!Unreal Engine 4.23 was also the first major game engine release to ship preview support for OpenXR 1.0! 現在在 Unreal 引擎 4.26 中,HoloLens 2、Windows Mixed Reality 和其他 desktop VR 耳機的支援可透過 Unreal 引擎的內建 OpenXR 外掛程式來取得。Now in Unreal Engine 4.26, support for HoloLens 2, Windows Mixed Reality and other desktop VR headsets will be available through Unreal Engine’s built-in OpenXR plugin. Unreal Engine 4.26 也會隨附其第一組 OpenXR 延伸模組外掛程式,讓您能夠進行手互動和 HP-UX 的 G2 控制器支援、 HoloLens 2 的完整功能集,以及 Windows Mixed Reality 耳機Unreal Engine 4.26 will also ship with its first set of OpenXR extension plugins enabling hand interaction and HP Reverb G2 controller support, lighting up the full feature set of HoloLens 2 and Windows Mixed Reality headsets. Unreal Engine 4.26 目前可在 長篇的遊戲啟動器上預覽,並在今年稍後推出正式發行版本。Unreal Engine 4.26 is available in preview today on the Epic Games Launcher, with the official release coming later this year. OpenXR 的 MRTK-Unreal 支援也會在該版本中提供。MRTK-Unreal support for OpenXR will be available alongside that release as well.

適用于原生開發的 OpenXROpenXR for native development

您可以在 HoloLens 2 上使用 OpenXR 或在電腦上使用 Windows Mixed Reality 沉浸式頭戴裝置進行開發。You can develop using OpenXR on a HoloLens 2 or Windows Mixed Reality immersive headset on the desktop. 如果您沒有耳機的存取權,您可以改用 HoloLens 2 模擬器或 Windows Mixed Reality 模擬器。If you don't have access to a headset, you can use the HoloLens 2 Emulator or the Windows Mixed Reality Simulator instead.

若要開始開發 HoloLens 2 或沉浸式 Windows Mixed Reality 耳機的 OpenXR 應用程式,請參閱 如何開始使用 OpenXR 開發To start developing OpenXR applications for HoloLens 2 or immersive Windows Mixed Reality headsets, see how to get started with OpenXR development.

如需 OpenXR API 的所有主要元件的教學課程,以及目前使用 OpenXR 的真實世界應用程式範例,請參閱此60分鐘逐步解說影片:For a tour through all the major components of the OpenXR API, along with examples of the real-world applications using OpenXR today, check out this 60-minute walkthrough video:

另請參閱See also