add setMaterialDepthWrite method

This commit is contained in:
Nick Fisher
2024-09-20 14:53:06 +08:00
parent fc3ca3d6b3
commit 43e5fd7766
5 changed files with 54 additions and 1 deletions

View File

@@ -2610,6 +2610,20 @@ EntityId SceneManager::createGeometry(
return instance;
}
void SceneManager::setMaterialDepthWrite(EntityId entityId, int materialIndex, bool enabled) {
auto entity = Entity::import(entityId);
const auto &rm = _engine->getRenderableManager();
auto renderableInstance = rm.getInstance(entity);
if (!renderableInstance.isValid())
{
Log("Error setting material property for entity %d: no renderable");
return;
}
auto materialInstance = rm.getMaterialInstanceAt(renderableInstance, materialIndex);
materialInstance->setDepthWrite(enabled);
}
} // namespace thermion_filament