Throughout WWDC 2018, Apple introduced numerous enhancements to its assist for augmented actuality experiments, together with the brand new file format, USDZ. The USDZ permits for brand spanking new experiences and provides new methods for customers to work together with augmented actuality content material.
I wrote extra about WWDC 2018 right here.
On this article, I’ll dispel some myths in regards to the USD (Z) format, clarify the way it works in relation to ARKit, and spotlight among the variations I discovered in my work and writing. conversion instruments. We are going to slowly dissect one of many USDZ examples supplied by Apple to grasp the format utilized to ARKit and QuickLook.
There’s a lot to cowl, so within the subsequent articles on this sequence I’ll clarify the interior workings of the USD specification and the file format from a extra generic standpoint. So you may work with him and create USD scenes programmatically through Python or C ++ from any platform, not essentially from a Mac.
Would you like me to implement customized USDZ initiatives for you? Click on right here to go away me an electronic mail.
What’s the USD (Z)?
U Common S cene D A author (a.okay.a. USD ) is:
Environment friendly and scalable system for creating, studying and streaming a time-sampled scene description for trade between graphics purposes.
Let's translate that into English.
In easy phrases, the USD is what you’ll name a 3D asset file format with particular additions. One among them is the flexibility to package deal a USDC file with its textures in a USDZ file for it to be consumed by ARKit and QuickLook.
What does all this imply for the AR trade and the ARKit?
USDZ information can, for instance, be shared through iMessage or you may open them instantly from an internet web page with Safari:
You possibly can go to this Safari web page on iOS to attempt it your self.
Probably the most attention-grabbing factor about these two examples is that they present how QuickLook permits customers to expertise RA content material with out having to put in new utility .
It's enormous: think about having the ability to see any 3D product, in the true world, before you purchase it at your favourite on-line retailer with out having to put in a brand new app! This may not be doable with out the assist of Apple's USDZ.
One other use I'm testing is to simply current / share 3D medical fashions: ship them to your mates with an iOS machine they usually'll be capable of instantly view your work, no apps required too. There are lots of extra use instances for USDZ and QuickLook.
USD is developed by Pixar and is used of their software program, from Hydra to Presto. Pixar carried out its open supply implementation a couple of years in the past on Github, so that everybody can now use it to implement conversion instruments or to combine them into their engines and software program .
A single USD file might be regarded as representing a scene, and a USD scene is a hierarchy of what Pixar calls Prims (which, intuitively, might be thought of a node).
The USD performs virtually the identical operate as, for instance, the gLTF or COLLADA file codecs, however in comparison with these different two pattern codecs, it has each extra and fewer options.
For instance, one of many predominant variations is that the gLTF begins to be broadly supported, whereas the USDZ is presently formally supported solely on iOS 'QuickLook.
Acquiring the USDZ asset pattern
For the needs of this text, I assume that you’re underneath MacOS and that you’ve configured your USD Python instruments to make use of from the command line of your terminal, as defined under, after downloading them right here .
Go to this web site out of your browser, click on on the 3D guitar mannequin and reserve it in an affordable location.
Extracting a USDZ asset with out renaming it
I've learn on-line that most individuals who wish to entry information contained in a .usdz file rename it first with a .zip extension, after which extract it from the Finder .
We are able to use the unzip command line instrument to instantly extract a USDZ file as such:
unzip stratocaster.usdz -d stratocaster
extraction: stratocaster / Stratocaster.usdc
extraction: stratocaster / StratocasterGuitar_NeckWood_Albedo.jpg
extraction: stratocaster / StratocasterGuitar_ButtonVolume_Albedo.png
extraction: stratocaster / StratocasterGuitar_ButtonTone_Albedo.png
extraction: stratocaster / StratocasterGuitar_BodyWood_Albedo.jpg
extract: stratocaster / StratocasterStand_Albedo.jpg
extraction: stratocaster / StratocasterStand_Metallic.jpg
extraction: stratocaster / StratocasterStand_Normal.jpg
extraction: stratocaster / StratocasterStand_Roughness.jpg
unzip stratocaster . usdz – – – ] stratocaster
Archives :   [Not available] usdz
Extracting  / Stratocaster .   . / StratocasterGuitar_NeckWood_Albedo . ] Extract from : Stratocaster / StratocasterGuitar_Button_Volume_Albedo . png ] Extract : Stratocaster / ] StratocasterGuitar_ButtonTone_Albedo png
Extract : / 19459010 StratocasterGuitar_BodyWood_Albedo . jpg   . . stratocaster / StratocasterStand_Albedo /  [1 9459011] Extract :  stratocaster / StratocasterStand_Metallic . jpg
Extract from :  / / StratocasterStand_Normal jpg
  stratocaster / StratocasterStand_Roughness
