<p>According to the source (<a href="https://github.com/assimp/assimp/blob/b7df376836e36c4b6998ce95d97626e30f61c2f0/code/AssetLib/Obj/ObjFileImporter.cpp#L594" rel="nofollow noreferrer">https://github.com/assimp/assimp/blob/b7df376836e36c4b6998ce95d97626e30f61c2f0/code/AssetLib/Obj/ObjFileImporter.cpp#L594</a>) only illum values of 0, 1, 2 are supported:</p>
<pre><code>    // convert illumination model
    int sm = 0;
    switch (pCurrentMaterial-&gt;illumination_model) {
    case 0:
        sm = aiShadingMode_NoShading;
        break;
    case 1:
        sm = aiShadingMode_Gouraud;
        break;
    case 2:
        sm = aiShadingMode_Phong;
        break;
    default:
        sm = aiShadingMode_Gouraud;
        ASSIMP_LOG_ERROR(&quot;OBJ: unexpected illumination model (0-2 recognized)&quot;);
    }
</code></pre>

CC BY-SA 4.0
2021-03-29T17:56:03.480Z
2021-03-29T17:56:03.480Z
J Mills
<p>I am loading an OBJ file using the ASSIMP library. Following is the MTL file associated with the obj file.</p>

<pre><code>newmtl initialShadingGroup
Kd 0.50 0.50 0.50
Ka 0.09 0.09 0.09
Tf 1.00 1.00 1.00
Ns 10.0
map_Ka sphere_roughness.jpg
map_Kd sphere_albedo.jpg
map_Ks sphere_metallic.jpg
bump sphere_normal.jpg
disp sphere_bump.jpg
illum 7
</code></pre>

<p>I want to read the illum value so that I can choose an appropriate sharding model in my shaders. The code I'm using is </p>

<pre><code>int shadingModel;
material-&gt;Get(AI_MATKEY_SHADING_MODEL, shadingModel);
std::cout &lt;&lt; "ShadingModel: " &lt;&lt; shadingModel&lt;&lt; std::endl;
</code></pre>

<p>But the output I'm getting is </p>

<pre><code>ShadingModel: 2
</code></pre>

<p>when the value is 7. Is there something that I'm doing it wrong or is it the wrong way to retrieve the shading model. 
Thanks for your help!</p>

<opengl><rendering><shading><material>
How to read illum value from mtl file using Assimp library?
user13184
# How to read illum value from mtl file using Assimp library?

(Asked by: username_0 on 2020-04-15)

I am loading an OBJ file using the ASSIMP library. Following is the MTL file associated with the obj file.
newmtl initialShadingGroup
Kd 0.50 0.50 0.50
Ka 0.09 0.09 0.09
Tf 1.00 1.00 1.00
Ns 10.0
map_Ka sphere_roughness.jpg
map_Kd sphere_albedo.jpg
map_Ks sphere_metallic.jpg
bump sphere_normal.jpg
disp sphere_bump.jpg
illum 7

I want to read the illum value so that I can choose an appropriate sharding model in my shaders. The code I'm using is 
int shadingModel;
material->Get(AI_MATKEY_SHADING_MODEL, shadingModel);
std::cout << "ShadingModel: " << shadingModel<< std::endl;

But the output I'm getting is 
ShadingModel: 2

when the value is 7. Is there something that I'm doing it wrong or is it the wrong way to retrieve the shading model. 
Thanks for your help!

**Tags:** opengl, rendering, shading, material

---

## 1 answers

### Answer by username_1 on 2021-03-29. Score: 1

According to the source (https://github.com/assimp/assimp/blob/b7df376836e36c4b6998ce95d97626e30f61c2f0/code/AssetLib/Obj/ObjFileImporter.cpp#L594) only illum values of 0, 1, 2 are supported:
    // convert illumination model
    int sm = 0;
    switch (pCurrentMaterial->illumination_model) {
    case 0:
        sm = aiShadingMode_NoShading;
        break;
    case 1:
        sm = aiShadingMode_Gouraud;
        break;
    case 2:
        sm = aiShadingMode_Phong;
        break;
    default:
        sm = aiShadingMode_Gouraud;
        ASSIMP_LOG_ERROR("OBJ: unexpected illumination model (0-2 recognized)");
    }


---

