chore: cleanup bloom effect code

This commit is contained in:
Almamu 2025-08-15 00:09:31 +02:00
parent aa44d88a2b
commit ace1282522

View File

@ -93,67 +93,64 @@ CScene::CScene (
// //
// TODO: TAKE THIS OUT OF HERE AND INTO THE GENERAL WALLPAPER APPLICATION?! // TODO: TAKE THIS OUT OF HERE AND INTO THE GENERAL WALLPAPER APPLICATION?!
const std::string imagejson = "{" const auto bloomOrigin = glm::vec3 { sceneWidth / 2, sceneHeight / 2, 0.0f };
"\t\"image\": \"models/wpenginelinux.json\"," const auto bloomSize = glm::vec2 { sceneWidth, sceneHeight };
"\t\"name\": \"bloomimagewpenginelinux\","
"\t\"visible\": true," const nlohmann::json bloom = {
"\t\"scale\": \"1.0 1.0 1.0\"," {"image", "models/wpenginelinux.json"},
"\t\"angles\": \"0.0 0.0 0.0\"," {"name", "bloomimagewpenginelinux"},
"\t\"origin\": \"" + {"visible", true},
std::to_string (sceneWidth / 2) + " " + std::to_string (sceneHeight / 2) + {"scale", "1.0 1.0 1.0"},
" 0.0\"," {"angles", "0.0 0.0 0.0"},
"\t\"id\": -1" + {"origin", std::to_string (bloomOrigin.x) + " " + std::to_string (bloomOrigin.y) + " " + std::to_string(bloomOrigin.z)},
"," {"size", std::to_string (bloomSize.x) + " " + std::to_string (bloomSize.y)},
"\t\"effects\":" {"id", -1},
"\t[" {"effects",
"\t\t{" json::array (
"\t\t\t\"file\": \"effects/wpenginelinux/bloomeffect.json\"," {
"\t\t\t\"id\": 15242000," {
"\t\t\t\"name\": \"\"," {"file", "effects/wpenginelinux/bloomeffect.json"},
"\t\t\t\"passes\":" {"id", 15242000},
"\t\t\t[" {"name", ""},
"\t\t\t\t{" {"passes",
"\t\t\t\t\t\"constantshadervalues\":" json::array (
"\t\t\t\t\t{" {
"\t\t\t\t\t\t\"bloomstrength\": " + {
std::to_string (this->getScene ().camera.bloom.strength->value->getFloat ()) + {"constantshadervalues",
"," {
"\t\t\t\t\t\t\"bloomthreshold\": " + {"bloomstrength", this->getScene ().camera.bloom.strength->value->getFloat ()},
std::to_string (this->getScene ().camera.bloom.threshold->value->getFloat ()) + {"bloomthreshold", this->getScene ().camera.bloom.threshold->value->getFloat ()}
"\t\t\t\t\t}" }
"\t\t\t\t}," }
"\t\t\t\t{" },
"\t\t\t\t\t\"constantshadervalues\":" {
"\t\t\t\t\t{" {"constantshadervalues",
"\t\t\t\t\t\t\"bloomstrength\": " + {
std::to_string (this->getScene ().camera.bloom.strength->value->getFloat ()) + {"bloomstrength", this->getScene ().camera.bloom.strength->value->getFloat ()},
"," {"bloomthreshold", this->getScene ().camera.bloom.threshold->value->getFloat ()}
"\t\t\t\t\t\t\"bloomthreshold\": " + }
std::to_string (this->getScene ().camera.bloom.threshold->value->getFloat ()) + }
"\t\t\t\t\t}" },
"\t\t\t\t}," {
"\t\t\t\t{" {"constantshadervalues",
"\t\t\t\t\t\"constantshadervalues\":" {
"\t\t\t\t\t{" {"bloomstrength", this->getScene ().camera.bloom.strength->value->getFloat ()},
"\t\t\t\t\t\t\"bloomstrength\": " + {"bloomthreshold", this->getScene ().camera.bloom.threshold->value->getFloat ()}
std::to_string (this->getScene ().camera.bloom.strength->value->getFloat ()) + }
"," }
"\t\t\t\t\t\t\"bloomthreshold\": " + }
std::to_string (this->getScene ().camera.bloom.strength->value->getFloat ()) + }
"\t\t\t\t\t}" )
"\t\t\t\t}" }
"\t\t\t]" }
"\t\t}" }
"\t]," )
"\t\"size\": \"" + }
std::to_string (sceneWidth) + " " + std::to_string (sceneHeight) + };
"\""
"}";
const auto json = nlohmann::json::parse (imagejson);
// create image for bloom passes // create image for bloom passes
if (scene->camera.bloom.enabled->value->getBool ()) { if (scene->camera.bloom.enabled->value->getBool ()) {
this->m_bloomObjectData = ObjectParser::parse (json, scene->project); this->m_bloomObjectData = ObjectParser::parse (bloom, scene->project);
this->m_bloomObject = this->createObject (*this->m_bloomObjectData); this->m_bloomObject = this->createObject (*this->m_bloomObjectData);
this->m_objectsByRenderOrder.push_back (this->m_bloomObject); this->m_objectsByRenderOrder.push_back (this->m_bloomObject);