AR/VR 입문서¶
이 튜토리얼은 Godot 게임 엔진에서 AR과 VR의 세계로 가도록 도와주는 발판이 될 것입니다.
Godot 3부터 AR/VR Server라고 하는 새로운 아키텍처가 도입됬습니다. 이 아키텍처를 기반으로 하여, 특정 구현을 인터페이스로 이용할 수 있게 되었습니다. 대부분은 GDNative로 만들어진 플러그인입니다. 이 튜토리얼은 순수히 핵심 아키텍처에 의해 추상화된 핵심 요소에 초점을 둘 것입니다. 이 아키텍처는 다양한 인터페이스로 배포되면서 모든 VR 경험을 만들기에 충분한 기능을 갖고 있습니다. 하지만 각 플랫폼은 추상화하기에 불가능한 독특한 기능을 갖고 있습니다. 그런 기능은 입문서의 영역을 벗어나는 것이므로 관련 인터페이스에서 서술하겠습니다.
AR/VR 서버¶
Godot를 실행하면, 사용 가능한 각 인터페이스는 AR/VR 서버에 알려집니다. GDNative 인터페이스는 싱글톤으로 설정됩니다; 인터페이스가 프로젝트의 GDNative 싱글톤 목록에 추가되는 만큼, 서버로 알려질 것입니다.
이용 가능한 인터페이스 목록을 반환하기 위해선 함수 get_interfaces()를 사용할 수 있습니다, 하지만 이 튜토리얼에서, 예제를 위해 네이티브 모바일 VR 인터페이스를 사용하겠습니다. 이 인터페이스는 폰에서 3DOF를 사용해 입체 이미지를 화면에 출력하도록 하는 간단한 구현입니다. 또한 Godot 코어로 데스크톱에서 화면을 출력할 수 있으므로, 프로토타입을 만들거나 이것과 같은 튜토리얼을 하기에 이상적입니다.
인터페이스를 활성화하기 위해, 다음 코드를 실행합니다:
var arvr_interface = ARVRServer.find_interface("Native mobile")
if arvr_interface and arvr_interface.initialize():
get_viewport().arvr = true
var arvrInterface = ARVRServer.FindInterface("Native mobile");
if (arvrInterface != null && arvrInterface.Initialize())
{
GetViewport().Arvr = true;
}
이 코드는 우리가 사용하고자 하는 인터페이스를 찾아 초기화합니다, 그리고 완료되면 메인 뷰포트를 인터페이스에 제한합니다. 마지막 단계에서는 뷰포트에서 인터페이스를 제어하여 뷰포트에 입체 렌더링과 같은 것을 자동으로 활성화하도록 할 것입니다.
For our mobile VR interface, and any interface where the main input is directly displayed on
screen, the main viewport needs to be the viewport where arvr
is set to true
. But for interfaces that render on an externally attached device, you can use
a secondary viewport. In the latter case, a viewport that shows its output on screen will show an
undistorted version of the left eye, while showing the fully processed stereoscopic output on the
device.
Finally, you should only initialize an interface once; switching scenes and reinitializing interfaces
will just introduce a lot of overhead. If you want to turn the headset off temporarily, just disable
the viewport or set arvr to false
on the viewport. In most
scenarios though, you wouldn't disable the headset once you're in VR, this can be disconcerting to
the gamer.
새로운 AR/VR 노드¶
Godot에서 AR과 VR을 지원하기 위해 세가지 새로운 노드 타입이 추가되었고 AR만을 위한 추가적인 노드 타입 한 가지가 추가되었습니다. 다음과 같습니다:
ARVROrigin - 월드에서 원점
ARVRCamera - 위치 추적이 가능한 카메라의 특수 하위 클래스
ARVRController - 컨트롤러의 위치를 추적하는 새로운 Spatial 클래스
ARVRAnchor - 실제 세상 위치를 가상 세계에 매핑하는 AR 구현을 위한 기준점
AR/VR을 위해선 앞의 두 개가 씬에 있어야 하고 이 튜토리얼 역시 이 둘에 초점을 두고 있습니다.
ARVROrigin은 중요한 노드로, 씬 어딘가에 반드시 있어야 합니다. 이 노드는 실제 세상의 중심을 가상 세상의 한 위치에 매핑합니다. 다른 모든 것들은 이 점으로 위치를 추적합니다. 이 점이 하나의 구현에서 다른 구현으로는 다르지만, 이 노드가 작동하는 방식을 이해하기 위한 최선의 예는 방 규모 장소를 살펴보는 것입니다. 기본적으로 플레이어를 중심으로 점이 조정되지만, 원점은 당신이 있는 방의 중심에 있게 됩니다. 물리적으로 방을 돌어다니면 HMD의 위치는 중심점에 따라 추적하고 이는 가상 세계에 반영됩니다.
간단한 예로 물리적으로 방을 돌아다닐 때, ARVR 원점은 한 자리에 있고, 카메라와 컨트롤러의 위치는 움직임에 따라 조정되는 것입니다. 가상 세상을 통해 움직이거나 컨트롤러 조작을 통한 순간이동을 구현할 때, 그 위치에 원점을 조정해야할 것입니다.
ARVRCamera는 씬에 반드시 있어야 되는 두 번째 노드로, 항상 Origin 노드의 자손으로 있어야 합니다. Godot의 표준 카메라의 하위 클래스입니다. 하지만, 위치는 매 프레임마다 HMD의 위치와 물리적 방위에 따라 자동으로 업데이트됩니다. 그리고 HMD나 실제 카메라를 통한 AR 오버레이를 렌더링하기 위한 정밀도 때문에, 대부분의 표준 카메라 속성은 무시됩니다. 사용되는 카메라의 유일한 속성은 근거리 및 원거리 평면 설정입니다. FOV, 종횡비 그리고 투영 모드 모두 무시됩니다.
주의하세요, 우리 고유의 모바일 VR 구현을 위해, 위치 추적 없이 스마트폰의 방위만 확장되어, HMD를 추적합니다. 이 구현에서 인위적으로 카메라를 1.85의 높이 (Y)에 둡니다.
결론: 씬에서 AR이나 VR 작업을 위한 최소 설정은 다음과 같아야 합니다:

