MCPcopy Create free account
hub / github.com/KTStephano/StratusGFX / ProcessMaterial

Function ProcessMaterial

Source/Engine/StratusResourceManager.cpp:432–552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430 }
431
432 static void ProcessMaterial(
433 const aiScene* scene,
434 const aiMesh* mesh,
435 MaterialPtr material,
436 const std::string& directory,
437 const std::string& extension,
438 const ColorSpace& cspace) {
439
440 if (mesh->mMaterialIndex >= 0) {
441 aiMaterial* aimat = scene->mMaterials[mesh->mMaterialIndex];
442
443 aiString matName;
444 aimat->Get<aiString>(AI_MATKEY_NAME, matName);
445 STRATUS_LOG << "Loading Mesh Material [" << material->GetName() << "]" << std::endl;
446 // PrintMatType(aimat, aiTextureType_DIFFUSE);
447 // PrintMatType(aimat, aiTextureType_SPECULAR);
448 // PrintMatType(aimat, aiTextureType_AMBIENT);
449 // PrintMatType(aimat, aiTextureType_EMISSIVE);
450 // PrintMatType(aimat, aiTextureType_HEIGHT);
451 // PrintMatType(aimat, aiTextureType_NORMALS);
452 // PrintMatType(aimat, aiTextureType_OPACITY);
453 // PrintMatType(aimat, aiTextureType_BASE_COLOR);
454 // PrintMatType(aimat, aiTextureType_NORMAL_CAMERA);
455 // PrintMatType(aimat, aiTextureType_EMISSION_COLOR);
456 // PrintMatType(aimat, aiTextureType_METALNESS);
457 // PrintMatType(aimat, aiTextureType_AMBIENT_OCCLUSION);
458 // PrintMatType(aimat, aiTextureType_DIFFUSE_ROUGHNESS);
459 // PrintMatType(aimat, aiTextureType_SHEEN);
460 // PrintMatType(aimat, aiTextureType_CLEARCOAT);
461 // PrintMatType(aimat, aiTextureType_TRANSMISSION);
462 // PrintMatType(aimat, aiTextureType_UNKNOWN);
463
464 aiColor4D diffuse;
465 aiColor4D reflective;
466 aiColor4D specular;
467 aiColor4D emissive;
468 float metallic;
469 float roughness;
470 float opacity;
471 float specularFactor;
472 unsigned int max = 1;
473 aiColor4D transparency;
474
475 if (aiGetMaterialFloat(aimat, AI_MATKEY_METALLIC_FACTOR, &metallic) == AI_SUCCESS) {
476 material->SetMetallic(metallic);
477 //STRATUS_LOG << "M: " << metallic << std::endl;
478 }
479 if (aiGetMaterialFloat(aimat, AI_MATKEY_ROUGHNESS_FACTOR, &roughness) == AI_SUCCESS) {
480 material->SetRoughness(roughness);
481 }
482
483 if (aiGetMaterialColor(aimat, AI_MATKEY_COLOR_DIFFUSE, &diffuse) == AI_SUCCESS) {
484 material->SetDiffuseColor(glm::vec4(diffuse.r, diffuse.g, diffuse.b, std::clamp(diffuse.a, 0.0f, 1.0f)));
485 }
486 if (aiGetMaterialColor(aimat, AI_MATKEY_COLOR_EMISSIVE, &emissive) == AI_SUCCESS) {
487 material->SetEmissiveColor(glm::vec3(emissive.r, emissive.g, emissive.b));
488 }
489 else {

Callers 1

ProcessNodeFunction · 0.85

Calls 13

LoadMaterialTextureFunction · 0.85
GetNameMethod · 0.80
SetMetallicMethod · 0.80
SetRoughnessMethod · 0.80
SetDiffuseColorMethod · 0.80
SetEmissiveColorMethod · 0.80
SetReflectanceMethod · 0.80
SetDiffuseMapMethod · 0.80
SetNormalMapMethod · 0.80
SetRoughnessMapMethod · 0.80
SetEmissiveMapMethod · 0.80
SetMetallicMapMethod · 0.80

Tested by

no test coverage detected