| 460 | auto postProcessGroupsRoot = "postProcessGroups"; |
| 461 | |
| 462 | void ClientApplication::renderReload() { |
| 463 | auto assets = m_root->assets(); |
| 464 | auto renderer = Application::renderer(); |
| 465 | |
| 466 | auto loadEffectConfig = [&](String const& name) { |
| 467 | String path = strf("/rendering/effects/{}.config", name); |
| 468 | if (assets->assetExists(path)) { |
| 469 | StringMap<String> shaders; |
| 470 | auto config = assets->json(path); |
| 471 | auto shaderConfig = config.getObject("effectShaders"); |
| 472 | for (auto& entry : shaderConfig) { |
| 473 | if (entry.second.isType(Json::Type::String)) { |
| 474 | String shader = entry.second.toString(); |
| 475 | if (!shader.hasChar('\n')) { |
| 476 | auto shaderBytes = assets->bytes(AssetPath::relativeTo(path, shader)); |
| 477 | shader = std::string(shaderBytes->ptr(), shaderBytes->size()); |
| 478 | } |
| 479 | shaders[entry.first] = shader; |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | renderer->loadEffectConfig(name, config, shaders); |
| 484 | } else |
| 485 | Logger::warn("No rendering config found for renderer with id '{}'", renderer->rendererId()); |
| 486 | }; |
| 487 | |
| 488 | renderer->loadConfig(assets->json("/rendering/opengl.config")); |
| 489 | |
| 490 | loadEffectConfig("world"); |
| 491 | |
| 492 | // define post process groups and set them to be enabled/disabled based on config |
| 493 | |
| 494 | auto config = m_root->configuration(); |
| 495 | if (!config->get(postProcessGroupsRoot).isType(Json::Type::Object)) |
| 496 | config->set(postProcessGroupsRoot, JsonObject()); |
| 497 | auto groupsConfig = config->get(postProcessGroupsRoot); |
| 498 | |
| 499 | m_postProcessGroups.clear(); |
| 500 | auto postProcessGroups = assets->json("/client.config:postProcessGroups").toObject(); |
| 501 | for (auto& pair : postProcessGroups) { |
| 502 | auto name = pair.first; |
| 503 | auto groupConfig = groupsConfig.opt(name); |
| 504 | auto def = pair.second.getBool("enabledDefault",true); |
| 505 | if (!groupConfig) |
| 506 | config->setPath(strf("{}.{}", postProcessGroupsRoot, name),JsonObject()); |
| 507 | m_postProcessGroups.add(name,PostProcessGroup{ groupConfig ? groupConfig.value().getBool("enabled", def) : def }); |
| 508 | } |
| 509 | |
| 510 | // define post process layers and optionally assign them to groups |
| 511 | m_postProcessLayers.clear(); |
| 512 | m_labelledPostProcessLayers.clear(); |
| 513 | auto postProcessLayers = assets->json("/client.config:postProcessLayers").toArray(); |
| 514 | for (auto& layer : postProcessLayers) { |
| 515 | auto effects = jsonToStringList(layer.getArray("effects")); |
| 516 | for (auto& effect : effects) |
| 517 | loadEffectConfig(effect); |
| 518 | PostProcessGroup* group = nullptr; |
| 519 | auto gname = layer.optString("group"); |
nothing calls this directly
no test coverage detected