kcoley / gltf2usd

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

Material opacity lost on export to USDZ #169

Open TyLindberg opened 5 years ago

TyLindberg commented 5 years ago

When the material in a gltf file has a base color with an alpha value less than 1, the material will still appear fully opaque in USDZ. This seems to have started happening at commit c0301fc9579739c826d51be97fc1d169f2c78e65.

Attached is an example model that exhibits this behavior.

TransparentDuck.zip

paprikka commented 5 years ago

+1 Please let me know if there's anything I can do to help.

SokWonJeremyKim commented 4 years ago

+1 Please help. GLTF viewers show transparency correctly, which is lost on exporting to USDZ

This is the part that gives alpha

{
    "alphaMode" : "BLEND",
    "name" : "Model_AP.001",
    "normalTexture" : {
        "index" : 2,
        "texCoord" : 0
    },
    "pbrMetallicRoughness" : {
        "baseColorFactor" : [
            1,
            1,
            1,
            0.5799999833106995
        ],
        "baseColorTexture" : {
            "index" : 3,
            "texCoord" : 0
        },
        "metallicFactor" : 0.8826087117195129,
        "roughnessFactor" : 0.08260869234800339
    }
}
rafaelmaroxa commented 4 years ago

@TyLindberg The line of code that set the default opacity value was removed on commit c0301fc9579739c826d51be97fc1d169f2c78e65 like you suspected. Adding it back fixed it for me, but may not work for you.

Added the following line to the _gltf2usd/usd_material.py file:

self._clearcoat_roughness = material.CreateInput('clearcoatRoughness', Sdf.ValueTypeNames.Float)
self._clearcoat_roughness.Set(0.01)

self._opacity = material.CreateInput('opacity', Sdf.ValueTypeNames.Float)
self._opacity.Set(1.0) # added back this line to set a default value to the opacity.

self._ior = material.CreateInput('ior', Sdf.ValueTypeNames.Float)
self._ior.Set(1.5)
TyLindberg commented 4 years ago

@rafaelmaroxa Nice find! Might be worthwhile to open a pull request with that fix.

ang88myt commented 4 years ago

opacity did not work after the convert to usdz file

ang88myt commented 4 years ago

may i know what is the proper way to it up on gltf side?

pedrorocha-net commented 2 years ago

Any update on this issue? Should we consider a PR with the suggested fix?