I am very new to USD, I have written a simple Python script to generate a basic USD file containing a blue Sphere, this part works fine, however, I then want to create a USDZ package using this file so have used the UsdUtils CreateNewUSDZPackage function which results in a pink and purple mess instead of the blue from the original file.
I would like to know why this is occurring and how to prevent it.
The simple script is as follows:
from pxr import Usd, UsdGeom, UsdUtils
stage = Usd.Stage.CreateNew('HelloWorld.usd')
xform = stage.DefinePrim('/hello', 'Xform')
sphere = stage.DefinePrim('/hello/world', 'Sphere')
extentAttr = sphere.GetAttribute('extent')
radiusAttr = sphere.GetAttribute('radius')
radiusAttr.Set(2)
extentAttr.Set(extentAttr.Get() * 2)
sphereSchema = UsdGeom.Sphere(sphere)
color = sphereSchema.GetDisplayColorAttr()
color.Set([(0, 0, 1)])
stage.GetRootLayer().Save()
UsdUtils.CreateNewUsdzPackage('HelloWorld.usd', 'HelloWorldZ.usdz')
The produced files look like this:
Thank you
I think this is the same issue I've described here: https://developer.apple.com/forums/thread/691674
Your script is correct, and you can confirm by opening the created "HelloWorldZ.usdz" file in USDView. However, it looks like "displayColor" is not supported by apple AR viewers (AR Quick Look / Reality Composer). You have to create textures and shaders if you want colors there, otherwise they'll look pink / purple. I have not been able to find any official Apple documentation on this (if anyone can that'd be awesome), I only found a post on usd-interest google group from 2019 which reported the same: https://groups.google.com/g/usd-interest/c/8hD2rzRboeg/m/PSgIPlLCBgAJ with the answer:
And I was just told that ARQL does not currently support vertex displayColors in any capacity - neither without a bound material (as in the example I provided), nor as something read via a UsdPrimvarReader shader to feed to a UsdPreviewSurface... the only primvars currently supported in ARQL are texture coordinates for feeding a UsdUVTexture shader.