Trying to get opacity to work properly

Hey, all. I’ve been working towards producing transparent materials. One material in particular is for a pool model which acts as scenery within a house. Overall, it uses a simple water bump map, with an opacity setting that gives it transparency.

Since I’ve exported the model from SketchUp to .dae, both the original file as well as .dae export are pretty much identical. The issue lies within the generated .skp file I’m creating with the API: the texture for the pool’s material doesn’t resolve any transparency; rather, the result is a “blank” color (sans texture) which is dark blue.

What I’m not sure about the are the implications of setting the material type to a “ColorizedTexture”. If I don’t have a color set, for whatever reason, will this effectively take the color fragment of the texture at a particular UV coordinate and multiply it by (0, 0, 0, 0)?

I’ve tried setting colors and combining them with textures as well. What I’ve noticed is that either A) the result is completely black in the renderer I’m testing with, or as it seems dark bluish as in SketchUP or B) there is no change at all in the look of the texture.

I thought that testing for the pool image in particular, giving it a low opacity of 0.2, and passing “true” to SUMaterialSetUseOpacity() would invoke the transparency. Even after testing with either SUMaterialType_ColorizedTexture or SUMaterialType_Textured set for the pool material in particular, there has been no transparency in the image what-so-ever.

For what it’s worth, I’ve also tried explicitly creating a color and setting the textured material’s color to that color…with a low alpha value (say, 25). No transparency there, either…

It might help to mention that I’m also using Assimp to import the .dae exported from SketchUP, though I’m not sure how relevant that is.

Any idea what may be the cause of this issue might be?

For context,


auto DoBasicMaterialLoad = [&](const aiMaterial* importMaterial, SUMaterialRef exportMaterial )

    bool isTextured = false;
    std::string outfilepath;
    for (unsigned j = 0; j < LENGTH_OF(texLookUp); ++j)
        aiString filepath;
        isTextured = importMaterial->GetTexture(texLookUp[j], 0, &filepath) == AI_SUCCESS; 
        // If this material has a texture, we load it.
        if (isTextured)
            std::string fullpath(rootDir);
            outfilepath = filepath.C_Str();
            // Generate our texture from the file.
            SUTextureRef tex = SU_INVALID;
            SU_CHECK_RESULT( SUTextureCreateFromFile(&tex, fullpath.c_str(), 1.0f, 1.0f) );

            // Bind our texture to the material and bail out of our texture loop.
            SU_CHECK_RESULT( SUMaterialSetTexture(exportMaterial, tex) );    

        aiColor4D ambient, diffuse;
        aiReturn diffuseResult = aiGetMaterialColor(importMaterial, AI_MATKEY_COLOR_DIFFUSE, &diffuse);
        aiReturn ambientResult = aiGetMaterialColor(importMaterial, AI_MATKEY_COLOR_AMBIENT, &ambient);

        bool isColored = (diffuseResult == aiReturn_SUCCESS) || (ambientResult == aiReturn_SUCCESS);

        // This a test, to see if the model which uses Pool_Water_bump.jpg
        // will display a transparent material.
        bool isPool = outfilepath == "pool-before/Pool_Water_bump.jpg";
        if (isPool)
            SU_CHECK_RESULT( SUMaterialSetUseOpacity(exportMaterial, true) );
            SU_CHECK_RESULT( SUMaterialSetOpacity(exportMaterial, 0.2) );
            SU_CHECK_RESULT( SUMaterialSetType(exportMaterial, SUMaterialType_Textured) );

        if (false) // was "if (isColored)"; disabled for debugging purposes.
            aiColor4D total(1.0f, 1.0f, 1.0f, 1.0f);

            if (diffuseResult == aiReturn_SUCCESS) AddRgbMulAlpha(total, diffuse);
            if (ambientResult == aiReturn_SUCCESS) AddRgbMulAlpha(total, ambient);                            

            SUColor color;
   = (unsigned char)(total.r * 255.0f);
   = (unsigned char)(total.g * 255.0f);
   = (unsigned char)(total.b * 255.0f);
            color.alpha = (unsigned char)(total.a * 255.0f);

            if (isPool)
                color.alpha = 0;
            SU_CHECK_RESULT( SUMaterialSetColor(exportMaterial, &color) );

            if (isTextured)
                SU_CHECK_RESULT( SUMaterialSetType(exportMaterial, SUMaterialType_ColorizedTexture) );
                SU_CHECK_RESULT( SUMaterialSetType(exportMaterial, SUMaterialType_Colored) );
        else if (isTextured && !isPool)
            SU_CHECK_RESULT( SUMaterialSetType(exportMaterial, SUMaterialType_Textured) );