And that's all you need to get started with the native mobile interface. Obviously, you need to add something more into your scene, so there is something to see, but after that, you can export the game to your phone of choice, pop it into a viewer and away you go.
Official plugins and resources¶
As mentioned earlier, Godot does not support the various VR and AR SDKs out of the box, you need a plugin for the specific SDK you want to use. There are several official plugins available in the GodotVR Repository.
Godot OpenXR: This is the official XR plugin starting with Godot 3.4. It supports OpenXR, an open standard for designing and building cross-platform VR and AR software. Tested with SteamVR, Monada and Oculus OpenXR (desktop and mobile) runtimes.
See OpenXR plugin.
Godot Oculus Mobile provides support for the Meta Quest.
Note: This plugin has been deprecated starting with Godot 3.4. We recommend migrating to the Godot OpenXR plugin instead.
Godot OpenVR (not to be confused with OpenXR) supports the OpenVR SDK used by Steam.
Godot Oculus supports the Oculus SDK (desktop headsets only).
Note: This plugin has been deprecated starting with Godot 3.4. We recommend migrating to the Godot OpenXR plugin instead.
Godot OpenHMD supports OpenHMD, an open source API and drivers for headsets.
These plugins can be downloaded from GitHub or the Godot Asset Library.
In addition to the plugins, there are several official demos.
Godot OpenVR FPS (the tutorial for this project is VR starter tutorial part 1).
Godot XR tools, which shows implementations for VR features such as movement and picking up objects.
고려해야 할 다른 사항¶
이 입문서도 알아두면 좋지만, 이를 넘어 간략하게 볼 몇 가지 사항이 있습니다.
The first are our units. In normal 3D games, you don't have to think a lot about units. As long as everything is at the same scale, a box sized 1 unit by 1 unit by 1 unit can be any size from a cub you can hold in your hand to something the size of a building. In AR and VR, this changes because things in your virtual world are mapped to things in the real world. If you step 1 meter forward in the real world, but you only move 1 cm forward in your virtual world, you have a problem. The same with the position of your controllers; if they don't appear in the right relative space, it breaks the immersion for the player. Most VR platforms, including our AR/VR Server, assume that 1 unit = 1 meter. The AR/VR server, however, has a property that, for convenience, is also exposed on the ARVROrigin node called world scale. For instance, setting this to a value of 10 changes our coordinate system so 10 units = 1 meter.
Performance is another thing that needs to be carefully considered. Especially VR taxes your game a lot more than most people realize. For mobile VR, you have to be extra careful here, but even for desktop games, there are three factors that make life extra difficult:
스테레오스코픽을 렌더링합니다, 하나 짜리를 두 개로 렌더링 하는 거죠. 새로운 MultiView OpenGL 확장을 지원하는 것을 염두에 두기에, 작업 부하를 두 배로 늘리거나 파이프라인에있는 작업을 두 배로 늘리지는 않더라도, 두 눈을 위한 렌더링 이미지로 추가 작업 부하가 있습니다
일반 게임은 30fps에서 정상적으로 실행되며 이상적으로는 60fps로 관리합니다. 이는 저사양과 고사양 하드웨어를 사이에서 플레이하는데 큰 격차를 줄 수 있습니다. 하지만 AR이나 VR의 HMD 애플리케이션은, 60fps가 절대적인 최솟값이므로 반드시 게임이 안정적인 90fps로 실행되어 사용자가 즉시 멀미를 느끼지 않도록 해야 합니다.
높은 FOV와 관련 렌즈 왜곡 효과는 화질을 두 배로 렌더하기 위해 많은 VR 경험이 필요합니다. 네 VIVE는 각 눈마다 1080x1200의 화질을 갖고 있지만, 우리는 각 눈에 2160x2400의 결과로 렌더링합니다. 이는 대부분의 AR 애플리케이션에서 문제가 되지 않습니다.
전체적으로, 일반 3D 게임과 비교하여 GPU의 작업량은 상당히 높습니다. 작업이 파이프라인에 있는 동안, MultiView와 foveated 렌더링과 같은 것을 개선하기 위해, 이들은 모든 장치에서 지원하잔 않습니다. 이런 이유로 더 많은 아트 스타일을 사용하는 많은 VR 게임을 보게되며, 현실감을 추구하는 VR 게임에 깊게 보다보면, 아마 효과에 대해 조금 더 전통적이거나 좋은 오래된 눈속임을 사용한다는 것을 알 수 있습니다.