Now you can navigate to your extracted folder and open instantly the .usdc file:
Earlier than persevering with, let's check out what these totally different file codecs imply.
What’s the distinction between USD, USDC, USDA and USDZ?
Recordsdata with .usd, .usdc, and .usda extensions all characterize a scene file in USD, however the way in which they retailer this information is totally different.
Do not forget that a USD file might be regarded as representing a scene and that a USD scene is a hierarchy of nodes. More often than not, you’ll have a 1 to 1 match between a USD file and a 3D mannequin, as a substitute of a scene; that’s, you’ll have just one mesh within the file.
.usda information are USD scenes saved in an ASCII format file. Subsequently, these information are textual content information containing the outline of the scene in a human readable means. For instance, right here is the file .usda for the illustration of a scene in USD containing a easy dice:
# usda 1.zero
def Mesh "dice"
float3  extension = [(-0.5, -0.5, -0.5), (0.5, 0.5, 0.5)]
int  faceVertexCounts = [4, 4, 4, 4, 4, 4]
int  faceVertexIndices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4]
normal3f  normals = [(-0.15186, 0.988312, 0.013374), (-0.206543, 0.977774, -0.036018), (0.026661, 0.999633, 0.004783), (0, -1, 0), (1, 0, 0), (-1, 0, 0)] (
interpolation = "uniform"
point3f  factors = [(-0.5, -0.5, 0.5), (0.5, -0.5, 0.5), (-0.5, 0.5, 0.5), (0.5, 0.5, 0.5), (-0.5, 0.5, -0.5), (0.5, 0.5, -0.5), (-0.5, -0.5, -0.5), (0.5, -0.5, -0.5)]
uniform token subdivisionScheme = "none"
def  "Dice"
  ] Prolong [Not available] =  – zero.5 – ] ] – zero.5 ) ] zero.5 ]
