USDZ: Converting 3D models and other start-up tips

Nelson Chang
Perficient Digital Labs
6 min readJan 18, 2019

--

Recently, I’ve been working with the USDZ file format to do animation tests and generally see what was possible with the format. For those unfamiliar, USDZ is the new file format for 3D scenes that was revealed by Apple in collaboration with Pixar mid-2018. As unfortunate as it is, the reality of the moment is that with the file format still being very new, it’s difficult to find a unified source of information documenting the workflow of creating USDZ scenes.

The purpose of this article is to provide a general guide to the workflow that I’ve been using to create new USDZ files as well as document some of the miscellaneous best practices that I have discovered along the way that will make your first time working with the file format significantly easier. I’ll be approaching it from the perspective of someone new to 3D modeling.

Setting up Xcode and getting your model

To get started, you will need to have Xcode 10 or later installed — I would suggest getting the most up to date version as during the course of my testing certain aspects of the usdz_converter were actually updated. Once you have your Xcode updated, you’ll need to double check that command line tools are installed and enabled as shown here:

This option can be found under Xcode>Preferences>Locations

Now that your Xcode is all setup, you can get to the main flow of creating and converting objects to USDZ. To start you’ll need a 3D model to work with. The primary file types that I have worked with so far and know are well-supported are .obj, .abc, .usd, .usda, and .usdc. At the time of writing, there doesn’t appear to be support for .fbx, .dae, or .stl formats. If you’re not able to make your own 3D model, you can download a number of free .obj files from Google Poly or TurboSquid.

Applying textures

One thing to keep in mind at this point is that there currently isn’t support for converting .obj files using their accompanying .mtl files. The USDZ format uses PBR (physically based rendering) textures — this is what helps make USDZ files look so much more realistic when placed in the real world. I’ve found some awesome resources for free PBR textures on these two sites. They’re largely generic, but for our testing purposes they were more than enough.

For anyone who is unfamiliar with PBR textures like I was before I started this process, I’ll quickly run down the different texture map types and what each of them represents. If you’re more of a visual person, it might be useful to crack open a USDZ file and take a look at the individual texture maps while reading through this list. You can easily achieve this by changing the file extension on a USDZ file from Apple’s gallery to .zip and unzipping it.

  • Color: Sometimes referred to as albedo or diffuse, this texture maps color(s) to your 3D object (i.e., what part of the object is which color)
  • Metallic: This texture is grayscale and represents which areas of the object are metal. White represents a metal texture, and black represents non-metal.
  • Roughness: This texture is the inverse of a glossy map and is also grayscale. It maps which portions of the object are reflective versus matte. The values are the opposite of a glossy map, so black represents a reflective surface while white represents a matte surface. You can invert the colors of a glossy map and use it for the roughness map.
  • Normal: This texture is the mostly purple image file that you will often see in texture packages. It represents which portions of a 3D object protrude, are bumpy, or vice-versa.
  • Ambient-Occlusion: This texture map aids in the calculation of how ambient light is reflected or blocked by different portions of the model. In the simplest terms, it gives the model more detailed shadows. This is the last grayscale map applicable to USDZ.
  • Emissive: This map represents which portions of a 3D model are emitting light. For most objects that aren’t lights themselves, this will be a mostly black map or not be used at all.

After you’ve picked out the textures you want, you can open up a terminal and get to converting your 3D model to USDZ.

Using the USDZ Converter

The actual process of converting your file to USDZ is fairly straightforward. You’ll first want to navigate in your terminal to the folder containing your 3D model and PBR textures. Then you’ll need to run this line of code to convert and add textures:

xcrun usdz_converter ExampleInput.obj ExampleOutput.usdz
-g ExampleModelNameFromObj
-color_map Example_Albedo.png
-metallic_map Example_Metallic.png
-roughness_map Example_Roughness.png
-normal_map Example_Normal.png
-ao_map Example_AmbientOcclusion.png
-emissive_map Example_Emissive.png

The -g flag represents the label for a group or model within your 3D model, and this flag can be used to apply different textures to different areas of your model. For models with multiples of the same base object where you want the same texture applied across the board, you can opt out of using the -g flag as by default the texture maps will get applied to every object in the scene. The same goes for standalone object models. Furthermore, the -g flag can be strung together as many times as needed to get textures mapped to the correct models in a scene with multiple objects.

As you can probably guess by going through this, it is fairly difficult to adjust textures and track groups for large scenes when you’re limited to the command line. Apple has thankfully built in a useful flag for handling this, -f, which allows you to dictate commands from an indicated file. Here’s an example portion of a plain text file I created for converting a model with multiple objects:

And we can invoke this text file like so in the command line:

xcrun usdz_converter -f converter.txt

And that’s it! Any edits you need to make to your conversion file can be made in the text file as opposed to navigating through your command line and manually editing changes. You can now view your converted USDZ object on any iPhone with AR support! (A small caveat here is that we were unable to view objects that were larger than 15mb. )

Final Thoughts

If you’re interested in learning more about USDZ and some of the limitations we encountered along with the future that we see coming for the format, I’d recommend checking out the most recent article by my coworker, Conner Hasbrouck.

If you’ve made it this far, thanks for reading, and hopefully this article has helped provide some clarity around the process of converting to USDZ. I know for myself it was difficult to track down a lot of this information, and so, in combining it here, I hope that a lot more people will be able to start experimenting with USDZ and pushing the format to its limits.

Nelson Chang is a Front-end Engineer at Perficient Digital Labs. Read more about how Perficient Digital Labs uses Emerging Technology to create innovative experiences that transform the way our clients do business here.

--

--

Front-End Engineer at Perficient Digital Labs. In a committed relationship with front-end, in love with design, always thinking about UX.