gltfio: use the new material name feature.

To see proof that this works, use gltf_viewer with -u and examine the
node hierarchy. You will now see the correct material names instead of
the ubershader names.
This commit is contained in:
Philip Rideout
2020-05-06 15:25:33 -07:00
parent 38b9cf4fe3
commit 072d17d64f
3 changed files with 4 additions and 5 deletions

View File

@@ -380,8 +380,7 @@ void SimpleViewer::updateUserInterface() {
rm.setCastShadows(instance, scaster);
size_t numPrims = rm.getPrimitiveCount(instance);
for (size_t prim = 0; prim < numPrims; ++prim) {
const Material* mat = rm.getMaterialInstanceAt(instance, prim)->getMaterial();
const char* mname = mat->getName();
const char* mname = rm.getMaterialInstanceAt(instance, prim)->getName();
if (mname) {
ImGui::Text("prim %zu: material %s", prim, mname);
} else {

View File

@@ -381,9 +381,9 @@ MaterialInstance* MaterialGenerator::createMaterialInstance(MaterialKey* config,
Material* mat = createMaterial(mEngine, *config, *uvmap, label);
mCache.emplace(std::make_pair(*config, mat));
mMaterials.push_back(mat);
return mat->createInstance();
return mat->createInstance(label);
}
return iter->second->createInstance();
return iter->second->createInstance(label);
}
} // anonymous namespace

View File

@@ -149,7 +149,7 @@ MaterialInstance* UbershaderLoader::createMaterialInstance(MaterialKey* config,
return hasTexture ? int(uvmap->at(srcIndex)) - 1 : -1;
};
Material* material = getMaterial(*config);
MaterialInstance* mi = material->createInstance();
MaterialInstance* mi = material->createInstance(label);
mi->setParameter("baseColorIndex",
getUvIndex(config->baseColorUV, config->hasBaseColorTexture));
mi->setParameter("normalIndex", getUvIndex(config->normalUV, config->hasNormalTexture));