Assimp: STL files have broken default material (full white ambient)

Created on 16 Jul 2018  路  7Comments  路  Source: assimp/assimp

Hi,

f84851e8931fb04e7074d487c91c3b3faa566994 refactored the default material provided by the STL importer. For some reason now both the diffuse and the ambient are set to full white.

Having a full white ambient of course breaks literally all appliations using the default materials provided by assimp.

The commit also changes PLY's default material to the same values, and the STL seems to have changed for consistency reason. This however is inconsistent with OBJ files, whose default material has no ambient, no specular and (0.6, 0.6, 0.6) diffuse.

Bug

Most helpful comment

@kimkulling was the issue with the white ambient color resolved since 4.1 got released? I'm hitting this when loading STL models in Magnum and have to work around this post-import.

To be clear, no matter if it's possible to override default settings for materials or not, having white ambient is just plain wrong, as it completely discards any other color information. Can we get it back to black, as it was before?

All 7 comments

Ok, thanks for the report.

Just as a demonstration:

When importing STL file with assimp 3.1:

screenshot from 2018-07-21 11-40-14

When importing STL file with assimp 4.1:

screenshot from 2018-07-21 11-44-03

Is this issue also closed by last PR?

On the latest master you now can get the default-material via aigetDefaultMaterial() and set the colors as you want to have them. So this issue should be closed as well.

I think this issue should be reopened. Even with new API aiCreateAndRegisterDefaultMaterial STL loader overwrite any parameters setted previously for that material, which is pointless.

Only usefull usage of aiCreateAndRegisterDefaultMaterial is a way to detect if material is default. But not to use your own parameters.

All because of this peace of code from STLLoader.cpp:

   // create a single default material, using a white diffuse color for consistency with
    // other geometric types (e.g., PLY).
    aiMaterial* pcMat = aiCreateAndRegisterDefaultMaterial();
    /*aiMaterial* pcMat = new aiMaterial();
    aiString s;
    s.Set(AI_DEFAULT_MATERIAL_NAME);
    pcMat->AddProperty(&s, AI_MATKEY_NAME);*/

    aiColor4D clrDiffuse(ai_real(1.0),ai_real(1.0),ai_real(1.0),ai_real(1.0));
    if (bMatClr) {
        clrDiffuse = clrColorDefault;
    }
    pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_DIFFUSE);
    pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_SPECULAR);
    clrDiffuse = aiColor4D( ai_real(1.0), ai_real(1.0), ai_real(1.0), ai_real(1.0));
    pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_AMBIENT);

@kimkulling was the issue with the white ambient color resolved since 4.1 got released? I'm hitting this when loading STL models in Magnum and have to work around this post-import.

To be clear, no matter if it's possible to override default settings for materials or not, having white ambient is just plain wrong, as it completely discards any other color information. Can we get it back to black, as it was before?

Was this page helpful?
0 / 5 - 0 ratings