gltf2usd icon indicating copy to clipboard operation
gltf2usd copied to clipboard

Material opacity lost on export to USDZ

Open TyLindberg opened this issue 5 years ago • 7 comments

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

TyLindberg avatar Jul 23 '19 21:07 TyLindberg

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

paprikka avatar Aug 02 '19 15:08 paprikka

+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
    }
}

SokWonJeremyKim avatar Sep 10 '19 05:09 SokWonJeremyKim

@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)

rafaelmaroxa avatar Nov 19 '19 20:11 rafaelmaroxa

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

TyLindberg avatar Nov 20 '19 07:11 TyLindberg

opacity did not work after the convert to usdz file

ang88myt avatar Dec 11 '19 08:12 ang88myt

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

ang88myt avatar Dec 11 '19 08:12 ang88myt

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

pedrorocha-net avatar Oct 29 '21 15:10 pedrorocha-net