lighttransport / tinyusdz

Tiny, dependency-free USDZ/USDA/USDC library written in C++14
Other
488 stars 37 forks source link

USDLoadFromFile fails for some models #174

Closed Richard-Ly closed 1 month ago

Richard-Ly commented 2 months ago

When using USDLoadFromFile, these USD files fail to open with the below error messages:

Arcade_Fight_Stick_Final.usd Download: https://www.dropbox.com/scl/fi/h8boiuvylzqkwg0sax8kl/Arcade_Fight_Stick_Final.usd?rlkey=1wqa8rkn6j9ueqb3mw389qtgr&dl=0

[error]C:\Users\xxxxx\Desktop\tinyusdz\tinyusdz-dev\src\usdc-reader.cc:ReconstructStage():3438 Failed to reconstruct Stage(Prim hierarchy)
[error]C:\Users\xxxxx\Desktop\tinyusdz\tinyusdz-dev\src\usdc-reader.cc:ReconstructPrimFromTypeName():1748 Failed to reconstruct Prim Mesh elementName: Button4BaseShape
[error]C:\Users\xxxxx\Desktop\tinyusdz\tinyusdz-dev\src\usdc-reader.cc[USDC]:ReconstructPrim():1433 Failed to build PropertyMap.
[error]C:\Users\xxxxx\Desktop\tinyusdz\tinyusdz-dev\src\usdc-reader.cc[USDC]:BuildPropertyMap():831 Failed to construct Property `primvars:normals` from FieldValuePairVector.
[error]C:\Users\xxxxx\Desktop\tinyusdz\tinyusdz-dev\src\usdc-reader.cc[USDC]:ParseProperty():1087 `elementSize` must be within [1, 512), but got 840

BattleSpaceship.usd Dowload: https://www.dropbox.com/scl/fi/gqr8w0js7idma0fubfsqf/BattleSpaceship.usd?rlkey=vsgu9zjbouqnhsfm771qkmsla&dl=0

[error]C:\Users\xxxxx\Desktop\tinyusdz\tinyusdz\src\usdc-reader.cc:ReconstructStage():3441 Failed to reconstruct Stage(Prim hierarchy)
[error]C:\Users\xxxxx\Desktop\tinyusdz\tinyusdz\src\usdc-reader.cc:ReconstructPrimFromTypeName():1748 Failed to reconstruct Prim Mesh elementName: Casco_de_cristalShape
[error]C:\Users\xxxxx\Desktop\tinyusdz\tinyusdz\src\usdc-reader.cc[USDC]:ReconstructPrim():1433 Failed to build PropertyMap.
[error]C:\Users\xxxxx\Desktop\tinyusdz\tinyusdz\src\usdc-reader.cc[USDC]:BuildPropertyMap():831 Failed to construct Property `primvars:normals` from FieldValuePairVector.
[error]C:\Users\xxxxx\Desktop\tinyusdz\tinyusdz\src\usdc-reader.cc[USDC]:ParseProperty():1087 `elementSize` must be within [1, 512), but got 7050

Any ideas on what is causing the issue?

Thanks.

syoyo commented 2 months ago

https://www.dropbox.com/scl/fi/h8boiuvylzqkwg0sax8kl/Arcade_Fight_Stick_Final.usd?rlkey=1wqa8rkn6j9ueqb3mw389qtgr&dl=0

Seems contain invalid primvars:normals attribute. No values and elementSize is quite large.

                    vector3f[] primvars:normals (
                        elementSize = 840
                        interpolation = "faceVarying"
                    )

You can ask around OpenUSD community this is a valid USD file.

Richard-Ly commented 2 months ago

Would it be possible to ignore these primvars:normals (or any invalid data)? I'm able to import these models into Blender, though it seems like it fails to load the materials and normals.

syoyo commented 1 month ago

I'd like to report potentially invalid USD data as error for a while to avoid possible side-effects.

syoyo commented 1 month ago

I made too large elementSize as warning, not as error.

But ButtleShip model encounters another errros

ERR : [error]/home/syoyo/work/tinyusdz/src/usdc-reader.cc:ReconstructStage():3496 Failed to reconstruct Stage(Prim hierarchy)
[error]/home/syoyo/work/tinyusdz/src/usdc-reader.cc:ReconstructPrimFromTypeName():1820 Failed to reconstruct Prim Shader elementName: shader
[error]/home/syoyo/work/tinyusdz/src/usdc-reader.cc[USDC]:ReconstructPrim():1484 Failed to build PropertyMap.
[error]/home/syoyo/work/tinyusdz/src/usdc-reader.cc[USDC]:BuildPropertyMap():883 Failed to construct Property `inputs:camera` from FieldValuePairVector.
[error]/home/syoyo/work/tinyusdz/src/usdc-reader.cc[USDC]:ParseProperty():1057 `connectionPaths` must be composed of Explicit items.
syoyo commented 1 month ago

USD contains list editing for attribute(connection)

prepend string inputs:camera.connect = </BattleSpaceship/ala_der/group1/light_ala_der_turquesa2/light_ala_der_turquesa2Shape/two_sided.outputs:out>

According to the spec, https://openusd.org/release/glossary.html#list-editing attribute cannot have list editing. So USD must be wrong.