First things first: Augmented Reality is an inherently 3D activity. The ease with which you pick it up will be directly proportional to your existing experience working in 3D. This is not to say someone without 3D experience can't do AR, but it will be harder for you until you become more familiar with common 3D principles. The skill set used for creating 3D games and AR experiences are essentially the same.
If your'e a complete 3D noob, I suggest checking out some of the RayWenderlich.com tutorials on getting started with 3D game development.
The first decision to make is whether you want to use Xcode or a 3D game framework such as Unity or Unreal to create your experience. For the purposes of this guide, I'll assume you will choose Xcode, simply because I have no personal experience with the other two options. If you're already experienced with one of them or are feeling adventurous, then I'm sure you can find AR learning resources online.
Pros: Familiar interface. Develop in Swift. No licensing costs. Cons: Lacks asset production pipelines of dedicated game platforms.
Xcode will probably be the first choice for most existing iOS developers. Having familiarity with the interface means spending less time wondering how to accomplish tasks and more time coding. Unlike the game platforms, however, the asset production pipeline in Xcode is rudimentary and converting 3D assets for use in SceneKit can be difficult.
Pros: Free to develop. Great community support. Robust asset production pipeline. Cons: Pay to publish. Revenue sharing above a certain limit. Complex interface.
Unity is the most popular non-Apple platform for creating 3D content on iOS devices. There is a robust and active community as well as a very high quality asset store allowing easy access to tens of thousands of models, textures, sounds, etc.
Pros: Free to develop. Great community support. Robust asset production pipeline. Cons: Pay to publish. Revenue sharing above a certain limit. Complex interface.
Unreal is making a big play in the AR market, both on Android and iOS. It is a mature platform with lots of developers. I don't really know much about it, though.
Assuming you went with Xcode, you now must choose between 3 different rendering technologies:
SceneKit is going to be the right choice over 90% of the time. It is expressly made for 3D content and is very easy to get up and running with. It is the technology which Apple chose for all of its example projects.
While there are not currently a ton of high-quality tutorials specifically about doing AR in SceneKit, there are a TON of basic 3D game creation tutorials out there and the skill set is almost completely the same.
Ray Wenderlich's SceneKit Tutorials
While you can use SpriteKit, it's difficult to imagine many scenarios where you should. It is designed and optimized for 2D game creation and the ability to place 2D sprites into a 3D space is of questionable utility.
If you're experienced enough to be rolling your own 3D rendering pipeline in Metal, you don't need this document. Godspeed.
It is important to understand the ARKit rendering cycle and the various classes involved and their purposes. I suggest starting with the WWDC 2017 video on the topic:
WWDC 2017 Session 602: Introducing ARKit
If you're interested in doing Animoji or other facial recognition AR tasks, this video is a good place to start:
Fall 2017: Face Tracking with ARKit
From there, I'd recommend checking out the resources on the Apple Developer ARKit page, which includes links to the above videos, example projects, links to the documentation and Human Interface Guidelines for AR experiences.
I strongly suggest you read the HIG for augmented reality, as it contains Apple's best practices for creating believable AR experiences.
The default project that Xcode 9 creates when you tell it you want to do AR is a great jumping-off point. It has already configured ARKit and SceneKit with an example of 3D geometry for you to inspect. Note: the default project's ARSession
is NOT configured to do plane detection. To enable it, you will need to add the following line to the view controller's viewWillAppear
method:
configuration.planeDetection = .horizontal
Then you need to implement the ARSCNViewDelegate
methods for adding, updating and removing nodes for anchors.
- Be aware that the camera will start at the origin of the SceneKit scene, facing directly along the Z-axis, no matter what direction you're facing in the real world when you launch the app. If you want a user to see an object in front of them when the app starts, place it some distance along the Z axis.
- Placing an object over the origin of a scene will cause the camera to spawn inside the object and the user won't be able to see it until they move away and turn around.
- Scenekit's dimensional unit of measure is the meter. So a cube that is 1.0 x 1.0 x 1.0 will be 1 meter on each side. Keep this in mind when importing 3D artwork you find online, as it will often be tens or hundreds of units on a side and need to be scaled down dramatically.
- The free 3D program Blender can convert a lot of popular 3D formats into ARKit's preferred format. Simply open the model file in Blender, then choose File -> Export and choose Collada (.dae).
- SceneKit's SCNPlane objects are created with a vertical orientation, perpendicular to the Z axis. To use them in your scene to show an
ARPlaneAnchor
's extent, rotate them by (-Double.Pi / 2.0) on the X axis before placing them into the scene.
Feel free to suggest changes or additions to this document. Reach me at jsulliva@nerdery.com or on HipChat.