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

Method writeMaterial

Source/Falcor/Scene/SceneCache.cpp:697–725  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

695 }
696
697 void SceneCache::writeMaterial(OutputStream& stream, const ref<Material>& pMaterial)
698 {
699 // Write common fields.
700 stream.write((uint32_t)pMaterial->getType());
701 stream.write(pMaterial->mName);
702 stream.write(pMaterial->mHeader);
703 stream.write(pMaterial->mUpdates);
704 writeTransform(stream, pMaterial->mTextureTransform);
705
706 auto writeTextureSlot = [&stream, &pMaterial](Material::TextureSlot slot)
707 {
708 auto pTexture = pMaterial->getTexture(slot);
709 bool hasTexture = pTexture != nullptr;
710 stream.write(hasTexture);
711 if (hasTexture)
712 {
713 stream.write(pTexture->getSourcePath());
714 }
715 };
716
717 for (uint32_t slot = 0; slot < (uint32_t)Material::TextureSlot::Count; ++slot)
718 {
719 writeTextureSlot(Material::TextureSlot(slot));
720 }
721
722 // Write data in derived class.
723 if (auto pBasicMaterial = pMaterial->toBasicMaterial()) writeBasicMaterial(stream, pBasicMaterial);
724 else FALCOR_THROW("Unsupported material type");
725 }
726
727 void SceneCache::writeBasicMaterial(OutputStream& stream, const ref<BasicMaterial>& pMaterial)
728 {

Callers

nothing calls this directly

Calls 5

TextureSlotEnum · 0.85
toBasicMaterialMethod · 0.80
writeMethod · 0.45
getTypeMethod · 0.45
getTextureMethod · 0.45

Tested by

no test coverage detected