0
votes

I've applied transparency in maya and export it as dae, but when I'm converting dae to gltf, transparency is not visible. Can anyone tell me how to achieve transparency in gltf file?

materail used in .gltf file

"materials": {
    "small_walls_lambert2-fx": {
        "name": "small_walls_lambert2",
        "technique": "technique0",
        "values": {
            "ambient": [
                0,
                0,
                0,
                1
            ],
            "diffuse": "texture_small_walls_file1-image",
            "emission": [
                0,
                0,
                0,
                1
            ]
        }
    },

fo your reference i am attaching sample gltf 3d model. enter image description here My requirement is walls should be in transaparant, it is achived in maya but not visible when coming to gltf(cesium). Is there any way to achieve this by editing gltf file.

1
Can you post the dae, or a snippet showing the material definition inside the dae file where there is supposed to be transparency?emackey
hi emacky, please check the attached model bmpChanduRaj

1 Answers

1
votes

The transparency factor is usually in the range [0,1]. Maya does always export a transparency factor of 1.0, which implies full transparency.

Here is my code from the FBX->glTF converter

web::json::value gltfWriter::WriteMaterialTransparencyParameter (
    const utility::char_t *pszName, 
    FbxPropertyT<FbxDouble> &property, FbxPropertyT<FbxDouble3> &propertyColor, FbxProperty &propertyOpaque,
    web::json::value &values, web::json::value &techniqueParameters
) {
    web::json::value ret =web::json::value::null () ;
    double value =1. ;
    if ( propertyOpaque.IsValid () ) {
        value =1.0 - propertyOpaque.Get<double> () ;
    } else {
        if ( !property.IsValid () )
            return (ret) ;
        value =property.Get () ;
        if ( propertyColor.IsValid () ) {
            FbxDouble3 color =propertyColor.Get () ;
            value =(color [0] * value + color [1] * value + color [2] * value) / 3.0 ;
        }
    }
    if ( !GetIOSettings ()->GetBoolProp (IOSN_FBX_GLTF_INVERTTRANSPARENCY, false) )
        value =1.0 - value ;
    values [pszName] =web::json::value::number (value) ;
    techniqueParameters [pszName] =web::json::value::object ({ { U("type"), IOglTF::FLOAT } }) ;
    return (ret) ;
}

What is does is to check if there is an Opaque property set. If not use the TransparencyFactor and TransparencyColor to determine the glTF transparency.

value =(color [0] * value + color [1] * value + color [2] * value) / 3.0 ;

You material definition above does not define any transparency, so you would need to add something like this:

            "transparency": 1,
            "transparent": [0,
            0,
            0,
            1]

and handle the parameter in your shader as well.