Int ] = ] four four  11] four four four = = ] zero ] three ] 2 three  three ] four four ] 7 7 ] ] zero 7 ] 5 three ] zero four ]
 9011] The Normals = ] ] ( – ] zero.977774 – zero.036018  11] ( zero.026661 zero.026661  ] zero.004783 )  ] ] – 1  1 ] [Not available] 1  eight] 1 zero ) ] 1 zero 
] Interpolation ] ] "uniform"
)  003]
]]  information ] – zero.5 –  – – zero.5 459017 ] zero.5 – zero.5  9011] ] ] ] zero.5 ] ] zero.5 zero.5 ] zero.5 ] –  zero.5 ] – [1 9459010] ] zero.5 zero.5 – zero.5 – 19459010 zero.5 – zero.5 – – – – – – ] zero.5 ) [1 9459011] – zero.5 – ] ]
Uniform Token SubdivisionScheme ] "nothingness"
As you may see, the format is sort of readable and makes it simple to grasp the group of the scene.
Nonetheless, this format isn’t environment friendly as a result of it takes a very long time to research massive information in a textual content file. Because of this, Pixar additionally specifies the .usdc file format, which permits the software program to play the scenes in USD a lot sooner.
.usdc information are the binary illustration of scenes in USD. Subsequently, they’re saved in binary type and opening them with the assistance of a textual content editor isn’t an enormous assist. Right here once more is the instance of the dice scene, this time after opening its .usdc equal with a textual content editor:
¿¿¿? ? ? O EEEUU ÿ € úÿþþú €? €? € ¿€? € ¿¿¿? ? ¿? ¿? ? ? ? ? ¿? ¿? ? ¿¿¿¿? SpecChildren dice specifiertypeNameMesh properties subdivisionScheme pointsextent regular faceVertexCo unets faceVertexIndices float3  default int  B ò 3f  interpolation uniformq ðtoken variability onone Ð
UEQþö öóöùk X) a * @ 1 @ d 1)
1 @ 1 1 @ ¨ 2 € è! 1 @ ø 1 three @ H zero 1 @ °, @ @ ð
EUP ÿüúø ÷
° QA õþÿ @ ÿþ p ÿû TOKENS ° Î STRINGS ž FIELDS | FI FIELDSETS B / PATHS q I SPECS º @
PXR – USDC Discover out extra
] ¿¿? ? ? Ô EEEUU to € 1945ÿþþú ? € ? € ¿] ? € ¿¿? ? ¿? ¿? ? ? ? ? ¿12 ? ¿? ? ¿¿¿? ¿¿Ú Ö primChildren cubic identifier typeName mesh Properties factors Prolonged Regular FaceVertexCounts FaceVertexIndices Float ] default int [ ] B ò 3f ] Interpolation Uniform ð ] token variability none ð
UEQ þö öóöù okay X ) a ] * @ 1 @ 1 )
1 @ 1 1 1 @ ¨ 2 € È90 ! 1 @ ø 1 @ ] H 1 @ ° @ @ ð
[1945 EUP üúø ÷
[ QA @ ÿþ ÿû TOKENS ° ] CORDES ž  9017] ZONES – FIELD ZONES B / PATHS I ] [1 9459016] SPECS º @
Nonetheless, these information might be learn by software program a lot sooner than their .usda counterparts. In reality, USDZ packages for QuickLook should use .usdc in order that scenes are loaded shortly on cell gadgets.
.usd information might be binary or ASCII-based information. Their extension doesn’t reveal their exterior format, however the methods that learn them can decide their format from the primary bytes of the file. In consequence, .usd information might be each textual and binary, which means that you may rename a .usdc or .usda file to .usd, and they’ll operate in the identical means as earlier than they have been renamed.
This format is utilized by QuickLook for rendering scenes and might be imported and utilized in iOS initiatives developed underneath Xcode.
In its present type, it is kind of a compressed file containing at most (and at the least) a .usdc file and all of the textures utilized by this scene.
You possibly can discover ways to create USDZ information from OBJ right here.
USDZ Stratocaster Asset Exploration
Now that you’ve extracted the Strato, you may convert its .usdc file to .usda as such:
cd stratocaster /
usdcat Stratocaster.usdc -o Stratocaster.usda
cd stratocaster /
The Usdcat Stratocaster / / usdc – o – – ] ] usda
Open the file Stratocaster.usda along with your favourite textual content editor and growth:
We are able to now learn the contents of the file to grasp how the belongings of the USDZ are organized to be used by QuickLook.
Open the newly created Stratocaster.usda file by double-clicking it in order that the modifications you make are displayed in actual time.
Simply on the prime you may see the definition of various supplies for this asset. Certaines utilisent des propriétés constantes, alors que d'autres, comme celle-ci, utilisent une texture:
Pour une utilisation avec QuickLook, les noms des attributs (par exemple, les propriétés du matériau) dans les différents pbrMat1 doivent être exactement identiques à ceux indiqués dans l'exemple ci-dessus. Changer le nom de diffuseColor pour diffuser dans le matériau «StratocasterGuitar_SynthString_Material» (et non celui illustré ci-dessus) entraîne la perte de couleur albedo pour les composants utilisant ce matériau:
Remarquez les chaînes à gauche: il manque des informations sur l'albédo.
Pour chaque attribut de matériau utilisant une texture au lieu d'une valeur constante, QuickLook attend un matériau comme celui-ci:
def Shader "color_map"
def Shader "color_map"
and also you additionally want to supply a texture sampler:
def Shader "Primvar"
def Shader "Primvar"
That is what the fabric definition appears to be like like when taken as a complete:
Scene Graph and Meshes
Wanting on the expanded Scene Graph for the Stratocaster mannequin, one factor is straight away noticeable: appears that parts are repeating.
What’s the distinction between the “splitContainer” part and the weather ending with “Materials”?
tl;dr: They’re primarily the identical factor. And the nodes with out something connected, those ending with “Materials”, are merely a by-product of how USD belongings are parsed by the viewer and SceneKit.
If we return to our .usda file, we will search for the textual content “StratocasterGuitar_ButtonTone_Material”, and right here it’s:
Submeshes are represented by GeomSubset Prims in USD. They’re used to specify subsets of the entire mannequin to which to use a cloth completely.
If we attempt to search for any of the “splitContainer” parts, we wouldn’t discover them within the file. It’s as a result of they’re auto-generated from the indices of a given submesh, they usually use the fabric they’re assigned through the rel materials:binding relationship.
The indices listed above for the ButtonTone factor are indices into faces, as a substitute of vertices. They confer with the worldwide face indices for the entire guitar mesh, which might be discovered additional up within the file:
The “StratocasterGuitar” Prim additionally defines the weather composing a vertex: positions, normals, texture coordinates, and and so forth, that are then listed through vertex indices.
Supplies in USD
The USD specification doesn’t explicitly forbid the utilization of non-PBR supplies, however iOS’ QuickLook doesn’t work with non-PBR supplies. So, make it possible for your USDZ file makes use of PBR supplies or QuickLook won’t render them correctly.
Why is PBR essential?
PBR stands for “Bodily Based mostly Rendering”. PBR allows a wide range of enhancements on how realistically objects might be rendered. One among these is the flexibility to make use of image-based lighting, which offers extra correct ambient diffuse and specular reflections.
The variations between “conventional” shading and PBR shading might be stark:
You possibly can study extra about PBR from right here and right here.
In Augmented Actuality, PBR is very related because it permits the 3D fashions being rendered to be shaded in a means which is extra conscious of its environment. For instance, should you have been to render a USDZ mannequin of a shiny metallic dice, with PBR supplies and QuickLook the dice would replicate the atmosphere round it as if it have been an actual one:
Present Points and Limitations with USDZ
One of many largest pains by far is the shortage of fine instruments for artists to export their creations from their asset creation software program to USDZ instantly and with out having to make use of the command line instruments. Command line instruments aren’t for everybody, and most of all of the supplied ones work with solely a handful and outdated intermediate asset codecs, making it laborious to essentially exploit the functionalities of the USD format.
Of their present type, neither the USD or USDZ specs discuss in regards to the potential for the consumer to work together with the 3D scene described by a USDZ file. Therefore, all that’s doable to do in the meanwhile when opening a USDZ file in QuickLook is to take a look at it, and nothing else. For instance, tapping on it gained’t set off any actions and such actions has no approach to be coded into the format anyway.
You possibly can bake animations into the asset, however these are pre-baked and never interactive.
You possibly can’t use non-PBR supplies when combining USDZ with QuickLook. Notice that nothing stops you from declaring Attributes (in USD-speak) in your Prims which have names resembling the fabric properties you’d discover on, say, a Lambert materials, however they gained’t work with Pixar’s renderer or Apple’s.
This can be a limitation particularly if you wish to show widgets/summary 3D objects slightly than 3D fashions of real looking objects.
Apple merchandise solely
Up to now USDZ hasn’t been adopted by Android or different platforms, and therefore it could solely be consumed by customers with iOS and MacOS gadgets. On different platforms, gLTF and gLB appear to be the principle candidate to develop into the USDZ equal.
Furthermore, QuickLook is simply obtainable on iOS. Though third-party options exist, there isn’t an equal native resolution on Android. However you may make sure that if and when it arrives, it would use the gLTF format and can show the content material barely totally different from QuickLook.
AR is inherently averse to the idea of apps: you don’t wish to change to a unique app each time you wish to entry a unique AR layer or service, not to mention obtain and set up an app which you’re going to make use of solely when at a selected location.
Because of this, the truth that USDZ permits customers to work together with AR content material with out having to put in an app is a step ahead in that path, albeit a small one. To essentially transfer within the path of an AR cloud, we’d like to have the ability to, at the least, add interactions to experiences akin to those provided by USDZ.
This requires an answer nearer to a net browser than an app retailer; Mozilla and others are working in direction of that resolution with WebXR.
Given what the USD format is meant as a format to characterize 3D information, however not interactionsI don’t suppose that Apple or Pixar will modify the specs to introduce interactions and scripting.
As an alternative, Apple will both should chunk the bullet and permit customers to work with one thing much like the WebXR/AR or lengthen QuickLook/Safari to combine scripting of the USDZ scenes obtainable.
Apple must step by step introduce higher instruments to writer USD belongings if it doesn’t wish to formally assist gLTF. So, we would see some bulletins with respect to that at WWDC 2019.
USDZ, when mixed with ARKit and QuickLook lets you:
let customers check out 3D fashions of real looking objects with out having to put in apps (which is nice for e-commerce purposes);
ship 3D fashions to mates through iMessage;
package deal USD scenes into a transportable format; and
render objects in 3D realistically due to PBR;
By far probably the most promising utilization for USDZ information is the primary one on the record: customers can check out merchandise in real-life scale and with a lighting atmosphere that makes them look the identical as the ultimate product as a lot as doable:
This can be a visitor put up by Alberto Taiuti. The article was first revealed on Medium.
In regards to the Creator: Alberto is an skilled Engineer turned Entrepreneur with a ardour for Augmented Actuality and mobile-first experiences. He’s presently engaged on Augmented Actuality for indoors. You possibly can attain him right here or observe him on Twitter.