| 270 | } |
| 271 | |
| 272 | void MaterialSystem::replaceMaterial(const MaterialID materialID, const ref<Material>& pReplacement) |
| 273 | { |
| 274 | FALCOR_CHECK(materialID.isValid() && materialID.get() < mMaterials.size(), "Material ID is invalid."); |
| 275 | FALCOR_CHECK(pReplacement != nullptr, "Replacement material is missing."); |
| 276 | |
| 277 | // Remove the previous material. |
| 278 | removeMaterial(materialID); |
| 279 | |
| 280 | // Prepare replacement material. |
| 281 | if (pReplacement->getDefaultTextureSampler() == nullptr) |
| 282 | { |
| 283 | pReplacement->setDefaultTextureSampler(mpDefaultTextureSampler); |
| 284 | } |
| 285 | pReplacement->registerUpdateCallback([this](auto flags) { mMaterialUpdates |= flags; }); |
| 286 | |
| 287 | // Replace the material. |
| 288 | mMaterials[materialID.get()] = pReplacement; |
| 289 | mMaterialsChanged = true; |
| 290 | } |
| 291 | |
| 292 | void MaterialSystem::replaceMaterial(const ref<Material>& pMaterial, const ref<Material>& pReplacement) |
| 293 | { |
nothing calls this directly
no test coverage detected