pablode / guc

glTF to USD converter with MaterialX support
Apache License 2.0
112 stars 6 forks source link

`UsdGlTFFileFormat::Read` fails to files with non-filesystem `resolvedPath`s. #24

Closed expenses closed 3 months ago

expenses commented 9 months ago

Hi! I tried to get guc working with the custom resolver I've been working on but unfortunately it fails upon trying to load the file: Failed to open "iroh://doc/pajzuzssv2l7wg7iruxixkbc7nfcm42gqfqbmzz5hux4im4v2yea/m5wfirrpirqw2ylhmvseqzlmnvsxilthnr2gmaa.gltf" - unable to parse glTF file: file not found

The problem is that this code assumes that resolvedPath is on the local filesystem:

https://github.com/pablode/guc/blob/0fb7f767786de6bb14076eb69f3998e3b79115d9/src/libguc/src/fileFormat.cpp#L97-L106

Ideally you'd call something like ArGetResolver().OpenAsset(resolvedPath) to get an ArAsset and then use the bytes from ArAsset::GetBuffer to load the glTF data. This is a bit of a hastle not gonna lie, but it would mean that assets using custom URI schemas (iroh:// for me, but also http://) would load perfectly.

pablode commented 9 months ago

Thank you very much for this report! This is an oversight, and your proposed solution makes sense. Will implement it soon-ish!

expenses commented 9 months ago

Additionally, I think you want to return relative paths for existing on-disk assets. At the moment you get absolute paths like @/home/ashley/projects/glTF-Sample-Models/2.0/DamagedHelmet/glTF/Default_normal.jpg@ which a HTTP resolver isn't going to be able to resolve if the anchor path looks like http://localhost:8000/DamagedHelmet.gltf. I haven't done a deep dive into how the internals work yet, so I'm not sure how the the images embedded in a binary file like http://localhost:8000/DamagedHelmet.glb should be resolved. Presumably just extracted to a temporary directory?

pablode commented 6 months ago

Hi, I just implemented the feature in this branch. I have yet to test it with an actual custom resolver.

EDIT: it's now in dev and will be released soon.

pablode commented 3 months ago

This is now implemented in v0.4, thanks for the patience!