kcoley / gltf2usd

command-line utility for converting glTF 2.0 models to USD
MIT License
264 stars 38 forks source link

Support for Apple's package stand-alone USD (v18.09) libs #8

Closed wave-electron closed 6 years ago

wave-electron commented 6 years ago

Kacey,

Currently you will need to initially have USD v18.09 installed on your system and have the Python modules built Pillow (Python module for image manipulation)

Would gltf2usd build with Apples new package python-usd-library ?

In the python-usd-library readme file it stated the following

This binary library was compiled using version 18.09 of [the public USD Github repository](http://openusd.org) with the following build script arguments (see USDPython/README.md for further details):

    python USD/build_scripts/build_usd.py --build-args TBB,extra_inc=big_iron.inc --python --no-imaging --docs --no-usdview --build-monolithic USDPython
kcoley commented 6 years ago

Hi @wave-electron. It should work theoretically since this code is built against the official USD python API. I can give it a try later today to verify

wave-electron commented 6 years ago

I used your gltf2usd python tool to successfully build the monster.gtlf example and it’s working in ios12 beta 9. However, I already had the older version of usd prior to 18.09 built on my system. I’m also on high Sierra. I had to install Pillow and another python module to get it working. I haven’t had much time to play with it yet. I did notice the scaling had to be set to 0.05 in the usda file to get the monster to a viewable 1 metre size to view in my room in AR. I had already drop the Apple usd tool on my system as well, so don’t know for sure if that helped it work properly. Anyway would love to know if the standalone build will suffice as it will make it much easier deploying on my other Mac computers as building USD is still a tricky process on Mac from what i’ve found.

enzyme69 commented 6 years ago

@wave-electron Kind of on topic, I tested on the Monster asset and getting animated USDZ, however it is not animating on my iOS 12 Beta 9.

So I use the GLTF -> USDA. Then I convert USDA into USDZ using Apple binary at USDZ Gallery.

Wondering if I am doing it right?

Note: I think I have USD v18.09 that I built normally. I also downloaded Apple one but not sure how to use it. But anyhow, animation USDZ animation works on MacOS, but not on iOS 12 Beta 9. Maybe I need to wait for XCode 10 Beta 7? Hmmm... weird.

kcoley commented 6 years ago

@wave-electron I just pointed to Apple's build of USD_Python instead of my local build, and this tool still works, which makes using this tool more convenient for those without a USD build (on Mac). As for the scaling issue you are running into, I scale the generated USD models by 100x since glTF defaults to meters and USD defaults to centimeters. I could provide an option where the scale of the generated USD file can be customized to something else through command line, though in the meantime, you can overwrite the scale at the top of the USD model (if viewed as a usda file).

@enzyme69 I made some updates to this code to work around some iOS bugs that were preventing animations from working. You can pull the latest master from this code and try converting again. I will report these bugs to Apple's bug reporting tool.

enzyme69 commented 6 years ago

@kcoley I tested it just now with latest update and confirming the GLTF -> USD -> USDZ animation works! Thanks! Not sure what causing it, but finally we have a working USDZ animation with bones! Awesome!

@wave-electron Also bouncing ball USD animation from Apple example does not work as USDZ, but maybe it's related to this bug. Also regarding scale, I can see a weird USDZ scaling of this Monster and it seems to be floating high on floor.

wave-electron commented 6 years ago

Jimmy,

Both transform & bone animations are working in ios12 beta 9. I’ve got some working examples at www.fusionar.app

However, there is some recent change relating to material referencing in usda which broke previous usdz models built prior to ios12 beta 6. I’m still working on what the change is between the versions.... hopefully work it out later tonight... and let you know.

On Thu, 23 Aug 2018 at 12:54 pm, Jimmy Gunawan notifications@github.com wrote:

@kcoley https://github.com/kcoley I tested it just now with latest update and confirming the GLTF -> USD -> USDZ animation works! Thanks! Not sure what causing it, but finally we have a working USDZ animation with bones! Awesome!

@wave-electron https://github.com/wave-electron Also bouncing ball USD animation from Apple example does not work as USDZ, but maybe it's related to this bug.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kcoley/gltf2usd/issues/8#issuecomment-415266235, or mute the thread https://github.com/notifications/unsubscribe-auth/APhRdGB5jp6asdh5rd1DIXVSMBDi-9zpks5uThlngaJpZM4WHF_- .

enzyme69 commented 6 years ago

UPDATE: Although monster.usdz animation works correctly, I am not getting animation on this monkey head. Not sure why... monkey_test_usdz.zip

enzyme69 commented 6 years ago

And this animation does not working on iOS, works on MacOS:

What could the bug be? Is this something that I can manually edit on USDA for quick fix?

tentacle_test.zip

Thanks!

This makes me wondering why the Monster USDZ works on iOS earlier...

kcoley commented 6 years ago

Hi @enzyme69 . I played with the models a bit and got them to work on iOS by removing Armature/ from the bones names. One of the workarounds I previously implemented was naming the skeleton root the same as the root joint. But with the USD models converted from Blender glTFs, Armature is the root of all bones so is part of the bone names based on the hierarchy.
Here are the tweaked models: monkeybone.zip tentacle.zip

I'll file another issue to try to handle this workaround as well.

So for now, remove Armature/ from the bone names

wave-electron commented 6 years ago

Also bouncing ball USD animation from Apple example does not work as USDZ, but maybe it's related to this bug.

@enzyme69 Apple has some samples in the standalone USD library. For example if you run the python script skinnedMeshAnimation.py You get the skinnedMeshAnimation.usd and skinnedMeshAnimation.usdz in samples/assets directory. These usdz animations are working & i've posted skinnedMeshAnimation.usdz on my fusionar.app gallery. Its a bouncing cube with morph animation.

wave-electron commented 6 years ago

@enzyme69 @kcoley I've undercovered a really strange bug. A png image file named basecolor.png used for my base_map PBR texture for some reason was making all my usdz models that uses that png file crash in ios12 beta 6 onwards. By merely replacing that png file but keeping everything else the same I fixed all those corrupted usdz files. It doesn't seem to have anything to do with the naming or referencing - but purely the png file! If I can work out what it is I'll let you guys know.

This was the command line I used to create the file. It was an animated alembic file exported from Blender... which BTW was working perfectly fine up until ios12 beta 6.

xcrun usdz_converter newtons_cradle.abc newtons_cradle.usdz -g base -color_map basecolor.png -metallic_map metallic.png -normal_map normal.png -roughness_map roughness.png -g cradle -color_map basecolor.png -metallic_map metallic.png -normal_map normal.png -roughness_map roughness.png -a -l -v 

This is the usdz file which is now working again in ios12 beta newtons_cradle.usdz

enzyme69 commented 6 years ago

@wave-electron @kcoley

Thanks this is now working great! 👍 👍

screen shot 2018-08-23 at 5 28 35 pm