Table of Contents

AR 駆動の 3D rendering

AR アプリケーションの開発では、AR content の rendering という基本的な問題を解決する必要があります。この記事では planar image tracking を例に、AR アプリケーションの基本モジュール、ワークフロー、rendering 実装について説明します。

典型的な AR アプリケーションのワークフロー

典型的な AR アプリケーションは通常、camera images から特定の画像、オブジェクト、またはシーンを認識し、その position と pose を tracking し、その position と pose に従って virtual content (3D models) をレンダリングするプロセスです。

image tracking

たとえば上図は planar image tracking の AR アプリケーションです。

アプリケーションのワークフローを以下に示します。

flowchart TD
    CameraDevice[Camera Device]
    Tracker[Tracker]
    Renderer[Renderer]

    CameraDevice -->|Image Frame| Tracker
    Tracker -->|Image Frame + Tracked Pose| Renderer

このワークフローには次のモジュールがあります。

モジュール 役割
Physical camera 入力 image frames の sequence を提供します。image frame には image、image が生成された timestamp、場合によっては空間内の camera の position と pose が含まれます
Tracker image frames から tracking target の position と pose を計算します。tracking target に応じて、planar image tracker や 3D object tracker など、さまざまな trackers があります
Renderer camera image と tracked object に対応する 3D model を画面にレンダリングします。一部の AR glasses では camera image をレンダリングせず、3D model のみをレンダリングする場合もあります

スマートフォンでの rendering

スマートフォンでの rendering は、camera image の rendering と virtual objects の rendering の 2 つに分かれます。

Camera image の rendering

camera image

camera image を rendering するときは、いくつか注意すべきパラメーターがあります。

  • Scaling mode

    通常、camera image は画面全体またはウィンドウ全体を埋める必要があります。このとき、camera image と screen/window の aspect ratio が一致しない問題に対応する必要があります。

    camera image の中心を screen/window の中心に合わせ、aspect ratio を変えない場合、一般的な scaling mode には fit と fill の 2 種類があります。

    Scaling mode 効果
    Fit すべての content を画面に表示しますが、左右または上下に黒帯が残ります
    Fill 黒帯は残りませんが、左右または上下の一部の image が切り取られます
  • Camera image rotation

    スマートフォンでは、physical camera が記録する image は通常デバイス本体に対して固定されており、screen display orientation の変化に合わせて変わることはありません。ただし、スマートフォン本体の向きの変化は、image の上下左右をどのように定義するかに影響します。rendering 時には、現在の screen display orientation も表示される image の向きに影響します。

    通常、rendering 時には screen display orientation に対する camera image の rotation angle を決定する必要があります。

  • Camera image flipping

    場合によっては front-facing camera を使用します。このとき通常、鏡のように見えるよう image を左右反転する必要があります。

Virtual objects の rendering

virtual object

スマートフォンで virtual objects を rendering するには、virtual objects と camera image を合わせる必要があります。そのためには、rendering camera と objects の両方を real space に完全に対応する virtual space に配置し、physical camera と同じ field of view と aspect ratio で rendering します。camera image と virtual objects は同一の perspective projection transforms を通りますが、camera image の perspective projection transform の大部分は physical camera 内で発生し、virtual objects の perspective projection transform は完全に計算処理です。

ヘッドセットでの rendering

ヘッドセットでの rendering はスマートフォンとは異なり、2 つのケースに分ける必要があります。

  • VST

    Video See-Through は、headset が physical cameras を通じて images を取得し、headset の画面に camera images と virtual content を表示する AR 技術です。代表例は Vision Pro です。通常、camera images と virtual content の perspective projection matrices は headset が提供する SDK によって設定され、外部コードは virtual content の position と pose を設定するだけで済みます。tracking に使用される physical camera と画面に rendering される camera image の camera は異なる位置にある場合があり、rendering 時には coordinate transforms が行われます。

  • OST

    Optical See-Through は、headset の画面が透明で、headset が画面上に virtual content のみを表示する AR 技術です。代表例は HoloLens です。通常、virtual content の perspective projection matrix は headset が提供する SDK によって設定され、外部コードは virtual content の position と pose を設定するだけで済みます。tracking に使用される physical camera と画面に rendering される camera image の camera は異なる位置にある場合があり、rendering 時には coordinate transforms が行われます。

プラットフォーム専用ガイド

AR-driven 3D rendering はプラットフォームと密接に関係しています。対象プラットフォームに応じて、以下のガイドを参照して開発してください。