| 350 | } |
| 351 | |
| 352 | FALCOR_SCRIPT_BINDING(Material) |
| 353 | { |
| 354 | using namespace pybind11::literals; |
| 355 | |
| 356 | FALCOR_SCRIPT_BINDING_DEPENDENCY(Transform) |
| 357 | FALCOR_SCRIPT_BINDING_DEPENDENCY(Texture) |
| 358 | |
| 359 | pybind11::enum_<MaterialType> materialType(m, "MaterialType"); |
| 360 | materialType.value("Standard", MaterialType::Standard); |
| 361 | materialType.value("Cloth", MaterialType::Cloth); |
| 362 | materialType.value("Hair", MaterialType::Hair); |
| 363 | materialType.value("MERL", MaterialType::MERL); |
| 364 | materialType.value("MERLMix", MaterialType::MERLMix); |
| 365 | materialType.value("PBRTDiffuse", MaterialType::PBRTDiffuse); |
| 366 | materialType.value("PBRTDiffuseTransmission", MaterialType::PBRTDiffuseTransmission); |
| 367 | materialType.value("PBRTConductor", MaterialType::PBRTConductor); |
| 368 | materialType.value("PBRTDielectric", MaterialType::PBRTDielectric); |
| 369 | materialType.value("PBRTCoatedConductor", MaterialType::PBRTCoatedConductor); |
| 370 | materialType.value("PBRTCoatedDiffuse", MaterialType::PBRTCoatedDiffuse); |
| 371 | materialType.value("RGL", MaterialType::RGL); |
| 372 | |
| 373 | pybind11::enum_<AlphaMode> alphaMode(m, "AlphaMode"); |
| 374 | alphaMode.value("Opaque", AlphaMode::Opaque); |
| 375 | alphaMode.value("Mask", AlphaMode::Mask); |
| 376 | |
| 377 | pybind11::enum_<Material::TextureSlot> textureSlot(m, "MaterialTextureSlot"); |
| 378 | textureSlot.value("BaseColor", Material::TextureSlot::BaseColor); |
| 379 | textureSlot.value("Specular", Material::TextureSlot::Specular); |
| 380 | textureSlot.value("Emissive", Material::TextureSlot::Emissive); |
| 381 | textureSlot.value("Normal", Material::TextureSlot::Normal); |
| 382 | textureSlot.value("Transmission", Material::TextureSlot::Transmission); |
| 383 | textureSlot.value("Displacement", Material::TextureSlot::Displacement); |
| 384 | textureSlot.value("Index", Material::TextureSlot::Index); |
| 385 | |
| 386 | // Register Material base class as IMaterial in python to allow deprecated script syntax. |
| 387 | // TODO: Remove workaround when all scripts have been updated to create derived Material classes. |
| 388 | pybind11::class_<Material, ref<Material>> material(m, "IMaterial"); // PYTHONDEPRECATED |
| 389 | material.def_property_readonly("type", &Material::getType); |
| 390 | material.def_property("name", &Material::getName, &Material::setName); |
| 391 | material.def_property("doubleSided", &Material::isDoubleSided, &Material::setDoubleSided); |
| 392 | material.def_property("thinSurface", &Material::isThinSurface, &Material::setThinSurface); |
| 393 | material.def_property_readonly("emissive", &Material::isEmissive); |
| 394 | material.def_property("alphaMode", &Material::getAlphaMode, &Material::setAlphaMode); |
| 395 | material.def_property("alphaThreshold", &Material::getAlphaThreshold, &Material::setAlphaThreshold); |
| 396 | material.def_property("nestedPriority", &Material::getNestedPriority, &Material::setNestedPriority); |
| 397 | material.def_property("textureTransform", pybind11::overload_cast<>(&Material::getTextureTransform, pybind11::const_), &Material::setTextureTransform); |
| 398 | |
| 399 | material.def("setTexture", &Material::setTexture, "slot"_a, "texture"_a); |
| 400 | material.def("getTexture", &Material::getTexture, "slot"_a); |
| 401 | auto loadTexture = [&](Material& self, Material::TextureSlot slot, const std::filesystem::path& path, bool useSrgb) { |
| 402 | return self.loadTexture(slot, getActiveAssetResolver().resolvePath(path), useSrgb); |
| 403 | }; |
| 404 | material.def("loadTexture", loadTexture, "slot"_a, "path"_a, "useSrgb"_a = true); // PYTHONDEPRECATED |
| 405 | material.def("load_texture", loadTexture, "slot"_a, "path"_a, "use_srgb"_a = true); // PYTHONDEPRECATED |
| 406 | material.def("clearTexture", &Material::clearTexture, "slot"_a); |
| 407 | material.def("setRoughnessMollification", &Material::setRoughnessMollification, "value"_a); |
| 408 | |
| 409 | auto getMaterialParamLayoutDict = [&](MaterialType type) -> pybind11::dict { |
nothing calls this directly
no test coverage detected