mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 15:39:20 +02:00
Ordering them before the imports in the same file was not enough: a project header on line 1 can import a module several levels down whose global module fragment already pulled in the same standard header, and that include guard does not cross the module boundary. Putting them first means the guard is set before anything can import. Skips vendored single-header libraries and anything inside an #if.
61 lines
2.4 KiB
C++
61 lines
2.4 KiB
C++
#include <filesystem>
|
|
#include <string>
|
|
#include <vector>
|
|
#include "config.h"
|
|
|
|
#include "nvrenderer/nvrenderer.h"
|
|
#include "nvrendererbackend.h"
|
|
|
|
void MaConfig::Init(const std::filesystem::path& config_file) {
|
|
Init(YAML::LoadFile(config_file.generic_string()));
|
|
}
|
|
|
|
void MaConfig::Init(const YAML::Node& node) {
|
|
m_display.Init(node["display"]);
|
|
m_shadow.Init(node["shadows"]);
|
|
m_lighting.Init(node["lighting"]);
|
|
m_weight_lines = node["wire_diameter_lines"].as<float>(.01f);
|
|
m_weight_tractions = node["wire_diameter_tractions"].as<float>(.005f);
|
|
m_envmap_resolution = node["envmap_resolution"].as<int>(256);
|
|
m_cloud_texture = node["cloud_texture"].as<std::string>("textures/clouds/clear");
|
|
m_high_cloud_texture = node["high_cloud_texture"].as<std::string>("textures/clouds/clear");
|
|
}
|
|
|
|
void MaConfig::MaConfigDisplay::Init(const YAML::Node& node) {
|
|
m_hdr_configs[0].Init(node["hdr_config"]["sdr"]);
|
|
m_hdr_configs[0].m_tonemap_function = MaTonemapType::Default_Srgb;
|
|
m_hdr_configs[1].Init(node["hdr_config"]["hdr"]);
|
|
m_hdr_configs[1].m_tonemap_function = MaTonemapType::Linear_Rec2020;
|
|
m_adapter_index = node["adapter"].as<int>();
|
|
m_output_index = node["output"].as<int>();
|
|
m_disable_hdr = node["disable_hdr"].as<bool>(false);
|
|
}
|
|
|
|
MaConfig::MaConfigDisplay::MaConfigHDR MaConfig::MaConfigDisplay::GetHDRConfig()
|
|
const {
|
|
auto renderer = dynamic_cast<NvRenderer*>(GfxRenderer.get());
|
|
return GetHDRConfig(renderer ? renderer->GetBackend()->IsHDRDisplay()
|
|
: false);
|
|
}
|
|
|
|
void MaConfig::MaConfigDisplay::MaConfigHDR::Init(const YAML::Node& node) {
|
|
m_scene_exposure = node["pre_tonemap_exposure"].as<float>();
|
|
m_ui_nits = node["ui_nits"].as<float>();
|
|
m_scene_nits = node["scene_nits"].as<float>();
|
|
m_scene_gamma = node["scene_gamma"].as<float>();
|
|
}
|
|
|
|
void MaConfig::MaConfigShadow::Init(const YAML::Node& node) {
|
|
m_resolution = node["resolution"].as<int>();
|
|
m_cascade_distances = node["cascades"].as<std::vector<double>>();
|
|
}
|
|
|
|
void MaConfig::MaConfigLighting::Init(const YAML::Node& node) {
|
|
m_max_lights_per_scene = node["max_lights_per_scene"].as<int>(2048);
|
|
m_selfillum_multiplier = node["selfillum_factor"].as<float>(1.f);
|
|
m_freespot_multiplier = node["freespot_factor"].as<float>(10.f);
|
|
m_luminance_threshold = node["luminance_threshold"].as<float>(.01f);
|
|
m_min_luminance_ev = node["min_luminance_ev"].as<float>(-3.f);
|
|
m_max_luminance_ev = node["max_luminance_ev"].as<float>(3.f);
|
|
}
|