I was looking around on how to get the shininess (aka the specular coefficient, specular exponent) from a loaded model, when using the Assimp APIs (4.1.0). Unfortunately, nothing in the docs helped me and I had to look into some sample programs to get the answer. So, here’s how to do it:
// material index is the ID of the material you are interested in const aiMaterial* ai_material = scene.mMaterials[material_index]; float shininess; if(AI_SUCCESS != aiGetMaterialFloat(ai_material, AI_MATKEY_SHININESS, &shininess)) { // if unsuccessful set a default shininess = 20.f; }
Here’s an example to get some other property like specular color using Assimp’s structs.
aiColor4D spec_color; if(AI_SUCCESS != aiGetMaterialColor(ai_material, AI_MATKEY_COLOR_SPECULAR, &spec_color)) { spec_color = aiColor4D(1.f, 1.f, 1.f, 1.f); }
HTH