Dear Godot community,
I'm on Apple's visionOS engineering team, and we would like to contribute Vision Pro support to the Godot engine. This is the first PR that lays the foundation for that.
First, I'd like to mention that we're really excited to be working with the Godot community on adding visionOS support. We've attempted to follow Godot's coding standards and a high-quality bar for our contributions. We hope that our contributions align with Godot's goals. Lastly, even though we have tried to split the changes into smaller self-contained PRs, we acknowledge that some of these PRs can be of considerable size.
We're very happy to iterate on our PRs after receiving feedback and suggestions from the community.
High Level Overview
The immediate goals of our contributions are:
- To support current Godot games running natively on a planar window on visionOS.
- To support creating Immersive experiences by using a new Godot's visionOS VR Plugin.
To achieve that, and in order to make reviewing easier, we have structured our contributions in three incremental PRs.
- Add the native visionOS platform. Uses iOS as the starting point. Reuses as much code as possible between the iOS and Vision Pro platforms. (This PR).
- Add ability to compile and link Swift files within Godot, and replace main.mm on the visionOS platform by the SwiftUI app lifecycle. This is a requirement to be able to launch Immersive scenes on visionOS.
- Introduce Vision Pro VR plugin for Immersive support.
Even though we have a working version including points 2 and 3, those PRs are not up yet. Our current plan is to open them sequentially, after each of the previous PRs merge.
Technical Discussion
This PR implements a new native visionOS platform.
It's very close to the iOS platform in terms of implementation. In order to reuse as much code as possible, it introduces a new drivers/apple_embedded folder, to host code shared between the iOS and visionOS (but not macOS) platforms. We took inspiration from the new drivers/apple folder, which hosts code that applies to all Apple platforms.
The platform-specific logic (including app instantiation, client code, display server, os support, and export plugin) was refactored, and now the bulk of the implementation is on drivers/apple_embedded. The platforms provide small subclasses that specialize the concrete aspects that are different between platforms. We did this refactor with care, trying not to alter the existing iOS functionality.
The visionOS platform doesn't have OpenGL support, as it's not supported by visionOS.
In order to make reviewing easier, we have tried to split this PR into individual self-contained commits when that made sense, and we have added detailed descriptions to most of them about what's contained in each commit. It's easier to review commit by commit, to see how the changes were incrementally implemented.
Documentation Considerations
Now, the export plugin for iOS and visionOS share the majority of the code and most of their options (with the exception of launch storyboard support, which is iOS only; and specific platform icon support). Because of this, we have renamed EditorExportPlatformIOS.xml to EditorExportPlatformAppleEmbedded.xml, and moved it to drivers/apple_embedded.
We'd like to ask the community if this is appropriate from the docs tooling perspective, and we're requesting further guidance on how to modify this file or the docs tooling to provide specific documentation for each of the platforms.
Testing
We have been testing this PR mainly with the Platformer demo project. We have verified the project continues to work on iOS, and it now runs natively on visionOS. We have tested both the Mobile and Forward+ renderers with the Metal rendering driver on both platforms.
Open Questions
In all our tests, we exported an Xcode project using the corresponding export plugin and template, and we then ran this project directly to an iOS or visionOS device.
We'd like to ask the community to provide guidance, or to help testing the following functionality:
- We have not tested the ability of the iOS/visionOS export templates to embed and link plugins at export time. We tried to preserve this functionality on the visionOS platform, and we assume it will work in the same way it works on iOS. If anybody can attach a project using this functionality, we can help test it.
- We have not been able to make direct Archive/IPA export, nor One-Click-Deploy to work, not even in master. There are some differences between our developer account and what external developers use, so it's a bit difficult to pinpoint the problem. We'd appreciate it if anybody that has One-Click-Deploy currently working is able to test on both platforms.
- Likewise, we have not tested deploying directly to an iOS device using ios_deploy (used with Xcode versions prior to 14.0). If somebody has a working setup using this, we'd appreciate it if you could test this functionality still works. Alternatively, if ios_deploy support is no longer desired due to its age, we're happy to remove those codepaths for code simplicity.
Missing Functionality
- The DPI metrics on visionOS are hardcoded for now. They can change at runtime depending on how close the window is to the viewer. We'll address this in the PR adding SwiftUI, as the metrics come from SwiftUI APIs.
- We have not implemented building a visionOS Icon Asset Catalog into the exporter. If somebody from the community can step in and implement it, that would be awesome. Otherwise, we may submit this as a later PRs. For now, you can work around this by manually creating your visionOS icon after exporting the Xcode project. Here you can read how visionOS icons work. And here's an example icon showing the Asset Catalog structure: visionOS-icon.xcassets.zip
- The SVG logo for the visionOS platform is just text, it'd be good if somebody could come up with a nice graphic.
We're happy to answer any questions or address any concerns. We're looking forward to collaborating with all of you.
@BastiaanOlij @clayjohn @coppolaemilio @stuartcarnie Feel free to mention anybody who would be interested in this change.