mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
chore: rewritten bloom effect as a json object inside C++ so it's easier to follow
This commit is contained in:
parent
16682fcb68
commit
d163220156
@ -84,82 +84,108 @@ void CWallpaperApplication::setupContainer (CCombinedContainer& container, const
|
||||
// add the effect file for screen bloom
|
||||
|
||||
// add some model for the image element even if it's going to waste rendering cycles
|
||||
virtualContainer->add ("effects/wpenginelinux/bloomeffect.json",
|
||||
"{"
|
||||
"\t\"name\":\"camerabloom_wpengine_linux\","
|
||||
"\t\"group\":\"wpengine_linux_camera\","
|
||||
"\t\"dependencies\":[],"
|
||||
"\t\"passes\":"
|
||||
"\t["
|
||||
"\t\t{"
|
||||
"\t\t\t\"material\": \"materials/util/downsample_quarter_bloom.json\","
|
||||
"\t\t\t\"target\": \"_rt_4FrameBuffer\","
|
||||
"\t\t\t\"bind\":"
|
||||
"\t\t\t["
|
||||
"\t\t\t\t{"
|
||||
"\t\t\t\t\t\"name\": \"_rt_FullFrameBuffer\","
|
||||
"\t\t\t\t\t\"index\": 0"
|
||||
"\t\t\t\t}"
|
||||
"\t\t\t]"
|
||||
"\t\t},"
|
||||
"\t\t{"
|
||||
"\t\t\t\"material\": \"materials/util/downsample_eighth_blur_v.json\","
|
||||
"\t\t\t\"target\": \"_rt_8FrameBuffer\","
|
||||
"\t\t\t\"bind\":"
|
||||
"\t\t\t["
|
||||
"\t\t\t\t{"
|
||||
"\t\t\t\t\t\"name\": \"_rt_4FrameBuffer\","
|
||||
"\t\t\t\t\t\"index\": 0"
|
||||
"\t\t\t\t}"
|
||||
"\t\t\t]"
|
||||
"\t\t},"
|
||||
"\t\t{"
|
||||
"\t\t\t\"material\": \"materials/util/blur_h_bloom.json\","
|
||||
"\t\t\t\"target\": \"_rt_Bloom\","
|
||||
"\t\t\t\"bind\":"
|
||||
"\t\t\t["
|
||||
"\t\t\t\t{"
|
||||
"\t\t\t\t\t\"name\": \"_rt_8FrameBuffer\","
|
||||
"\t\t\t\t\t\"index\": 0"
|
||||
"\t\t\t\t}"
|
||||
"\t\t\t]"
|
||||
"\t\t},"
|
||||
"\t\t{"
|
||||
"\t\t\t\"material\": \"materials/util/combine.json\","
|
||||
"\t\t\t\"target\": \"_rt_FullFrameBuffer\","
|
||||
"\t\t\t\"bind\":"
|
||||
"\t\t\t["
|
||||
"\t\t\t\t{"
|
||||
"\t\t\t\t\t\"name\": \"_rt_imageLayerComposite_-1_a\","
|
||||
"\t\t\t\t\t\"index\": 0"
|
||||
"\t\t\t\t},"
|
||||
"\t\t\t\t{"
|
||||
"\t\t\t\t\t\"name\": \"_rt_Bloom\","
|
||||
"\t\t\t\t\t\"index\": 1"
|
||||
"\t\t\t\t}"
|
||||
"\t\t\t]"
|
||||
"\t\t}"
|
||||
"\t]"
|
||||
"}");
|
||||
virtualContainer->add (
|
||||
"effects/wpenginelinux/bloomeffect.json",
|
||||
{
|
||||
{"name", "camerabloom_wpengine_linux"},
|
||||
{"group", "wpengine_linux_camera"},
|
||||
{"dependencies", json::array ()},
|
||||
{"passes",
|
||||
json::array (
|
||||
{
|
||||
{
|
||||
{"material", "materials/util/downsample_quarter_bloom.json"},
|
||||
{"target", "_rt_4FrameBuffer"},
|
||||
{
|
||||
"bind",
|
||||
json::array (
|
||||
{
|
||||
{
|
||||
{"name", "_rt_FullFrameBuffer"},
|
||||
{"index", 0}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
{"material", "materials/util/downsample_eighth_blur_v.json"},
|
||||
{"target", "_rt_8FrameBuffer"},
|
||||
{
|
||||
"bind",
|
||||
json::array (
|
||||
{
|
||||
{
|
||||
{"name", "_rt_4FrameBuffer"},
|
||||
{"index", 0}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
{"material", "materials/util/blur_h_bloom.json"},
|
||||
{"target", "_rt_Bloom"},
|
||||
{
|
||||
"bind",
|
||||
json::array (
|
||||
{
|
||||
{
|
||||
{"name", "_rt_8FrameBuffer"},
|
||||
{"index", 0}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
{"material", "materials/util/combine.json"},
|
||||
{"target", "_rt_FullFrameBuffer"},
|
||||
{
|
||||
"bind",
|
||||
json::array (
|
||||
{
|
||||
{
|
||||
{"name", "_rt_imageLayerComposite_-1_a"},
|
||||
{"index", 0}
|
||||
},
|
||||
{
|
||||
{"name", "_rt_Bloom"},
|
||||
{"index", 1}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
),
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
virtualContainer->add ("models/wpenginelinux.json", "{"
|
||||
"\t\"material\":\"materials/wpenginelinux.json\""
|
||||
"}");
|
||||
virtualContainer->add (
|
||||
"models/wpenginelinux.json",
|
||||
{
|
||||
{"material","materials/wpenginelinux.json"}
|
||||
}
|
||||
);
|
||||
|
||||
// models require materials, so add that too
|
||||
virtualContainer->add ("materials/wpenginelinux.json", "{"
|
||||
"\t\"passes\":"
|
||||
"\t\t["
|
||||
"\t\t\t{"
|
||||
"\t\t\t\t\"blending\": \"normal\","
|
||||
"\t\t\t\t\"cullmode\": \"nocull\","
|
||||
"\t\t\t\t\"depthtest\": \"disabled\","
|
||||
"\t\t\t\t\"depthwrite\": \"disabled\","
|
||||
"\t\t\t\t\"shader\": \"genericimage2\","
|
||||
"\t\t\t\t\"textures\": [\"_rt_FullFrameBuffer\"]"
|
||||
"\t\t\t}"
|
||||
"\t\t]"
|
||||
"}");
|
||||
virtualContainer->add(
|
||||
"materials/wpenginelinux.json",
|
||||
{
|
||||
{"passes", json::array (
|
||||
{
|
||||
{
|
||||
{"blending", "normal"},
|
||||
{"cullmode", "nocull"},
|
||||
{"depthtest", "disabled"},
|
||||
{"depthwrite", "disabled"},
|
||||
{"shader", "genericimage2"},
|
||||
{"textures", json::array ({"_rt_FullFrameBuffer"})}
|
||||
}
|
||||
}
|
||||
)}}
|
||||
);
|
||||
|
||||
container.add (virtualContainer);
|
||||
}
|
||||
|
@ -19,6 +19,10 @@ void CVirtualContainer::add (const std::filesystem::path& filename, const std::s
|
||||
this->add (filename, copy, contents.length () + 1);
|
||||
}
|
||||
|
||||
void CVirtualContainer::add (const std::filesystem::path& filename, const json& contents) {
|
||||
this->add (filename, contents.dump ());
|
||||
}
|
||||
|
||||
const uint8_t* CVirtualContainer::readFile (const std::filesystem::path& filename, uint32_t* length) const {
|
||||
const auto cur = this->m_virtualFiles.find (filename);
|
||||
|
||||
|
@ -5,8 +5,11 @@
|
||||
|
||||
#include "CContainer.h"
|
||||
#include "CFileEntry.h"
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
|
||||
namespace WallpaperEngine::Assets {
|
||||
using json = nlohmann::json;
|
||||
/**
|
||||
* Virtual container implementation, provides virtual files for the backgrounds to use
|
||||
*/
|
||||
@ -28,6 +31,13 @@ class CVirtualContainer final : public CContainer {
|
||||
* @param contents
|
||||
*/
|
||||
void add (const std::filesystem::path& filename, const std::string& contents);
|
||||
/**
|
||||
* Adds a new file to the virtual container from a json object
|
||||
* @param filename
|
||||
* @param contents
|
||||
*/
|
||||
void add (const std::filesystem::path& filename, const json& contents);
|
||||
|
||||
/** @inheritdoc */
|
||||
const uint8_t* readFile (const std::filesystem::path& filename, uint32_t* length) const override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user