This tool is a command-line Python script which converts glTF 2.0 models to USD, with the goal being simple pipeline conversion from glTF to usd, usda, usdc, or usdz.
The tool is a proof-of-concept, to determine format conversion details, which could be useful for an actual C++ USD plugin. It has been developed and tested on both Windows 10 and Mac OS 10.14 Mojave Beta, using USD v18.09 and v18.11, and is built against the USD Python API.
This tool currently only works on glTF 2.0 files, based on the core glTF 2.0 specification (no extensions except PbrSpecularGlossiness
and KHR_texture_transform
).
Xform
PbrMetallicRoughnessMaterial
is mapped to USDPreviewSurface
UsdSkel
.gltf
conversion to .usd
, .usda
, .usdc
, and .usdz
.glb
filesKHR_materials_pbrSpecularGlossiness
and KHR_texture_transform
)PYTHONPATH
(an easy way to do this is to run the path_to_usdpython/USD.command
shell command included with the prebuilt USD Toolkit).You can install the following python dependencies using pip install -r requirements.txt
:
python gltf2usd.py -h
usage: gltf2usd.py [-h] --gltf GLTF_FILE [--fps FPS] --output USD_FILE
[--scale] [--verbose] [--arkit]
Convert glTF to USD
optional arguments:
-h, --help show this help message and exit
--gltf GLTF_FILE, -g GLTF_FILE
glTF file (in .gltf format)
--fps FPS The frames per second for the animations (defaults to 24 fps)
--output USD_FILE, -o USD_FILE
destination to store generated .usda file
--scale SCALE, -s Scale the resulting USDA model
--verbose, -v Enable verbose mode
--arkit Check USD with ARKit compatibility before making USDZ
file
--use-euler-rotation sets euler rotations for node animations instead of
quaternion rotations
--optimize-textures Specifies if image file size should be optimized and
reduced at the expense of longer export time
--generate_texture_transform_texture
Enables texture transform texture generation
--no-generate_texture_transform_texture
Disables texture transform texture generation
Create a .usda file
python gltf2usd.py -g ../path_to_read_glTF_file/file.gltf -o path_to_write_usd_file/file.usda
Create a .usdz file
python gltf2usd.py -g ../path_to_read_glTF_file/file.gltf -o path_to_write_usd_file/file.usdz