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 the effect file for screen bloom
|
||||||
|
|
||||||
// add some model for the image element even if it's going to waste rendering cycles
|
// add some model for the image element even if it's going to waste rendering cycles
|
||||||
virtualContainer->add ("effects/wpenginelinux/bloomeffect.json",
|
virtualContainer->add (
|
||||||
"{"
|
"effects/wpenginelinux/bloomeffect.json",
|
||||||
"\t\"name\":\"camerabloom_wpengine_linux\","
|
{
|
||||||
"\t\"group\":\"wpengine_linux_camera\","
|
{"name", "camerabloom_wpengine_linux"},
|
||||||
"\t\"dependencies\":[],"
|
{"group", "wpengine_linux_camera"},
|
||||||
"\t\"passes\":"
|
{"dependencies", json::array ()},
|
||||||
"\t["
|
{"passes",
|
||||||
"\t\t{"
|
json::array (
|
||||||
"\t\t\t\"material\": \"materials/util/downsample_quarter_bloom.json\","
|
{
|
||||||
"\t\t\t\"target\": \"_rt_4FrameBuffer\","
|
{
|
||||||
"\t\t\t\"bind\":"
|
{"material", "materials/util/downsample_quarter_bloom.json"},
|
||||||
"\t\t\t["
|
{"target", "_rt_4FrameBuffer"},
|
||||||
"\t\t\t\t{"
|
{
|
||||||
"\t\t\t\t\t\"name\": \"_rt_FullFrameBuffer\","
|
"bind",
|
||||||
"\t\t\t\t\t\"index\": 0"
|
json::array (
|
||||||
"\t\t\t\t}"
|
{
|
||||||
"\t\t\t]"
|
{
|
||||||
"\t\t},"
|
{"name", "_rt_FullFrameBuffer"},
|
||||||
"\t\t{"
|
{"index", 0}
|
||||||
"\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"
|
{"material", "materials/util/downsample_eighth_blur_v.json"},
|
||||||
"\t\t\t\t}"
|
{"target", "_rt_8FrameBuffer"},
|
||||||
"\t\t\t]"
|
{
|
||||||
"\t\t},"
|
"bind",
|
||||||
"\t\t{"
|
json::array (
|
||||||
"\t\t\t\"material\": \"materials/util/blur_h_bloom.json\","
|
{
|
||||||
"\t\t\t\"target\": \"_rt_Bloom\","
|
{
|
||||||
"\t\t\t\"bind\":"
|
{"name", "_rt_4FrameBuffer"},
|
||||||
"\t\t\t["
|
{"index", 0}
|
||||||
"\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{"
|
{"material", "materials/util/blur_h_bloom.json"},
|
||||||
"\t\t\t\"material\": \"materials/util/combine.json\","
|
{"target", "_rt_Bloom"},
|
||||||
"\t\t\t\"target\": \"_rt_FullFrameBuffer\","
|
{
|
||||||
"\t\t\t\"bind\":"
|
"bind",
|
||||||
"\t\t\t["
|
json::array (
|
||||||
"\t\t\t\t{"
|
{
|
||||||
"\t\t\t\t\t\"name\": \"_rt_imageLayerComposite_-1_a\","
|
{
|
||||||
"\t\t\t\t\t\"index\": 0"
|
{"name", "_rt_8FrameBuffer"},
|
||||||
"\t\t\t\t},"
|
{"index", 0}
|
||||||
"\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]"
|
{"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", "{"
|
virtualContainer->add (
|
||||||
"\t\"material\":\"materials/wpenginelinux.json\""
|
"models/wpenginelinux.json",
|
||||||
"}");
|
{
|
||||||
|
{"material","materials/wpenginelinux.json"}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// models require materials, so add that too
|
virtualContainer->add(
|
||||||
virtualContainer->add ("materials/wpenginelinux.json", "{"
|
"materials/wpenginelinux.json",
|
||||||
"\t\"passes\":"
|
{
|
||||||
"\t\t["
|
{"passes", json::array (
|
||||||
"\t\t\t{"
|
{
|
||||||
"\t\t\t\t\"blending\": \"normal\","
|
{
|
||||||
"\t\t\t\t\"cullmode\": \"nocull\","
|
{"blending", "normal"},
|
||||||
"\t\t\t\t\"depthtest\": \"disabled\","
|
{"cullmode", "nocull"},
|
||||||
"\t\t\t\t\"depthwrite\": \"disabled\","
|
{"depthtest", "disabled"},
|
||||||
"\t\t\t\t\"shader\": \"genericimage2\","
|
{"depthwrite", "disabled"},
|
||||||
"\t\t\t\t\"textures\": [\"_rt_FullFrameBuffer\"]"
|
{"shader", "genericimage2"},
|
||||||
"\t\t\t}"
|
{"textures", json::array ({"_rt_FullFrameBuffer"})}
|
||||||
"\t\t]"
|
}
|
||||||
"}");
|
}
|
||||||
|
)}}
|
||||||
|
);
|
||||||
|
|
||||||
container.add (virtualContainer);
|
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);
|
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 uint8_t* CVirtualContainer::readFile (const std::filesystem::path& filename, uint32_t* length) const {
|
||||||
const auto cur = this->m_virtualFiles.find (filename);
|
const auto cur = this->m_virtualFiles.find (filename);
|
||||||
|
|
||||||
|
@ -5,8 +5,11 @@
|
|||||||
|
|
||||||
#include "CContainer.h"
|
#include "CContainer.h"
|
||||||
#include "CFileEntry.h"
|
#include "CFileEntry.h"
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace WallpaperEngine::Assets {
|
namespace WallpaperEngine::Assets {
|
||||||
|
using json = nlohmann::json;
|
||||||
/**
|
/**
|
||||||
* Virtual container implementation, provides virtual files for the backgrounds to use
|
* Virtual container implementation, provides virtual files for the backgrounds to use
|
||||||
*/
|
*/
|
||||||
@ -28,6 +31,13 @@ class CVirtualContainer final : public CContainer {
|
|||||||
* @param contents
|
* @param contents
|
||||||
*/
|
*/
|
||||||
void add (const std::filesystem::path& filename, const std::string& 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 */
|
/** @inheritdoc */
|
||||||
const uint8_t* readFile (const std::filesystem::path& filename, uint32_t* length) const override;
|
const uint8_t* readFile (const std::filesystem::path& filename, uint32_t* length) const override;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user