c++openglassimpwavefront

How is NormalTexture represented in the Wavefront resource material format?


I have integrated 'Assimp' librairy to load my OBJ/MTL files components.

All works correctly.

But let's have a focus on a following MTL file example:

# Blender MTL File: 'plane.blend'
# Material Count: 1

newmtl PlaneMtl
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2

map_Ka ambient_texture.jpg
map_Kd diffuse_texture.jpg
map_Ks specular_texture.jpg
map_Bump bump_texture.jpg

And let's examine the following code:

aiMesh *pMesh = scene->mMeshes[idz];
aiMaterial *pMaterial = scene->mMaterials[pMesh->mMaterialIndex];

aiString ambient_texture_path, diffuse_texture_path, specular_texture_path, bump_texture_path;
pMaterial->GetTexture(aiTextureType_AMBIENT, 0, &ambient_texture_path);
pMaterial->GetTexture(aiTextureType_DIFFUSE, 0, &diffuse_texture_path);
pMaterial->GetTexture(aiTextureType_SPECULAR, 0, &specular_texture_path);
pMaterial->GetTexture(aiTextureType_HEIGHT, 0, &bump_texture_path);

std::cout << "AmbientTexture: " << ambient_texture_path.C_Str() << std::endl;
std::cout << "DiffuseTexture: " << diffuse_texture_path.C_Str() << std::endl;
std::cout << "SpecularTexture: " << specular_texture_path.C_Str() << std::endl;
std::cout << "BumpTexture: " << bump_texture_path.C_Str() << std::endl;

Here's the output:

ambient_texture.jpg
diffuse_texture.jpg
specular_texture.jpg
bump_texture.jpg

As you can see all works perfectly and the keywords 'map_Ka, map_Kd, map_Ks and map_Bump' refer to ambient, diffuse, specular and bump (height) map respectively. So these keywords are correct.

But what about normal texture (for normal mapping) and displacement texture (for displacement mapping) for example ?

I tried to add the following lines in my MTL file to test:

map_Normal normal_texture.jpg
map_Disp disp_texture.jpg

using the code:

aiString normal_texture_path, displacement_texture_path;

pMaterial->GetTexture(aiTextureType_NORMALS, 0, &normal_texture_path);
pMaterial->GetTexture(aiTextureType_DISPLACEMENT, 0, &displacement_texture_path);

std::cout << "NormalTexture: " << normal_texture_path.C_Str() << std::endl;
std::cout << "DispTexture: " << displacement_texture_path.C_Str() << std::endl;

and the output:

NormalTexture:
DispTexture:

So the keyword 'map_Normal' and 'map_Disp' are not corrects and so are not part of Wavefront MTL documentation.

I couldn't try to find a correct and official documentation about WaveFront MTL format (only the ones on Wikipedia or tutorials nut nothing official and complete).

Does it exist an official documentation about Wavefront MTL and OBJ format with all the keywords explained within ?

If it's not the case does anyone knows the keywords for normal and displacement texture ?


Solution

  • Alias/Wavefront is now so old and passed through so many owning companies that I very much doubt you will find an 'official' specification anywhere.

    I suggest the excellent write-up by Paul Bourke, which includes the keywords details for bump and displacement maps. (But not normal maps - I don't think they were ever official for OBJ)

    http://paulbourke.net/dataformats/mtl/

    Hope this helps.