<p>AI_MATKEY_COLOR_TRANSPARENT is used to define the transparent colour and AI_MATKEY_REFRACTI is the refractive index.</p>

CC BY-SA 3.0
2017-07-03T06:35:01.510Z
That doesn't seem to work for me. In this [example](https://pastebin.com/dKC8xz4V), I tried to use these identifiers but with no success. I also added the source .mtl file and the code I was trying to run with the output for clarification.
Michal Kučera
CC BY-SA 3.0
2017-07-03T07:35:30.067Z
Unfortunately I didn't test with a .mtl file, the information was from browsing the header files, the 2 macros I posted are the only references to those material parameters I could find so this could possibly be a incomplete feature in Assimp.
PaulHK
CC BY-SA 3.0
2017-07-03T07:43:53.253Z
That might very well be the case. I tried to find some document specifying which parameters are supported and which aren't, but no luck so far.
Would you know of any alternative way to define and load a material in an external file?
Michal Kučera
CC BY-SA 3.0
2017-07-02T06:49:13.320Z
2017-07-02T06:49:13.320Z
PaulHK
<p>I'm writing a raytracer and I'm using the assimp library to load objects. I have an object's material specified in a .mtl file:</p>

<pre><code>newmtl rightSphere
Ka 0.01 0.01 0.01
Kd 0.01 0.01 0.01
Ks 0.30 0.30 0.30
Tf 0.10 0.10 0.10
Ns 200
Ni 2.5
illum 7
</code></pre>

<p>and I'm trying to load this material. I've been mostly successful so far, for example I know that to extract the diffuse component (Kd), I can use</p>

<pre><code>aiMesh *mesh = scene-&gt;mMeshes[i];
aiMaterial *mat = scene-&gt;mMaterials[mesh-&gt;mMaterialIndex];
aiColor3D color;
mat-&gt;Get(AI_MATKEY_COLOR_DIFFUSE, color);
</code></pre>

<p>using the identifiers specified in <a href="http://assimp.sourceforge.net/lib_html/materials.html" rel="noreferrer">here</a>. However, I've been unable to extract the Tf component. I understand that this component defines the coefficient of refracted light per color channel, and I need this value along with the index of refraction (Ni) to get it to work.</p>

<p>My question is: how can I get the Tf value?</p>

<raytracing><material>
Loading a material via assimp
Michal Kučera
# Loading a material via assimp

(Asked by: username_0 on 2017-06-30)

I'm writing a raytracer and I'm using the assimp library to load objects. I have an object's material specified in a .mtl file:

```
newmtl rightSphere
Ka 0.01 0.01 0.01
Kd 0.01 0.01 0.01
Ks 0.30 0.30 0.30
Tf 0.10 0.10 0.10
Ns 200
Ni 2.5
illum 7

```

and I'm trying to load this material. I've been mostly successful so far, for example I know that to extract the diffuse component (Kd), I can use

```
aiMesh *mesh = scene->mMeshes[i];
aiMaterial *mat = scene->mMaterials[mesh->mMaterialIndex];
aiColor3D color;
mat->Get(AI_MATKEY_COLOR_DIFFUSE, color);

```

using the identifiers specified in [here](http://assimp.sourceforge.net/lib_html/materials.html). However, I've been unable to extract the Tf component. I understand that this component defines the coefficient of refracted light per color channel, and I need this value along with the index of refraction (Ni) to get it to work.

My question is: how can I get the Tf value?

**Tags:** raytracing, material


---

## 1 answers

### Answer by username_1 on 2017-07-02. Score: 2

AI\_MATKEY\_COLOR\_TRANSPARENT is used to define the transparent colour and AI\_MATKEY\_REFRACTI is the refractive index.

> **Comments:**
> **username_0**: That doesn't seem to work for me. In this [example](https://pastebin.com/dKC8xz4V), I tried to use these identifiers but with no success. I also added the source .mtl file and the code I was trying to run with the output for clarification.  
> **username_1**: Unfortunately I didn't test with a .mtl file, the information was from browsing the header files, the 2 macros I posted are the only references to those material parameters I could find so this could possibly be a incomplete feature in Assimp.  
> **username_0**: That might very well be the case. I tried to find some document specifying which parameters are supported and which aren't, but no luck so far. Would you know of any alternative way to define and load a material in an external file?  

---

