mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
Compare commits
8 Commits
2569960681
...
2eefc7ff64
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2eefc7ff64 | ||
![]() |
303a2b5624 | ||
![]() |
04c85bebe4 | ||
![]() |
1a3f789cee | ||
![]() |
ace1282522 | ||
![]() |
aa44d88a2b | ||
![]() |
958c97f791 | ||
![]() |
e5355d0013 |
2
src/External/glslang-WallpaperEngine
vendored
2
src/External/glslang-WallpaperEngine
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 077d4f3c89bbfbb7951a9011d4551b075f092334
|
Subproject commit 9fba00b655d79ef2fe6f05b459571bd3b1f119ea
|
@ -284,7 +284,7 @@ std::unique_ptr<CTexture::TextureHeader> CTexture::parseHeader (const char* file
|
|||||||
header->freeImageFormat = static_cast<FreeImageFormat> (*pointer++);
|
header->freeImageFormat = static_cast<FreeImageFormat> (*pointer++);
|
||||||
header->isVideoMp4 = *pointer++ == 1;
|
header->isVideoMp4 = *pointer++ == 1;
|
||||||
|
|
||||||
if (header->freeImageFormat == FIF_UNKNOWN) {
|
if (header->freeImageFormat == FIF_UNKNOWN && header->isVideoMp4) {
|
||||||
header->freeImageFormat = FIF_MP4;
|
header->freeImageFormat = FIF_MP4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,6 +412,8 @@ std::shared_ptr<CTexture::TextureMipmap> CTexture::parseMipmap (const TextureHea
|
|||||||
fileData ++;
|
fileData ++;
|
||||||
|
|
||||||
pointer = reinterpret_cast<const uint32_t*> (fileData);
|
pointer = reinterpret_cast<const uint32_t*> (fileData);
|
||||||
|
// this is another param to ignore
|
||||||
|
pointer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
mipmap->width = *pointer++;
|
mipmap->width = *pointer++;
|
||||||
|
@ -19,6 +19,7 @@ void CDynamicValue::update(float newValue) {
|
|||||||
this->m_float = newValue;
|
this->m_float = newValue;
|
||||||
this->m_int = static_cast<int> (newValue);
|
this->m_int = static_cast<int> (newValue);
|
||||||
this->m_bool = static_cast<int> (newValue) != 0;
|
this->m_bool = static_cast<int> (newValue) != 0;
|
||||||
|
this->m_type = UnderlyingType::Float;
|
||||||
|
|
||||||
this->propagate ();
|
this->propagate ();
|
||||||
}
|
}
|
||||||
@ -33,6 +34,7 @@ void CDynamicValue::update(int newValue) {
|
|||||||
this->m_float = static_cast<float> (newValue);
|
this->m_float = static_cast<float> (newValue);
|
||||||
this->m_int = newValue;
|
this->m_int = newValue;
|
||||||
this->m_bool = newValue != 0;
|
this->m_bool = newValue != 0;
|
||||||
|
this->m_type = UnderlyingType::Int;
|
||||||
|
|
||||||
this->propagate ();
|
this->propagate ();
|
||||||
}
|
}
|
||||||
@ -47,6 +49,7 @@ void CDynamicValue::update(bool newValue) {
|
|||||||
this->m_float = newValue;
|
this->m_float = newValue;
|
||||||
this->m_int = newValue;
|
this->m_int = newValue;
|
||||||
this->m_bool = newValue;
|
this->m_bool = newValue;
|
||||||
|
this->m_type = UnderlyingType::Boolean;
|
||||||
|
|
||||||
this->propagate ();
|
this->propagate ();
|
||||||
}
|
}
|
||||||
@ -61,6 +64,7 @@ void CDynamicValue::update(const glm::vec2& newValue) {
|
|||||||
this->m_float = newValue.x;
|
this->m_float = newValue.x;
|
||||||
this->m_int = static_cast<int> (newValue.x);
|
this->m_int = static_cast<int> (newValue.x);
|
||||||
this->m_bool = newValue.x != 0.0f;
|
this->m_bool = newValue.x != 0.0f;
|
||||||
|
this->m_type = UnderlyingType::Vec2;
|
||||||
|
|
||||||
this->propagate ();
|
this->propagate ();
|
||||||
}
|
}
|
||||||
@ -75,6 +79,7 @@ void CDynamicValue::update(const glm::vec3& newValue) {
|
|||||||
this->m_float = newValue.x;
|
this->m_float = newValue.x;
|
||||||
this->m_int = static_cast<int> (newValue.x);
|
this->m_int = static_cast<int> (newValue.x);
|
||||||
this->m_bool = newValue.x != 0.0f;
|
this->m_bool = newValue.x != 0.0f;
|
||||||
|
this->m_type = UnderlyingType::Vec3;
|
||||||
|
|
||||||
this->propagate ();
|
this->propagate ();
|
||||||
}
|
}
|
||||||
@ -89,6 +94,7 @@ void CDynamicValue::update(const glm::vec4& newValue) {
|
|||||||
this->m_float = newValue.x;
|
this->m_float = newValue.x;
|
||||||
this->m_int = static_cast<int> (newValue.x);
|
this->m_int = static_cast<int> (newValue.x);
|
||||||
this->m_bool = newValue.x != 0.0f;
|
this->m_bool = newValue.x != 0.0f;
|
||||||
|
this->m_type = UnderlyingType::Vec4;
|
||||||
|
|
||||||
this->propagate ();
|
this->propagate ();
|
||||||
}
|
}
|
||||||
@ -103,6 +109,7 @@ void CDynamicValue::update(const glm::ivec2& newValue) {
|
|||||||
this->m_float = static_cast<float> (newValue.x);
|
this->m_float = static_cast<float> (newValue.x);
|
||||||
this->m_int = static_cast<int> (newValue.x);
|
this->m_int = static_cast<int> (newValue.x);
|
||||||
this->m_bool = newValue.x != 0;
|
this->m_bool = newValue.x != 0;
|
||||||
|
this->m_type = UnderlyingType::IVec2;
|
||||||
|
|
||||||
this->propagate ();
|
this->propagate ();
|
||||||
}
|
}
|
||||||
@ -117,6 +124,7 @@ void CDynamicValue::update(const glm::ivec3& newValue) {
|
|||||||
this->m_float = static_cast<float> (newValue.x);
|
this->m_float = static_cast<float> (newValue.x);
|
||||||
this->m_int = static_cast<int> (newValue.x);
|
this->m_int = static_cast<int> (newValue.x);
|
||||||
this->m_bool = newValue.x != 0;
|
this->m_bool = newValue.x != 0;
|
||||||
|
this->m_type = UnderlyingType::IVec3;
|
||||||
|
|
||||||
this->propagate ();
|
this->propagate ();
|
||||||
}
|
}
|
||||||
@ -131,6 +139,7 @@ void CDynamicValue::update(const glm::ivec4& newValue) {
|
|||||||
this->m_float = static_cast<float> (newValue.x);
|
this->m_float = static_cast<float> (newValue.x);
|
||||||
this->m_int = static_cast<int> (newValue.x);
|
this->m_int = static_cast<int> (newValue.x);
|
||||||
this->m_bool = newValue.x != 0;
|
this->m_bool = newValue.x != 0;
|
||||||
|
this->m_type = UnderlyingType::IVec4;
|
||||||
|
|
||||||
this->propagate ();
|
this->propagate ();
|
||||||
}
|
}
|
||||||
@ -202,4 +211,8 @@ const int& CDynamicValue::getInt () const {
|
|||||||
|
|
||||||
const bool& CDynamicValue::getBool () const {
|
const bool& CDynamicValue::getBool () const {
|
||||||
return this->m_bool;
|
return this->m_bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
CDynamicValue::UnderlyingType CDynamicValue::getType () const {
|
||||||
|
return this->m_type;
|
||||||
}
|
}
|
@ -19,6 +19,19 @@ class CDynamicValue {
|
|||||||
friend class WallpaperEngine::Data::Parsers::UserSettingParser;
|
friend class WallpaperEngine::Data::Parsers::UserSettingParser;
|
||||||
friend class WallpaperEngine::Data::Builders::UserSettingBuilder;
|
friend class WallpaperEngine::Data::Builders::UserSettingBuilder;
|
||||||
public:
|
public:
|
||||||
|
enum UnderlyingType {
|
||||||
|
Unknown = -1,
|
||||||
|
IVec4 = 0,
|
||||||
|
IVec3 = 1,
|
||||||
|
IVec2 = 2,
|
||||||
|
Vec4 = 3,
|
||||||
|
Vec3 = 4,
|
||||||
|
Vec2 = 5,
|
||||||
|
Float = 6,
|
||||||
|
Int = 7,
|
||||||
|
Boolean = 8
|
||||||
|
};
|
||||||
|
|
||||||
virtual ~CDynamicValue ();
|
virtual ~CDynamicValue ();
|
||||||
|
|
||||||
[[nodiscard]] const glm::ivec4& getIVec4 () const;
|
[[nodiscard]] const glm::ivec4& getIVec4 () const;
|
||||||
@ -30,6 +43,7 @@ class CDynamicValue {
|
|||||||
[[nodiscard]] const float& getFloat () const;
|
[[nodiscard]] const float& getFloat () const;
|
||||||
[[nodiscard]] const int& getInt () const;
|
[[nodiscard]] const int& getInt () const;
|
||||||
[[nodiscard]] const bool& getBool () const;
|
[[nodiscard]] const bool& getBool () const;
|
||||||
|
[[nodiscard]] UnderlyingType getType () const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connects the current instance to the given instance, updating it's values
|
* Connects the current instance to the given instance, updating it's values
|
||||||
@ -38,8 +52,6 @@ class CDynamicValue {
|
|||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
void connectOutgoing (CDynamicValue* value) const;
|
void connectOutgoing (CDynamicValue* value) const;
|
||||||
|
|
||||||
protected:
|
|
||||||
void update (float newValue);
|
void update (float newValue);
|
||||||
void update (int newValue);
|
void update (int newValue);
|
||||||
void update (bool newValue);
|
void update (bool newValue);
|
||||||
@ -49,6 +61,8 @@ class CDynamicValue {
|
|||||||
void update (const glm::ivec2& newValue);
|
void update (const glm::ivec2& newValue);
|
||||||
void update (const glm::ivec3& newValue);
|
void update (const glm::ivec3& newValue);
|
||||||
void update (const glm::ivec4& newValue);
|
void update (const glm::ivec4& newValue);
|
||||||
|
|
||||||
|
protected:
|
||||||
/**
|
/**
|
||||||
* Registers an incoming connection (another CDynamicValue affecting the current instance's value)
|
* Registers an incoming connection (another CDynamicValue affecting the current instance's value)
|
||||||
* Useful mainly for destroying the connection on delete
|
* Useful mainly for destroying the connection on delete
|
||||||
@ -65,6 +79,7 @@ class CDynamicValue {
|
|||||||
private:
|
private:
|
||||||
mutable std::vector<CDynamicValue*> m_outgoingConnections = {};
|
mutable std::vector<CDynamicValue*> m_outgoingConnections = {};
|
||||||
mutable std::vector<const CDynamicValue*> m_incomingConnections = {};
|
mutable std::vector<const CDynamicValue*> m_incomingConnections = {};
|
||||||
|
UnderlyingType m_type = UnderlyingType::Unknown;
|
||||||
// different values that we will be casted to automagically
|
// different values that we will be casted to automagically
|
||||||
glm::ivec4 m_ivec4 = {};
|
glm::ivec4 m_ivec4 = {};
|
||||||
glm::ivec3 m_ivec3 = {};
|
glm::ivec3 m_ivec3 = {};
|
||||||
|
@ -24,9 +24,11 @@ std::shared_ptr<CProperty> CProperty::fromJSON (const json& data, const std::str
|
|||||||
if (*type == "text")
|
if (*type == "text")
|
||||||
return CPropertyText::fromJSON (data, name);
|
return CPropertyText::fromJSON (data, name);
|
||||||
|
|
||||||
// show the error and ignore this property
|
if (*type != "group") {
|
||||||
sLog.error ("Unexpected type for property: ", *type);
|
// show the error and ignore this property
|
||||||
sLog.error (data);
|
sLog.error ("Unexpected type for property: ", *type);
|
||||||
|
sLog.error (data);
|
||||||
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ EffectUniquePtr EffectParser::load (Project& project, const std::string& filenam
|
|||||||
|
|
||||||
EffectUniquePtr EffectParser::parse (const JSON& it, Project& project) {
|
EffectUniquePtr EffectParser::parse (const JSON& it, Project& project) {
|
||||||
const auto dependencies = it.optional ("dependencies");
|
const auto dependencies = it.optional ("dependencies");
|
||||||
|
const auto fbos = it.optional ("fbos");
|
||||||
|
|
||||||
return std::make_unique <Effect> (Effect {
|
return std::make_unique <Effect> (Effect {
|
||||||
.name = it.optional <std::string> ("name", ""),
|
.name = it.optional <std::string> ("name", ""),
|
||||||
@ -24,6 +25,7 @@ EffectUniquePtr EffectParser::parse (const JSON& it, Project& project) {
|
|||||||
.preview = it.optional <std::string> ("preview", ""),
|
.preview = it.optional <std::string> ("preview", ""),
|
||||||
.dependencies = dependencies.has_value () ? parseDependencies (*dependencies) : std::vector <std::string> {},
|
.dependencies = dependencies.has_value () ? parseDependencies (*dependencies) : std::vector <std::string> {},
|
||||||
.passes = parseEffectPasses (it.require ("passes", "Effect file must have passes"), project),
|
.passes = parseEffectPasses (it.require ("passes", "Effect file must have passes"), project),
|
||||||
|
.fbos = fbos.has_value () ? parseFBOs (*fbos) : std::vector <FBOUniquePtr> {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +51,7 @@ std::vector <EffectPassUniquePtr> EffectParser::parseEffectPasses (const JSON& i
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& cur : it) {
|
for (const auto& cur : it) {
|
||||||
const auto binds = cur.optional ("binds");
|
const auto binds = cur.optional ("bind");
|
||||||
std::optional <PassCommand> command = std::nullopt;
|
std::optional <PassCommand> command = std::nullopt;
|
||||||
|
|
||||||
if (cur.contains ("command")) {
|
if (cur.contains ("command")) {
|
||||||
@ -91,5 +93,23 @@ std::map <int, std::string> EffectParser::parseBinds (const JSON& it) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector <FBOUniquePtr> EffectParser::parseFBOs (const JSON& it) {
|
||||||
|
std::vector <FBOUniquePtr> result = {};
|
||||||
|
|
||||||
|
if (!it.is_array ()) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& cur : it) {
|
||||||
|
result.push_back(std::make_unique<FBO>(FBO {
|
||||||
|
.name = cur.require <std::string> ("name", "FBO must have a name"),
|
||||||
|
.format = cur.optional <std::string> ("format", "rgba8888"),
|
||||||
|
.scale = cur.optional ("scale", 1.0f),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
@ -16,5 +16,6 @@ class EffectParser {
|
|||||||
static std::vector <std::string> parseDependencies (const JSON& it);
|
static std::vector <std::string> parseDependencies (const JSON& it);
|
||||||
static std::vector <EffectPassUniquePtr> parseEffectPasses (const JSON& it, Project& project);
|
static std::vector <EffectPassUniquePtr> parseEffectPasses (const JSON& it, Project& project);
|
||||||
static std::map <int, std::string> parseBinds (const JSON& it);
|
static std::map <int, std::string> parseBinds (const JSON& it);
|
||||||
|
static std::vector <FBOUniquePtr> parseFBOs (const JSON& it);
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Data::Parsers
|
} // namespace WallpaperEngine::Data::Parsers
|
||||||
|
@ -60,7 +60,7 @@ std::map <int, std::string> MaterialParser::parseTextures (const JSON& it) {
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
for (const auto& cur : it) {
|
for (const auto& cur : it) {
|
||||||
if (!it.is_null ()) {
|
if (!cur.is_null ()) {
|
||||||
result.emplace (index, cur);
|
result.emplace (index, cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ ImageUniquePtr ObjectParser::parseImage (
|
|||||||
const auto& properties = project.properties;
|
const auto& properties = project.properties;
|
||||||
const auto& effects = it.optional ("effects");
|
const auto& effects = it.optional ("effects");
|
||||||
|
|
||||||
return std::make_unique <Image> (
|
auto result = std::make_unique <Image> (
|
||||||
std::move (base),
|
std::move (base),
|
||||||
ImageData {
|
ImageData {
|
||||||
.origin = it.user ("origin", properties, glm::vec3 (0.0f)),
|
.origin = it.user ("origin", properties, glm::vec3 (0.0f)),
|
||||||
@ -86,7 +86,7 @@ ImageUniquePtr ObjectParser::parseImage (
|
|||||||
.angles = it.user ("angles", properties, glm::vec3 (0.0)),
|
.angles = it.user ("angles", properties, glm::vec3 (0.0)),
|
||||||
.visible = it.user ("visible", properties, true),
|
.visible = it.user ("visible", properties, true),
|
||||||
.alpha = it.user ("alpha", properties, 1.0f),
|
.alpha = it.user ("alpha", properties, 1.0f),
|
||||||
.color = it.user ("color", properties, glm::vec3 (1.0f)),
|
.color = it.user ("color", properties, glm::vec4 (1.0f)),
|
||||||
.alignment = it.optional ("alignment", std::string ("center")),
|
.alignment = it.optional ("alignment", std::string ("center")),
|
||||||
.size = it.optional ("size", glm::vec2 (0.0f)),
|
.size = it.optional ("size", glm::vec2 (0.0f)),
|
||||||
.parallaxDepth = it.optional ("parallaxDepth", glm::vec2 (0.0f)),
|
.parallaxDepth = it.optional ("parallaxDepth", glm::vec2 (0.0f)),
|
||||||
@ -96,6 +96,15 @@ ImageUniquePtr ObjectParser::parseImage (
|
|||||||
.effects = effects.has_value () ? parseEffects (*effects, project) : std::vector <ImageEffectUniquePtr> {},
|
.effects = effects.has_value () ? parseEffects (*effects, project) : std::vector <ImageEffectUniquePtr> {},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// color should be a vec4 for alpha, but it's read as vec3
|
||||||
|
if (result->color->value->getType () == DynamicValue::UnderlyingType::Vec3) {
|
||||||
|
result->color->value->update (glm::vec4 (result->color->value->getVec3 (), 1.0f));
|
||||||
|
} else if (result->color->value->getType () == DynamicValue::UnderlyingType::IVec3) {
|
||||||
|
result->color->value->update (glm::vec4 (result->color->value->getIVec3 (), 255));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector <ImageEffectUniquePtr> ObjectParser::parseEffects (const JSON& it, Project& project) {
|
std::vector <ImageEffectUniquePtr> ObjectParser::parseEffects (const JSON& it, Project& project) {
|
||||||
@ -115,8 +124,8 @@ std::vector <ImageEffectUniquePtr> ObjectParser::parseEffects (const JSON& it, P
|
|||||||
ImageEffectUniquePtr ObjectParser::parseEffect (const JSON& it, Project& project) {
|
ImageEffectUniquePtr ObjectParser::parseEffect (const JSON& it, Project& project) {
|
||||||
const auto& passsOverrides = it.optional ("passes");
|
const auto& passsOverrides = it.optional ("passes");
|
||||||
return std::make_unique <ImageEffect> (ImageEffect {
|
return std::make_unique <ImageEffect> (ImageEffect {
|
||||||
.id = it.require <int> ("id", "Image effect must have an id"),
|
.id = it.optional <int> ("id", -1),
|
||||||
.name = it.require <std::string> ("name", "Image effect must have a name"),
|
.name = it.optional <std::string> ("name", "Effect without name"),
|
||||||
.visible = it.user ("visible", project.properties, true),
|
.visible = it.user ("visible", project.properties, true),
|
||||||
.passOverrides = passsOverrides.has_value () ? parseEffectPassOverrides (passsOverrides.value (), project) : std::vector <ImageEffectPassOverrideUniquePtr> {},
|
.passOverrides = passsOverrides.has_value () ? parseEffectPassOverrides (passsOverrides.value (), project) : std::vector <ImageEffectPassOverrideUniquePtr> {},
|
||||||
.effect = EffectParser::load (project, it.require ("file", "Image effect must have an effect"))
|
.effect = EffectParser::load (project, it.require ("file", "Image effect must have an effect"))
|
||||||
@ -163,10 +172,10 @@ TextureMap ObjectParser::parseTextureMap (const JSON& it) {
|
|||||||
textureIndex ++;
|
textureIndex ++;
|
||||||
|
|
||||||
if (cur.is_null ()) {
|
if (cur.is_null ()) {
|
||||||
continue;
|
result.emplace (textureIndex, "");
|
||||||
|
} else {
|
||||||
|
result.emplace (textureIndex, cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
result.emplace (textureIndex, cur);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -22,7 +22,7 @@ ProjectUniquePtr ProjectParser::parse (const JSON& data, ContainerUniquePtr cont
|
|||||||
.title = data.require <std::string> ("title", "Project title missing"),
|
.title = data.require <std::string> ("title", "Project title missing"),
|
||||||
.type = parseType (type),
|
.type = parseType (type),
|
||||||
.workshopId = data.optional ("workshopid", std::to_string (--backgroundId)),
|
.workshopId = data.optional ("workshopid", std::to_string (--backgroundId)),
|
||||||
.supportsAudioProcessing = general.has_value () && general.value ().optional ("supportsAudioProcessing", false),
|
.supportsAudioProcessing = general.has_value () && general.value ().optional ("supportsaudioprocessing", false),
|
||||||
.properties = parseProperties (general),
|
.properties = parseProperties (general),
|
||||||
.container = std::move(container),
|
.container = std::move(container),
|
||||||
});
|
});
|
||||||
@ -63,6 +63,11 @@ Properties ProjectParser::parseProperties (const std::optional <JSON>& data) {
|
|||||||
for (const auto& cur : properties.value ().items ()) {
|
for (const auto& cur : properties.value ().items ()) {
|
||||||
const auto& property = Property::fromJSON (cur.value (), cur.key ());
|
const auto& property = Property::fromJSON (cur.value (), cur.key ());
|
||||||
|
|
||||||
|
// ignore properties that failed, these are generally groups
|
||||||
|
if (property == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
result.emplace (property->getName (), property);
|
result.emplace (property->getName (), property);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ CPass::CPass (
|
|||||||
m_blendingmode (pass.blending),
|
m_blendingmode (pass.blending),
|
||||||
m_binds (binds.has_value () ? binds.value ().get () : DEFAULT_BINDS),
|
m_binds (binds.has_value () ? binds.value ().get () : DEFAULT_BINDS),
|
||||||
m_override (override.has_value () ? override.value ().get () : DEFAULT_OVERRIDE),
|
m_override (override.has_value () ? override.value ().get () : DEFAULT_OVERRIDE),
|
||||||
m_fboProvider (fboProvider),
|
m_fboProvider (std::move(fboProvider)),
|
||||||
m_target (target) {
|
m_target (target) {
|
||||||
this->setupShaders ();
|
this->setupShaders ();
|
||||||
this->setupShaderVariables ();
|
this->setupShaderVariables ();
|
||||||
@ -425,8 +425,8 @@ void CPass::setupShaders () {
|
|||||||
// TODO: USED TO BUILD THE TEXTURES LATER
|
// TODO: USED TO BUILD THE TEXTURES LATER
|
||||||
// use the combos copied from the pass so it includes the texture format
|
// use the combos copied from the pass so it includes the texture format
|
||||||
this->m_shader = new Render::Shaders::CShader (
|
this->m_shader = new Render::Shaders::CShader (
|
||||||
this->m_image.getContainer (), this->m_pass.shader, this->m_combos,
|
this->m_image.getContainer (), this->m_pass.shader, this->m_combos, this->m_override.combos,
|
||||||
this->m_pass.textures, this->m_override.constants
|
this->m_pass.textures, this->m_override.textures, this->m_override.constants
|
||||||
);
|
);
|
||||||
|
|
||||||
const auto shaders = Shaders::CGLSLContext::get ().toGlsl (
|
const auto shaders = Shaders::CGLSLContext::get ().toGlsl (
|
||||||
@ -502,16 +502,11 @@ void CPass::setupTextureUniforms () {
|
|||||||
// and then try with fragment's and override any existing
|
// and then try with fragment's and override any existing
|
||||||
for (const auto& [index, textureName] : this->m_shader->getVertex ().getTextures ()) {
|
for (const auto& [index, textureName] : this->m_shader->getVertex ().getTextures ()) {
|
||||||
try {
|
try {
|
||||||
// resolve the texture first
|
|
||||||
std::shared_ptr<const ITexture> textureRef;
|
|
||||||
|
|
||||||
if (textureName.find ("_rt_") == 0 || textureName.find ("_alias_") == 0) {
|
if (textureName.find ("_rt_") == 0 || textureName.find ("_alias_") == 0) {
|
||||||
textureRef = this->resolveFBO (textureName);
|
this->m_textures [index] = this->resolveFBO (textureName);
|
||||||
} else {
|
} else if(!textureName.empty ()) {
|
||||||
textureRef = this->getContext ().resolveTexture (textureName);
|
this->m_textures [index] = this->getContext ().resolveTexture (textureName);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->m_textures [index] = textureRef;
|
|
||||||
} catch (std::runtime_error& ex) {
|
} catch (std::runtime_error& ex) {
|
||||||
sLog.error ("Cannot resolve texture ", textureName, " for fragment shader ", ex.what ());
|
sLog.error ("Cannot resolve texture ", textureName, " for fragment shader ", ex.what ());
|
||||||
}
|
}
|
||||||
@ -519,16 +514,11 @@ void CPass::setupTextureUniforms () {
|
|||||||
|
|
||||||
for (const auto& [index, textureName] : this->m_shader->getFragment ().getTextures ()) {
|
for (const auto& [index, textureName] : this->m_shader->getFragment ().getTextures ()) {
|
||||||
try {
|
try {
|
||||||
// resolve the texture first
|
|
||||||
std::shared_ptr<const ITexture> textureRef;
|
|
||||||
|
|
||||||
if (textureName.find ("_rt_") == 0 || textureName.find ("_alias_") == 0) {
|
if (textureName.find ("_rt_") == 0 || textureName.find ("_alias_") == 0) {
|
||||||
textureRef = this->resolveFBO (textureName);
|
this->m_textures [index] = this->resolveFBO (textureName);
|
||||||
} else {
|
} else if(!textureName.empty ()) {
|
||||||
textureRef = this->getContext ().resolveTexture (textureName);
|
this->m_textures [index] = this->getContext ().resolveTexture (textureName);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->m_textures [index] = textureRef;
|
|
||||||
} catch (std::runtime_error& ex) {
|
} catch (std::runtime_error& ex) {
|
||||||
sLog.error ("Cannot resolve texture ", textureName, " for fragment shader ", ex.what ());
|
sLog.error ("Cannot resolve texture ", textureName, " for fragment shader ", ex.what ());
|
||||||
}
|
}
|
||||||
@ -540,10 +530,31 @@ void CPass::setupTextureUniforms () {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textureName.find ("_rt_") == 0) {
|
try {
|
||||||
this->m_textures[index] = this->resolveFBO (textureName);
|
if (textureName.find ("_rt_") == 0 || textureName.find ("_alias_") == 0) {
|
||||||
} else if (!textureName.empty ()) {
|
this->m_textures [index] = this->resolveFBO (textureName);
|
||||||
this->m_textures[index] = this->m_image.getContext ().resolveTexture (textureName);
|
} else if (!textureName.empty ()) {
|
||||||
|
this->m_textures [index] = this->getContext ().resolveTexture (textureName);
|
||||||
|
}
|
||||||
|
} catch (std::runtime_error& ex) {
|
||||||
|
sLog.error ("Cannot resolve texture ", textureName, " for pass ", ex.what ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// override any texture
|
||||||
|
for (const auto& [index, textureName] : this->m_override.textures) {
|
||||||
|
if (index == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (textureName.find ("_rt_") == 0 || textureName.find ("_alias_") == 0) {
|
||||||
|
this->m_textures [index] = this->resolveFBO (textureName);
|
||||||
|
} else if (!textureName.empty ()) {
|
||||||
|
this->m_textures [index] = this->getContext ().resolveTexture (textureName);
|
||||||
|
}
|
||||||
|
} catch (std::runtime_error& ex) {
|
||||||
|
sLog.error ("Cannot resolve texture ", textureName, " for override ", ex.what ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -552,7 +563,7 @@ void CPass::setupTextureUniforms () {
|
|||||||
if (bind == "previous") {
|
if (bind == "previous") {
|
||||||
// use nullptr as indication for "previous" texture
|
// use nullptr as indication for "previous" texture
|
||||||
this->m_textures [index] = nullptr;
|
this->m_textures [index] = nullptr;
|
||||||
} else {
|
} else if(!bind.empty ()) {
|
||||||
// a normal bind, search for the corresponding FBO and set it
|
// a normal bind, search for the corresponding FBO and set it
|
||||||
this->m_textures [index] = this->resolveFBO (bind);
|
this->m_textures [index] = this->resolveFBO (bind);
|
||||||
}
|
}
|
||||||
@ -597,7 +608,7 @@ void CPass::setupUniforms () {
|
|||||||
this->addUniform ("g_UserAlpha", image.alpha->value->getFloat ());
|
this->addUniform ("g_UserAlpha", image.alpha->value->getFloat ());
|
||||||
this->addUniform ("g_Alpha", image.alpha->value->getFloat ());
|
this->addUniform ("g_Alpha", image.alpha->value->getFloat ());
|
||||||
this->addUniform ("g_Color", image.color->value->getVec3 ());
|
this->addUniform ("g_Color", image.color->value->getVec3 ());
|
||||||
this->addUniform ("g_Color4", image.color->value->getVec4());
|
this->addUniform ("g_Color4", image.color->value->getVec4 ());
|
||||||
// TODO: VALIDATE THAT G_COMPOSITECOLOR REALLY COMES FROM THIS ONE
|
// TODO: VALIDATE THAT G_COMPOSITECOLOR REALLY COMES FROM THIS ONE
|
||||||
this->addUniform ("g_CompositeColor", image.color->value->getVec3 ());
|
this->addUniform ("g_CompositeColor", image.color->value->getVec3 ());
|
||||||
// add some external variables
|
// add some external variables
|
||||||
|
@ -19,18 +19,21 @@ using namespace WallpaperEngine::Assets;
|
|||||||
namespace WallpaperEngine::Render::Shaders {
|
namespace WallpaperEngine::Render::Shaders {
|
||||||
CShader::CShader (
|
CShader::CShader (
|
||||||
const CContainer& container, std::string filename,
|
const CContainer& container, std::string filename,
|
||||||
const ComboMap& combos, const TextureMap& textures,
|
const ComboMap& combos, const ComboMap& overrideCombos,
|
||||||
|
const TextureMap& textures, const TextureMap& overrideTextures,
|
||||||
const ShaderConstantMap& constants
|
const ShaderConstantMap& constants
|
||||||
) :
|
) :
|
||||||
m_file (std::move (filename)),
|
m_file (std::move (filename)),
|
||||||
m_combos (combos),
|
m_combos (combos),
|
||||||
|
m_overrideCombos (overrideCombos),
|
||||||
m_passTextures (textures),
|
m_passTextures (textures),
|
||||||
|
m_overrideTextures (overrideTextures),
|
||||||
m_vertex (
|
m_vertex (
|
||||||
CGLSLContext::UnitType_Vertex, filename, container.readVertexShader (filename),
|
CGLSLContext::UnitType_Vertex, filename, container.readVertexShader (filename),
|
||||||
container, constants, textures, combos),
|
container, constants, textures, overrideTextures, combos, overrideCombos),
|
||||||
m_fragment (
|
m_fragment (
|
||||||
CGLSLContext::UnitType_Fragment, filename, container.readFragmentShader (filename),
|
CGLSLContext::UnitType_Fragment, filename, container.readFragmentShader (filename),
|
||||||
container, constants, textures, combos) {
|
container, constants, textures, overrideTextures, combos, overrideCombos) {
|
||||||
// link shaders between them
|
// link shaders between them
|
||||||
this->m_vertex.linkToUnit (&this->m_fragment);
|
this->m_vertex.linkToUnit (&this->m_fragment);
|
||||||
this->m_fragment.linkToUnit (&this->m_vertex);
|
this->m_fragment.linkToUnit (&this->m_vertex);
|
||||||
|
@ -46,7 +46,8 @@ class CShader {
|
|||||||
*/
|
*/
|
||||||
CShader (
|
CShader (
|
||||||
const CContainer& container, std::string filename,
|
const CContainer& container, std::string filename,
|
||||||
const ComboMap& combos, const TextureMap& textures,
|
const ComboMap& combos, const ComboMap& overrideCombos,
|
||||||
|
const TextureMap& textures, const TextureMap& overrideTextures,
|
||||||
const ShaderConstantMap& constants);
|
const ShaderConstantMap& constants);
|
||||||
/**
|
/**
|
||||||
* @return The vertex's shader coude for OpenGL to use
|
* @return The vertex's shader coude for OpenGL to use
|
||||||
@ -97,9 +98,17 @@ class CShader {
|
|||||||
* The combos the shader should be generated with
|
* The combos the shader should be generated with
|
||||||
*/
|
*/
|
||||||
const ComboMap& m_combos;
|
const ComboMap& m_combos;
|
||||||
|
/**
|
||||||
|
* The overriden combos
|
||||||
|
*/
|
||||||
|
const ComboMap& m_overrideCombos;
|
||||||
/**
|
/**
|
||||||
* The list of textures the pass knows about
|
* The list of textures the pass knows about
|
||||||
*/
|
*/
|
||||||
const TextureMap m_passTextures;
|
const TextureMap m_passTextures;
|
||||||
|
/**
|
||||||
|
* The list of the override textures
|
||||||
|
*/
|
||||||
|
const TextureMap& m_overrideTextures;
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Render::Shaders
|
} // namespace WallpaperEngine::Render::Shaders
|
||||||
|
@ -57,7 +57,8 @@ using namespace WallpaperEngine::Render::Shaders;
|
|||||||
|
|
||||||
CShaderUnit::CShaderUnit (
|
CShaderUnit::CShaderUnit (
|
||||||
CGLSLContext::UnitType type, std::string file, std::string content, const CContainer& container,
|
CGLSLContext::UnitType type, std::string file, std::string content, const CContainer& container,
|
||||||
const ShaderConstantMap& constants, const TextureMap& passTextures, const ComboMap& combos
|
const ShaderConstantMap& constants, const TextureMap& passTextures, const TextureMap& overrideTextures,
|
||||||
|
const ComboMap& combos, const ComboMap& overrideCombos
|
||||||
) :
|
) :
|
||||||
m_type (type),
|
m_type (type),
|
||||||
m_link (nullptr),
|
m_link (nullptr),
|
||||||
@ -66,7 +67,9 @@ CShaderUnit::CShaderUnit (
|
|||||||
m_constants (constants),
|
m_constants (constants),
|
||||||
m_content (std::move(content)),
|
m_content (std::move(content)),
|
||||||
m_passTextures (passTextures),
|
m_passTextures (passTextures),
|
||||||
|
m_overrideTextures (overrideTextures),
|
||||||
m_combos (combos),
|
m_combos (combos),
|
||||||
|
m_overrideCombos (overrideCombos),
|
||||||
m_discoveredCombos (),
|
m_discoveredCombos (),
|
||||||
m_usedCombos () {
|
m_usedCombos () {
|
||||||
// pre-process the shader so the units are clear
|
// pre-process the shader so the units are clear
|
||||||
@ -333,14 +336,14 @@ void CShaderUnit::parseComboConfiguration (const std::string& content, int defau
|
|||||||
|
|
||||||
// check the combos
|
// check the combos
|
||||||
const auto entry = this->m_combos.find (combo->get<std::string> ());
|
const auto entry = this->m_combos.find (combo->get<std::string> ());
|
||||||
|
const auto entryOverride = this->m_overrideCombos.find (combo->get<std::string> ());
|
||||||
|
|
||||||
// add the combo to the found list
|
// add the combo to the found list
|
||||||
this->m_usedCombos.emplace (*combo, true);
|
this->m_usedCombos.emplace (*combo, true);
|
||||||
|
|
||||||
// if the combo was not found in the predefined values this means that the default value in the JSON data can be
|
// if the combo was not found in the predefined values this means that the default value in the JSON data can be
|
||||||
// used so only define the ones that are not already defined
|
// used so only define the ones that are not already defined
|
||||||
if (entry == this->m_combos.end ()) {
|
if (entry == this->m_combos.end () && entryOverride == this->m_overrideCombos.end ()) {
|
||||||
|
|
||||||
// if no combo is defined just load the default settings
|
// if no combo is defined just load the default settings
|
||||||
if (defvalue == data.end ()) {
|
if (defvalue == data.end ()) {
|
||||||
// TODO: PROPERLY SUPPORT EMPTY COMBOS
|
// TODO: PROPERLY SUPPORT EMPTY COMBOS
|
||||||
@ -404,20 +407,28 @@ void CShaderUnit::parseParameterConfiguration (
|
|||||||
// samplers can have special requirements, check what sampler we're working with and create definitions
|
// samplers can have special requirements, check what sampler we're working with and create definitions
|
||||||
// if needed
|
// if needed
|
||||||
const auto textureName = data.find ("default");
|
const auto textureName = data.find ("default");
|
||||||
|
// TODO: CREATE TEXTURE WITH THE GIVEN COLOR
|
||||||
|
const auto paintDefaultColor = data.find ("paintdefaultcolor");
|
||||||
// extract the texture number from the name
|
// extract the texture number from the name
|
||||||
const char value = name.at (std::string ("g_Texture").length ());
|
const char value = name.at (std::string ("g_Texture").length ());
|
||||||
const auto requireany = data.find ("requireany");
|
const auto requireany = data.find ("requireany");
|
||||||
const auto require = data.find ("require");
|
const auto require = data.find ("require");
|
||||||
// now convert it to integer
|
// now convert it to integer
|
||||||
|
// TODO: BETTER CONVERSION HERE
|
||||||
size_t index = value - '0';
|
size_t index = value - '0';
|
||||||
|
|
||||||
|
if (combo != data.end () && paintDefaultColor != data.end () && combo->get <std::string> () == "MASK" && this->m_file.find ("water")) {
|
||||||
|
sLog.debug("mask defaultcolor!");
|
||||||
|
}
|
||||||
|
|
||||||
if (combo != data.end ()) {
|
if (combo != data.end ()) {
|
||||||
|
// TODO: CLEANUP HOW THIS IS DETERMINED FIRST
|
||||||
// if the texture exists (and is not null), add to the combo
|
// if the texture exists (and is not null), add to the combo
|
||||||
auto texture = this->m_passTextures.find (index);
|
auto textureSlotUsed = this->m_passTextures.find (index) != this->m_passTextures.end () || this->m_overrideTextures.find (index) != this->m_overrideTextures.end ();
|
||||||
bool isRequired = false;
|
bool isRequired = false;
|
||||||
int comboValue = 1;
|
int comboValue = 1;
|
||||||
|
|
||||||
if (texture != this->m_passTextures.end ()) {
|
if (textureSlotUsed) {
|
||||||
// nothing extra to do, the texture exists, the combo must be set
|
// nothing extra to do, the texture exists, the combo must be set
|
||||||
// these tend to not have default value
|
// these tend to not have default value
|
||||||
isRequired = true;
|
isRequired = true;
|
||||||
@ -428,9 +439,10 @@ void CShaderUnit::parseParameterConfiguration (
|
|||||||
for (const auto& item : require->items ()) {
|
for (const auto& item : require->items ()) {
|
||||||
const std::string& macro = item.key ();
|
const std::string& macro = item.key ();
|
||||||
const auto it = this->m_combos.find (macro);
|
const auto it = this->m_combos.find (macro);
|
||||||
|
const auto itOverride = this->m_overrideCombos.find (macro);
|
||||||
|
|
||||||
// if any of the values matched, this option is required
|
// if any of the values matched, this option is required
|
||||||
if (it == this->m_combos.end () || it->second != item.value ()) {
|
if (it == this->m_combos.end () || itOverride != this->m_overrideCombos.end () || it->second != item.value ()) {
|
||||||
isRequired = true;
|
isRequired = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -442,9 +454,10 @@ void CShaderUnit::parseParameterConfiguration (
|
|||||||
for (const auto& item : require->items ()) {
|
for (const auto& item : require->items ()) {
|
||||||
const std::string& macro = item.key ();
|
const std::string& macro = item.key ();
|
||||||
const auto it = this->m_combos.find (macro);
|
const auto it = this->m_combos.find (macro);
|
||||||
|
const auto itOverride = this->m_overrideCombos.find (macro);
|
||||||
|
|
||||||
// these can not exist and that'd be fine, we just care about the values
|
// these can not exist and that'd be fine, we just care about the values
|
||||||
if (it != this->m_combos.end () && it->second == item.value ()) {
|
if ((it != this->m_combos.end () || itOverride != this->m_overrideCombos.end ()) && it->second == item.value ()) {
|
||||||
isRequired = false;
|
isRequired = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -452,16 +465,17 @@ void CShaderUnit::parseParameterConfiguration (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRequired && texture == this->m_passTextures.end ()) {
|
if (isRequired && !textureSlotUsed) {
|
||||||
if (defvalue == data.end ()) {
|
if (defvalue == data.end ()) {
|
||||||
isRequired = false;
|
isRequired = false;
|
||||||
} else {
|
} else {
|
||||||
// is the combo registered already?
|
// is the combo registered already?
|
||||||
// if not, add it with the default value
|
// if not, add it with the default value
|
||||||
const auto combo_it = this->m_combos.find (*combo);
|
const auto combo_it = this->m_combos.find (*combo);
|
||||||
|
const auto overridencombo_it = this->m_overrideCombos.find (*combo);
|
||||||
|
|
||||||
// there's already a combo providing this value, so it doesn't need to be added
|
// there's already a combo providing this value, so it doesn't need to be added
|
||||||
if (combo_it != this->m_combos.end ()) {
|
if (combo_it != this->m_combos.end () || overridencombo_it != this->m_overrideCombos.end ()) {
|
||||||
isRequired = false;
|
isRequired = false;
|
||||||
// otherwise a default value must be used
|
// otherwise a default value must be used
|
||||||
} else if (defvalue->is_string ()) {
|
} else if (defvalue->is_string ()) {
|
||||||
@ -531,27 +545,42 @@ const std::string& CShaderUnit::compile () {
|
|||||||
|
|
||||||
std::map<std::string, bool> addedCombos;
|
std::map<std::string, bool> addedCombos;
|
||||||
|
|
||||||
|
for (const auto& combo : this->m_overrideCombos) {
|
||||||
|
if (addedCombos.find (combo.first) == addedCombos.end ()) {
|
||||||
|
this->m_final += DEFINE_COMBO (combo.first, combo.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
addedCombos.emplace (combo.first, true);
|
||||||
|
}
|
||||||
// now add all the combos to the source
|
// now add all the combos to the source
|
||||||
for (const auto& combo : this->m_combos) {
|
for (const auto& combo : this->m_combos) {
|
||||||
if (addedCombos.find (combo.first) == addedCombos.end ()) {
|
if (addedCombos.find (combo.first) == addedCombos.end ()) {
|
||||||
this->m_final += DEFINE_COMBO (combo.first, combo.second);
|
this->m_final += DEFINE_COMBO (combo.first, combo.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addedCombos.emplace (combo.first, true);
|
||||||
}
|
}
|
||||||
for (const auto& combo : this->m_discoveredCombos) {
|
for (const auto& combo : this->m_discoveredCombos) {
|
||||||
if (addedCombos.find (combo.first) == addedCombos.end ()) {
|
if (addedCombos.find (combo.first) == addedCombos.end ()) {
|
||||||
this->m_final += DEFINE_COMBO (combo.first, combo.second);
|
this->m_final += DEFINE_COMBO (combo.first, combo.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addedCombos.emplace (combo.first, true);
|
||||||
}
|
}
|
||||||
if (this->m_link != nullptr) {
|
if (this->m_link != nullptr) {
|
||||||
for (const auto& combo : this->m_link->getCombos ()) {
|
for (const auto& combo : this->m_link->getCombos ()) {
|
||||||
if (addedCombos.find (combo.first) == addedCombos.end ()) {
|
if (addedCombos.find (combo.first) == addedCombos.end ()) {
|
||||||
this->m_final += DEFINE_COMBO (combo.first, combo.second);
|
this->m_final += DEFINE_COMBO (combo.first, combo.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addedCombos.emplace (combo.first, true);
|
||||||
}
|
}
|
||||||
for (const auto& combo : this->m_link->getDiscoveredCombos ()) {
|
for (const auto& combo : this->m_link->getDiscoveredCombos ()) {
|
||||||
if (addedCombos.find (combo.first) == addedCombos.end ()) {
|
if (addedCombos.find (combo.first) == addedCombos.end ()) {
|
||||||
this->m_final += DEFINE_COMBO (combo.first, combo.second);
|
this->m_final += DEFINE_COMBO (combo.first, combo.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addedCombos.emplace (combo.first, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class CShaderUnit {
|
|||||||
CShaderUnit (
|
CShaderUnit (
|
||||||
CGLSLContext::UnitType type, std::string file, std::string content, const CContainer& container,
|
CGLSLContext::UnitType type, std::string file, std::string content, const CContainer& container,
|
||||||
const ShaderConstantMap& constants, const TextureMap& passTextures,
|
const ShaderConstantMap& constants, const TextureMap& passTextures,
|
||||||
const ComboMap& combos);
|
const TextureMap& overrideTextures, const ComboMap& combos, const ComboMap& overrideCombos);
|
||||||
~CShaderUnit () = default;
|
~CShaderUnit () = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,6 +132,10 @@ class CShaderUnit {
|
|||||||
* Pre-defined values for the combos
|
* Pre-defined values for the combos
|
||||||
*/
|
*/
|
||||||
const ComboMap& m_combos;
|
const ComboMap& m_combos;
|
||||||
|
/**
|
||||||
|
* Pre-defined overriden values for the combos
|
||||||
|
*/
|
||||||
|
const ComboMap& m_overrideCombos;
|
||||||
/**
|
/**
|
||||||
* The combos discovered in the pre-processing step that were not in the combos list
|
* The combos discovered in the pre-processing step that were not in the combos list
|
||||||
*/
|
*/
|
||||||
@ -145,7 +149,9 @@ class CShaderUnit {
|
|||||||
*/
|
*/
|
||||||
const ShaderConstantMap& m_constants;
|
const ShaderConstantMap& m_constants;
|
||||||
/** The textures that are already applied to this shader */
|
/** The textures that are already applied to this shader */
|
||||||
const TextureMap m_passTextures = {};
|
const TextureMap& m_passTextures;
|
||||||
|
/** The textures that are being overridden */
|
||||||
|
const TextureMap& m_overrideTextures;
|
||||||
/** The default textures to use when a texture is not applied in a given slot */
|
/** The default textures to use when a texture is not applied in a given slot */
|
||||||
TextureMap m_defaultTextures = {};
|
TextureMap m_defaultTextures = {};
|
||||||
/**
|
/**
|
||||||
|
@ -46,6 +46,14 @@ CScene::CScene (
|
|||||||
// setup framebuffers here as they're required for the scene setup
|
// setup framebuffers here as they're required for the scene setup
|
||||||
this->setupFramebuffers ();
|
this->setupFramebuffers ();
|
||||||
|
|
||||||
|
const uint32_t sceneWidth = this->m_camera->getWidth ();
|
||||||
|
const uint32_t sceneHeight = this->m_camera->getHeight ();
|
||||||
|
|
||||||
|
this->_rt_shadowAtlas =
|
||||||
|
this->create ("_rt_shadowAtlas", ITexture::TextureFormat::ARGB8888, ITexture::TextureFlags::ClampUVs, 1.0,
|
||||||
|
{sceneWidth, sceneHeight}, {sceneWidth, sceneHeight});
|
||||||
|
this->alias ("_alias_lightCookie", "_rt_shadowAtlas");
|
||||||
|
|
||||||
// set clear color
|
// set clear color
|
||||||
// TODO: MAKE USE OF THE REFERENCE POSSIBILITIES?!
|
// TODO: MAKE USE OF THE REFERENCE POSSIBILITIES?!
|
||||||
const glm::vec3 clearColor = scene->colors.clear->value->getVec3 ();
|
const glm::vec3 clearColor = scene->colors.clear->value->getVec3 ();
|
||||||
@ -67,9 +75,6 @@ CScene::CScene (
|
|||||||
this->m_objectsByRenderOrder.emplace_back (obj->second);
|
this->m_objectsByRenderOrder.emplace_back (obj->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t sceneWidth = this->m_camera->getWidth ();
|
|
||||||
const uint32_t sceneHeight = this->m_camera->getHeight ();
|
|
||||||
|
|
||||||
// create extra framebuffers for the bloom effect
|
// create extra framebuffers for the bloom effect
|
||||||
this->_rt_4FrameBuffer =
|
this->_rt_4FrameBuffer =
|
||||||
this->create ("_rt_4FrameBuffer", ITexture::TextureFormat::ARGB8888, ITexture::TextureFlags::ClampUVs, 1.0,
|
this->create ("_rt_4FrameBuffer", ITexture::TextureFormat::ARGB8888, ITexture::TextureFlags::ClampUVs, 1.0,
|
||||||
@ -88,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);
|
||||||
|
@ -52,5 +52,6 @@ class CScene final : public CWallpaper {
|
|||||||
std::shared_ptr<const CFBO> _rt_4FrameBuffer = nullptr;
|
std::shared_ptr<const CFBO> _rt_4FrameBuffer = nullptr;
|
||||||
std::shared_ptr<const CFBO> _rt_8FrameBuffer = nullptr;
|
std::shared_ptr<const CFBO> _rt_8FrameBuffer = nullptr;
|
||||||
std::shared_ptr<const CFBO> _rt_Bloom = nullptr;
|
std::shared_ptr<const CFBO> _rt_Bloom = nullptr;
|
||||||
|
std::shared_ptr<const CFBO> _rt_shadowAtlas = nullptr;
|
||||||
};
|
};
|
||||||
} // namespace WallpaperEngine::Render::Wallpaper
|
} // namespace WallpaperEngine::Render::Wallpaper
|
||||||
|
Loading…
Reference in New Issue
Block a user