Blender to RealityKit: My AR Pipeline for iOS
The laundry list I use to prepare my models for Apple RealityKit.
I built ThoughtsAR using Apple's platform-exclusive RealityKit. While my dev pipeline is always adapting and evolving, here are a few ways it has shaped my current pipeline when going from Blender to AR on iOS devices.
Here's the tldr:
- Export your model from Blender in .glb format
- Use RealityConverter to convert your model to a .usdz file
- Want animations? Then your model MUST have an armature
- Bake armature poses to the object before exporting
- Give explicit, custom names to each armature action
- In RealityKit, find the animations in the .availableAnimations array
1. Export your model from Blender in .glb format
RealityKit requires .usdz files, but my current pipeline uses RealityConverter to convert the exports from Blender, and GLTF seems to always translate better than .fbx in my experience.
2. Use RealityConverter to convert your model to a usdz file
I found that RealityConverter was not only a quick, painless way to convert to .usdz, but also a really good way to test if my model's animations look right before importing them into my app. I'm aware that there are probably Blender add-ons out there that handle the exporting to .usdz but this way felt comfortable for me.
I generally had the rule “if your animations don't play right in RealityConverter, they won't play right in RealityKit either.”
3. Want animations? Then your model must have an armature
I noticed that in Blender, if you try to keyframe an object's position and move it around the scene the .usdz file wouldn't ever capture those keyframes or motion. To solve this, I gave armatures to everything and made sure all of my animation keyframing happened in pose mode.
4. Bake armature poses to the object before exporting
Before exporting, make sure all your keyframes from pose mode have been baked.
5. Give explicit, custom names to each armature action
Not sure why this was a thing, but as long as I did this the animations would export as I need them to.
In Blender, go to your armature's Dope Sheet, then Action Editor, then name the actions directly.
I also found that any actions that have duplicated names as other actions can cause issues when importing or accessing the animations later on.
6. In RealityKit, find the animations in the availableAnimations array
Once you've loaded your model into RealityKit as a ModelEntity, you can play an animation by calling ModelEntity.playAnimation() and passing in an AnimationResource from the .availableAnimations property on the same model.
And that's it! If you have any questions about my RealityKit 4 experience or suggestions based on your own, feel free to contact me. ✌️
- Davey