MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / addMaterial

Method addMaterial

Source/Falcor/Scene/Material/MaterialSystem.cpp:224–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222 }
223
224 MaterialID MaterialSystem::addMaterial(const ref<Material>& pMaterial)
225 {
226 FALCOR_CHECK(pMaterial != nullptr, "'pMaterial' is missing");
227
228 // Reuse previously added materials.
229 if (auto it = std::find(mMaterials.begin(), mMaterials.end(), pMaterial); it != mMaterials.end())
230 {
231 return MaterialID{(size_t)std::distance(mMaterials.begin(), it) };
232 }
233
234 // Add material.
235 if (mMaterials.size() >= std::numeric_limits<uint32_t>::max())
236 {
237 FALCOR_THROW("Too many materials");
238 }
239 const MaterialID materialID{ mMaterials.size() };
240
241 if (pMaterial->getDefaultTextureSampler() == nullptr)
242 {
243 pMaterial->setDefaultTextureSampler(mpDefaultTextureSampler);
244 }
245
246 pMaterial->registerUpdateCallback([this](auto flags) { mMaterialUpdates |= flags; });
247 mMaterials.push_back(pMaterial);
248 mMaterialsChanged = true;
249
250 return materialID;
251 }
252
253 void MaterialSystem::removeMaterial(const MaterialID materialID)
254 {

Callers 2

computeAlbedoLUTMethod · 0.45
computeAlbedoLUTMethod · 0.45

Calls 7

findFunction · 0.85
maxFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected