Compare commits

...

8 Commits

17 changed files with 246 additions and 118 deletions

@ -1 +1 @@
Subproject commit 077d4f3c89bbfbb7951a9011d4551b075f092334
Subproject commit 9fba00b655d79ef2fe6f05b459571bd3b1f119ea

View File

@ -284,7 +284,7 @@ std::unique_ptr<CTexture::TextureHeader> CTexture::parseHeader (const char* file
header->freeImageFormat = static_cast<FreeImageFormat> (*pointer++);
header->isVideoMp4 = *pointer++ == 1;
if (header->freeImageFormat == FIF_UNKNOWN) {
if (header->freeImageFormat == FIF_UNKNOWN && header->isVideoMp4) {
header->freeImageFormat = FIF_MP4;
}
@ -412,6 +412,8 @@ std::shared_ptr<CTexture::TextureMipmap> CTexture::parseMipmap (const TextureHea
fileData ++;
pointer = reinterpret_cast<const uint32_t*> (fileData);
// this is another param to ignore
pointer++;
}
mipmap->width = *pointer++;

View File

@ -19,6 +19,7 @@ void CDynamicValue::update(float newValue) {
this->m_float = newValue;
this->m_int = static_cast<int> (newValue);
this->m_bool = static_cast<int> (newValue) != 0;
this->m_type = UnderlyingType::Float;
this->propagate ();
}
@ -33,6 +34,7 @@ void CDynamicValue::update(int newValue) {
this->m_float = static_cast<float> (newValue);
this->m_int = newValue;
this->m_bool = newValue != 0;
this->m_type = UnderlyingType::Int;
this->propagate ();
}
@ -47,6 +49,7 @@ void CDynamicValue::update(bool newValue) {
this->m_float = newValue;
this->m_int = newValue;
this->m_bool = newValue;
this->m_type = UnderlyingType::Boolean;
this->propagate ();
}
@ -61,6 +64,7 @@ void CDynamicValue::update(const glm::vec2& newValue) {
this->m_float = newValue.x;
this->m_int = static_cast<int> (newValue.x);
this->m_bool = newValue.x != 0.0f;
this->m_type = UnderlyingType::Vec2;
this->propagate ();
}
@ -75,6 +79,7 @@ void CDynamicValue::update(const glm::vec3& newValue) {
this->m_float = newValue.x;
this->m_int = static_cast<int> (newValue.x);
this->m_bool = newValue.x != 0.0f;
this->m_type = UnderlyingType::Vec3;
this->propagate ();
}
@ -89,6 +94,7 @@ void CDynamicValue::update(const glm::vec4& newValue) {
this->m_float = newValue.x;
this->m_int = static_cast<int> (newValue.x);
this->m_bool = newValue.x != 0.0f;
this->m_type = UnderlyingType::Vec4;
this->propagate ();
}
@ -103,6 +109,7 @@ void CDynamicValue::update(const glm::ivec2& newValue) {
this->m_float = static_cast<float> (newValue.x);
this->m_int = static_cast<int> (newValue.x);
this->m_bool = newValue.x != 0;
this->m_type = UnderlyingType::IVec2;
this->propagate ();
}
@ -117,6 +124,7 @@ void CDynamicValue::update(const glm::ivec3& newValue) {
this->m_float = static_cast<float> (newValue.x);
this->m_int = static_cast<int> (newValue.x);
this->m_bool = newValue.x != 0;
this->m_type = UnderlyingType::IVec3;
this->propagate ();
}
@ -131,6 +139,7 @@ void CDynamicValue::update(const glm::ivec4& newValue) {
this->m_float = static_cast<float> (newValue.x);
this->m_int = static_cast<int> (newValue.x);
this->m_bool = newValue.x != 0;
this->m_type = UnderlyingType::IVec4;
this->propagate ();
}
@ -203,3 +212,7 @@ const int& CDynamicValue::getInt () const {
const bool& CDynamicValue::getBool () const {
return this->m_bool;
}
CDynamicValue::UnderlyingType CDynamicValue::getType () const {
return this->m_type;
}

View File

@ -19,6 +19,19 @@ class CDynamicValue {
friend class WallpaperEngine::Data::Parsers::UserSettingParser;
friend class WallpaperEngine::Data::Builders::UserSettingBuilder;
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 ();
[[nodiscard]] const glm::ivec4& getIVec4 () const;
@ -30,6 +43,7 @@ class CDynamicValue {
[[nodiscard]] const float& getFloat () const;
[[nodiscard]] const int& getInt () const;
[[nodiscard]] const bool& getBool () const;
[[nodiscard]] UnderlyingType getType () const;
/**
* Connects the current instance to the given instance, updating it's values
@ -38,8 +52,6 @@ class CDynamicValue {
* @param value
*/
void connectOutgoing (CDynamicValue* value) const;
protected:
void update (float newValue);
void update (int newValue);
void update (bool newValue);
@ -49,6 +61,8 @@ class CDynamicValue {
void update (const glm::ivec2& newValue);
void update (const glm::ivec3& newValue);
void update (const glm::ivec4& newValue);
protected:
/**
* Registers an incoming connection (another CDynamicValue affecting the current instance's value)
* Useful mainly for destroying the connection on delete
@ -65,6 +79,7 @@ class CDynamicValue {
private:
mutable std::vector<CDynamicValue*> m_outgoingConnections = {};
mutable std::vector<const CDynamicValue*> m_incomingConnections = {};
UnderlyingType m_type = UnderlyingType::Unknown;
// different values that we will be casted to automagically
glm::ivec4 m_ivec4 = {};
glm::ivec3 m_ivec3 = {};

View File

@ -24,9 +24,11 @@ std::shared_ptr<CProperty> CProperty::fromJSON (const json& data, const std::str
if (*type == "text")
return CPropertyText::fromJSON (data, name);
if (*type != "group") {
// show the error and ignore this property
sLog.error ("Unexpected type for property: ", *type);
sLog.error (data);
}
return nullptr;
}

View File

@ -16,6 +16,7 @@ EffectUniquePtr EffectParser::load (Project& project, const std::string& filenam
EffectUniquePtr EffectParser::parse (const JSON& it, Project& project) {
const auto dependencies = it.optional ("dependencies");
const auto fbos = it.optional ("fbos");
return std::make_unique <Effect> (Effect {
.name = it.optional <std::string> ("name", ""),
@ -24,6 +25,7 @@ EffectUniquePtr EffectParser::parse (const JSON& it, Project& project) {
.preview = it.optional <std::string> ("preview", ""),
.dependencies = dependencies.has_value () ? parseDependencies (*dependencies) : std::vector <std::string> {},
.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) {
const auto binds = cur.optional ("binds");
const auto binds = cur.optional ("bind");
std::optional <PassCommand> command = std::nullopt;
if (cur.contains ("command")) {
@ -93,3 +95,21 @@ 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;
}

View File

@ -16,5 +16,6 @@ class EffectParser {
static std::vector <std::string> parseDependencies (const JSON& it);
static std::vector <EffectPassUniquePtr> parseEffectPasses (const JSON& it, Project& project);
static std::map <int, std::string> parseBinds (const JSON& it);
static std::vector <FBOUniquePtr> parseFBOs (const JSON& it);
};
} // namespace WallpaperEngine::Data::Parsers

View File

@ -60,7 +60,7 @@ std::map <int, std::string> MaterialParser::parseTextures (const JSON& it) {
int index = 0;
for (const auto& cur : it) {
if (!it.is_null ()) {
if (!cur.is_null ()) {
result.emplace (index, cur);
}

View File

@ -78,7 +78,7 @@ ImageUniquePtr ObjectParser::parseImage (
const auto& properties = project.properties;
const auto& effects = it.optional ("effects");
return std::make_unique <Image> (
auto result = std::make_unique <Image> (
std::move (base),
ImageData {
.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)),
.visible = it.user ("visible", properties, true),
.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")),
.size = it.optional ("size", 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> {},
}
);
// 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) {
@ -115,8 +124,8 @@ std::vector <ImageEffectUniquePtr> ObjectParser::parseEffects (const JSON& it, P
ImageEffectUniquePtr ObjectParser::parseEffect (const JSON& it, Project& project) {
const auto& passsOverrides = it.optional ("passes");
return std::make_unique <ImageEffect> (ImageEffect {
.id = it.require <int> ("id", "Image effect must have an id"),
.name = it.require <std::string> ("name", "Image effect must have a name"),
.id = it.optional <int> ("id", -1),
.name = it.optional <std::string> ("name", "Effect without name"),
.visible = it.user ("visible", project.properties, true),
.passOverrides = passsOverrides.has_value () ? parseEffectPassOverrides (passsOverrides.value (), project) : std::vector <ImageEffectPassOverrideUniquePtr> {},
.effect = EffectParser::load (project, it.require ("file", "Image effect must have an effect"))
@ -163,11 +172,11 @@ TextureMap ObjectParser::parseTextureMap (const JSON& it) {
textureIndex ++;
if (cur.is_null ()) {
continue;
}
result.emplace (textureIndex, "");
} else {
result.emplace (textureIndex, cur);
}
}
return result;
}

View File

@ -22,7 +22,7 @@ ProjectUniquePtr ProjectParser::parse (const JSON& data, ContainerUniquePtr cont
.title = data.require <std::string> ("title", "Project title missing"),
.type = parseType (type),
.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),
.container = std::move(container),
});
@ -63,6 +63,11 @@ Properties ProjectParser::parseProperties (const std::optional <JSON>& data) {
for (const auto& cur : properties.value ().items ()) {
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);
}

View File

@ -59,7 +59,7 @@ CPass::CPass (
m_blendingmode (pass.blending),
m_binds (binds.has_value () ? binds.value ().get () : DEFAULT_BINDS),
m_override (override.has_value () ? override.value ().get () : DEFAULT_OVERRIDE),
m_fboProvider (fboProvider),
m_fboProvider (std::move(fboProvider)),
m_target (target) {
this->setupShaders ();
this->setupShaderVariables ();
@ -425,8 +425,8 @@ void CPass::setupShaders () {
// TODO: USED TO BUILD THE TEXTURES LATER
// use the combos copied from the pass so it includes the texture format
this->m_shader = new Render::Shaders::CShader (
this->m_image.getContainer (), this->m_pass.shader, this->m_combos,
this->m_pass.textures, this->m_override.constants
this->m_image.getContainer (), this->m_pass.shader, this->m_combos, this->m_override.combos,
this->m_pass.textures, this->m_override.textures, this->m_override.constants
);
const auto shaders = Shaders::CGLSLContext::get ().toGlsl (
@ -502,16 +502,11 @@ void CPass::setupTextureUniforms () {
// and then try with fragment's and override any existing
for (const auto& [index, textureName] : this->m_shader->getVertex ().getTextures ()) {
try {
// resolve the texture first
std::shared_ptr<const ITexture> textureRef;
if (textureName.find ("_rt_") == 0 || textureName.find ("_alias_") == 0) {
textureRef = this->resolveFBO (textureName);
} else {
textureRef = this->getContext ().resolveTexture (textureName);
this->m_textures [index] = this->resolveFBO (textureName);
} else if(!textureName.empty ()) {
this->m_textures [index] = this->getContext ().resolveTexture (textureName);
}
this->m_textures [index] = textureRef;
} catch (std::runtime_error& ex) {
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 ()) {
try {
// resolve the texture first
std::shared_ptr<const ITexture> textureRef;
if (textureName.find ("_rt_") == 0 || textureName.find ("_alias_") == 0) {
textureRef = this->resolveFBO (textureName);
} else {
textureRef = this->getContext ().resolveTexture (textureName);
this->m_textures [index] = this->resolveFBO (textureName);
} else if(!textureName.empty ()) {
this->m_textures [index] = this->getContext ().resolveTexture (textureName);
}
this->m_textures [index] = textureRef;
} catch (std::runtime_error& ex) {
sLog.error ("Cannot resolve texture ", textureName, " for fragment shader ", ex.what ());
}
@ -540,10 +530,31 @@ void CPass::setupTextureUniforms () {
continue;
}
if (textureName.find ("_rt_") == 0) {
this->m_textures[index] = this->resolveFBO (textureName);
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->m_image.getContext ().resolveTexture (textureName);
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") {
// use nullptr as indication for "previous" texture
this->m_textures [index] = nullptr;
} else {
} else if(!bind.empty ()) {
// a normal bind, search for the corresponding FBO and set it
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_Alpha", image.alpha->value->getFloat ());
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
this->addUniform ("g_CompositeColor", image.color->value->getVec3 ());
// add some external variables

View File

@ -19,18 +19,21 @@ using namespace WallpaperEngine::Assets;
namespace WallpaperEngine::Render::Shaders {
CShader::CShader (
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
) :
m_file (std::move (filename)),
m_combos (combos),
m_overrideCombos (overrideCombos),
m_passTextures (textures),
m_overrideTextures (overrideTextures),
m_vertex (
CGLSLContext::UnitType_Vertex, filename, container.readVertexShader (filename),
container, constants, textures, combos),
container, constants, textures, overrideTextures, combos, overrideCombos),
m_fragment (
CGLSLContext::UnitType_Fragment, filename, container.readFragmentShader (filename),
container, constants, textures, combos) {
container, constants, textures, overrideTextures, combos, overrideCombos) {
// link shaders between them
this->m_vertex.linkToUnit (&this->m_fragment);
this->m_fragment.linkToUnit (&this->m_vertex);

View File

@ -46,7 +46,8 @@ class CShader {
*/
CShader (
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);
/**
* @return The vertex's shader coude for OpenGL to use
@ -97,9 +98,17 @@ class CShader {
* The combos the shader should be generated with
*/
const ComboMap& m_combos;
/**
* The overriden combos
*/
const ComboMap& m_overrideCombos;
/**
* The list of textures the pass knows about
*/
const TextureMap m_passTextures;
/**
* The list of the override textures
*/
const TextureMap& m_overrideTextures;
};
} // namespace WallpaperEngine::Render::Shaders

View File

@ -57,7 +57,8 @@ using namespace WallpaperEngine::Render::Shaders;
CShaderUnit::CShaderUnit (
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_link (nullptr),
@ -66,7 +67,9 @@ CShaderUnit::CShaderUnit (
m_constants (constants),
m_content (std::move(content)),
m_passTextures (passTextures),
m_overrideTextures (overrideTextures),
m_combos (combos),
m_overrideCombos (overrideCombos),
m_discoveredCombos (),
m_usedCombos () {
// 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
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
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
// 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 (defvalue == data.end ()) {
// 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
// if needed
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
const char value = name.at (std::string ("g_Texture").length ());
const auto requireany = data.find ("requireany");
const auto require = data.find ("require");
// now convert it to integer
// TODO: BETTER CONVERSION HERE
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 ()) {
// TODO: CLEANUP HOW THIS IS DETERMINED FIRST
// 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;
int comboValue = 1;
if (texture != this->m_passTextures.end ()) {
if (textureSlotUsed) {
// nothing extra to do, the texture exists, the combo must be set
// these tend to not have default value
isRequired = true;
@ -428,9 +439,10 @@ void CShaderUnit::parseParameterConfiguration (
for (const auto& item : require->items ()) {
const std::string& macro = item.key ();
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 (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;
break;
}
@ -442,9 +454,10 @@ void CShaderUnit::parseParameterConfiguration (
for (const auto& item : require->items ()) {
const std::string& macro = item.key ();
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
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;
break;
}
@ -452,16 +465,17 @@ void CShaderUnit::parseParameterConfiguration (
}
}
if (isRequired && texture == this->m_passTextures.end ()) {
if (isRequired && !textureSlotUsed) {
if (defvalue == data.end ()) {
isRequired = false;
} else {
// is the combo registered already?
// if not, add it with the default value
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
if (combo_it != this->m_combos.end ()) {
if (combo_it != this->m_combos.end () || overridencombo_it != this->m_overrideCombos.end ()) {
isRequired = false;
// otherwise a default value must be used
} else if (defvalue->is_string ()) {
@ -531,27 +545,42 @@ const std::string& CShaderUnit::compile () {
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
for (const auto& combo : this->m_combos) {
if (addedCombos.find (combo.first) == addedCombos.end ()) {
this->m_final += DEFINE_COMBO (combo.first, combo.second);
}
addedCombos.emplace (combo.first, true);
}
for (const auto& combo : this->m_discoveredCombos) {
if (addedCombos.find (combo.first) == addedCombos.end ()) {
this->m_final += DEFINE_COMBO (combo.first, combo.second);
}
addedCombos.emplace (combo.first, true);
}
if (this->m_link != nullptr) {
for (const auto& combo : this->m_link->getCombos ()) {
if (addedCombos.find (combo.first) == addedCombos.end ()) {
this->m_final += DEFINE_COMBO (combo.first, combo.second);
}
addedCombos.emplace (combo.first, true);
}
for (const auto& combo : this->m_link->getDiscoveredCombos ()) {
if (addedCombos.find (combo.first) == addedCombos.end ()) {
this->m_final += DEFINE_COMBO (combo.first, combo.second);
}
addedCombos.emplace (combo.first, true);
}
}

View File

@ -27,7 +27,7 @@ class CShaderUnit {
CShaderUnit (
CGLSLContext::UnitType type, std::string file, std::string content, const CContainer& container,
const ShaderConstantMap& constants, const TextureMap& passTextures,
const ComboMap& combos);
const TextureMap& overrideTextures, const ComboMap& combos, const ComboMap& overrideCombos);
~CShaderUnit () = default;
/**
@ -132,6 +132,10 @@ class CShaderUnit {
* Pre-defined values for the 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
*/
@ -145,7 +149,9 @@ class CShaderUnit {
*/
const ShaderConstantMap& m_constants;
/** 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 */
TextureMap m_defaultTextures = {};
/**

View File

@ -46,6 +46,14 @@ CScene::CScene (
// setup framebuffers here as they're required for the scene setup
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
// TODO: MAKE USE OF THE REFERENCE POSSIBILITIES?!
const glm::vec3 clearColor = scene->colors.clear->value->getVec3 ();
@ -67,9 +75,6 @@ CScene::CScene (
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
this->_rt_4FrameBuffer =
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?!
const std::string imagejson = "{"
"\t\"image\": \"models/wpenginelinux.json\","
"\t\"name\": \"bloomimagewpenginelinux\","
"\t\"visible\": true,"
"\t\"scale\": \"1.0 1.0 1.0\","
"\t\"angles\": \"0.0 0.0 0.0\","
"\t\"origin\": \"" +
std::to_string (sceneWidth / 2) + " " + std::to_string (sceneHeight / 2) +
" 0.0\","
"\t\"id\": -1" +
","
"\t\"effects\":"
"\t["
"\t\t{"
"\t\t\t\"file\": \"effects/wpenginelinux/bloomeffect.json\","
"\t\t\t\"id\": 15242000,"
"\t\t\t\"name\": \"\","
"\t\t\t\"passes\":"
"\t\t\t["
"\t\t\t\t{"
"\t\t\t\t\t\"constantshadervalues\":"
"\t\t\t\t\t{"
"\t\t\t\t\t\t\"bloomstrength\": " +
std::to_string (this->getScene ().camera.bloom.strength->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{"
"\t\t\t\t\t\"constantshadervalues\":"
"\t\t\t\t\t{"
"\t\t\t\t\t\t\"bloomstrength\": " +
std::to_string (this->getScene ().camera.bloom.strength->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{"
"\t\t\t\t\t\"constantshadervalues\":"
"\t\t\t\t\t{"
"\t\t\t\t\t\t\"bloomstrength\": " +
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);
const auto bloomOrigin = glm::vec3 { sceneWidth / 2, sceneHeight / 2, 0.0f };
const auto bloomSize = glm::vec2 { sceneWidth, sceneHeight };
const nlohmann::json bloom = {
{"image", "models/wpenginelinux.json"},
{"name", "bloomimagewpenginelinux"},
{"visible", true},
{"scale", "1.0 1.0 1.0"},
{"angles", "0.0 0.0 0.0"},
{"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)},
{"id", -1},
{"effects",
json::array (
{
{
{"file", "effects/wpenginelinux/bloomeffect.json"},
{"id", 15242000},
{"name", ""},
{"passes",
json::array (
{
{
{"constantshadervalues",
{
{"bloomstrength", this->getScene ().camera.bloom.strength->value->getFloat ()},
{"bloomthreshold", this->getScene ().camera.bloom.threshold->value->getFloat ()}
}
}
},
{
{"constantshadervalues",
{
{"bloomstrength", this->getScene ().camera.bloom.strength->value->getFloat ()},
{"bloomthreshold", this->getScene ().camera.bloom.threshold->value->getFloat ()}
}
}
},
{
{"constantshadervalues",
{
{"bloomstrength", this->getScene ().camera.bloom.strength->value->getFloat ()},
{"bloomthreshold", this->getScene ().camera.bloom.threshold->value->getFloat ()}
}
}
}
}
)
}
}
}
)
}
};
// create image for bloom passes
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_objectsByRenderOrder.push_back (this->m_bloomObject);

View File

@ -52,5 +52,6 @@ class CScene final : public CWallpaper {
std::shared_ptr<const CFBO> _rt_4FrameBuffer = nullptr;
std::shared_ptr<const CFBO> _rt_8FrameBuffer = nullptr;
std::shared_ptr<const CFBO> _rt_Bloom = nullptr;
std::shared_ptr<const CFBO> _rt_shadowAtlas = nullptr;
};
} // namespace WallpaperEngine::Render::Wallpaper