assimp / assimp

The official Open-Asset-Importer-Library Repository. Loads 40+ 3D-file-formats into one unified and clean data structure.
https://www.assimp.org
Other
10.78k stars 2.9k forks source link

Bug: 3ds export error #4157

Closed copycd closed 2 years ago

copycd commented 2 years ago

Describe the bug when i export my Scene-object to 3ds, ai_assert(false) occur error. because aiShadingMode_PBR_BRDF of shading_mode is not processed. so that I took care of it temporarily.

below line 320 in 3DSExporter.cpp

    if (mat.Get(AI_MATKEY_SHADING_MODEL, shading_mode) == AI_SUCCESS) {
        ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAT_SHADING);

        Discreet3DS::shadetype3ds shading_mode_out;
        switch (shading_mode) {
        case aiShadingMode_Flat:
        case aiShadingMode_NoShading:
            shading_mode_out = Discreet3DS::Flat;
            break;

        case aiShadingMode_Gouraud:
        case aiShadingMode_Toon:
        case aiShadingMode_OrenNayar:
        case aiShadingMode_Minnaert:
            shading_mode_out = Discreet3DS::Gouraud;
            break;

        case aiShadingMode_Phong:
        case aiShadingMode_Blinn:
        case aiShadingMode_CookTorrance:
        case aiShadingMode_Fresnel:
        // I writed.
        case aiShadingMode_PBR_BRDF:
            shading_mode_out = Discreet3DS::Phong;
            break;

        default:
            shading_mode_out = Discreet3DS::Flat;
            ai_assert(false);
        };
        writer.PutU2(static_cast<uint16_t>(shading_mode_out));
    }

Platform (please complete the following information):

Additional context Add any other context about the problem here.

RichardTea commented 2 years ago

Thanks for the report. Your fix looks to be the best option for now. I've added exporting BASE_COLOR if there's no DIFFUSE as it's usually close enough - at least for Phong rendering, anyway.

In theory a "high" Metalness probably ought to be exported Discreet3DS::Metal, however I've not found any documentation about the 3DS "metal" type. Given how obsolete this proprietary format is, it's highly unlikely anyone will ever reverse-engineer that part if it wasn't done back in the late 1990's...