mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-16 06:12:23 +08:00
- removed shader string constants, shaders do not have any, for future reference, these might be vectors or colors
+ shader constants now should be correctly applied as values for variables whenever possible Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
dc36adb200
commit
4358e7c173
@ -102,8 +102,6 @@ add_executable(
|
||||
src/WallpaperEngine/Core/Objects/Effects/CShaderConstant.cpp
|
||||
src/WallpaperEngine/Core/Objects/Effects/CShaderConstantFloat.h
|
||||
src/WallpaperEngine/Core/Objects/Effects/CShaderConstantFloat.cpp
|
||||
src/WallpaperEngine/Core/Objects/Effects/CShaderConstantString.h
|
||||
src/WallpaperEngine/Core/Objects/Effects/CShaderConstantString.cpp
|
||||
src/WallpaperEngine/Core/Objects/Effects/CShaderConstantInteger.h
|
||||
src/WallpaperEngine/Core/Objects/Effects/CShaderConstantInteger.cpp
|
||||
|
||||
|
3
main.cpp
3
main.cpp
@ -4,8 +4,6 @@
|
||||
#include <SDL_mixer.h>
|
||||
#include <SDL.h>
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Compiler.h"
|
||||
|
||||
#include "WallpaperEngine/Core/CProject.h"
|
||||
#include "WallpaperEngine/Irrlicht/CContext.h"
|
||||
#include "WallpaperEngine/Render/CScene.h"
|
||||
@ -132,7 +130,6 @@ int main (int argc, char* argv[])
|
||||
|
||||
irr::io::path wallpaper_path = IrrlichtContext->getDevice ()->getFileSystem ()->getAbsolutePath (path.c_str ());
|
||||
irr::io::path project_path = wallpaper_path + "project.json";
|
||||
irr::io::path scene_path;
|
||||
|
||||
if (mode == RUN_MODE_PACKAGE)
|
||||
{
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "WallpaperEngine/Core/Objects/CImage.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstant.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstantFloat.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstantString.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstantInteger.h"
|
||||
#include "WallpaperEngine/FileSystem/FileSystem.h"
|
||||
|
||||
@ -137,7 +136,7 @@ CEffect* CEffect::fromJSON (json data, Core::CObject* object)
|
||||
}
|
||||
else if ((*constantCur).is_string () == true)
|
||||
{
|
||||
constant = new Effects::CShaderConstantString ((*constantCur).get <std::string> ());
|
||||
throw std::runtime_error ("String constants not supported yet");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -14,9 +14,8 @@ namespace WallpaperEngine::Core::Objects::Effects
|
||||
|
||||
irr::f32* getValue ();
|
||||
|
||||
static const std::string Type;
|
||||
protected:
|
||||
irr::f32 m_value;
|
||||
|
||||
static const std::string Type;
|
||||
};
|
||||
}
|
||||
|
@ -14,9 +14,8 @@ namespace WallpaperEngine::Core::Objects::Effects
|
||||
|
||||
irr::u32* getValue ();
|
||||
|
||||
static const std::string Type;
|
||||
protected:
|
||||
irr::u32 m_value;
|
||||
|
||||
static const std::string Type;
|
||||
};
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
#include "CShaderConstantString.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Effects;
|
||||
|
||||
|
||||
CShaderConstantString::CShaderConstantString (std::string value) :
|
||||
CShaderConstant (Type),
|
||||
m_value (std::move(value))
|
||||
{
|
||||
}
|
||||
|
||||
std::string* CShaderConstantString::getValue ()
|
||||
{
|
||||
return &this->m_value;
|
||||
}
|
||||
|
||||
const std::string CShaderConstantString::Type = "string";
|
@ -1,22 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "CShaderConstant.h"
|
||||
|
||||
#include <string>
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Effects
|
||||
{
|
||||
class CShaderConstantString : public CShaderConstant
|
||||
{
|
||||
public:
|
||||
CShaderConstantString (std::string value);
|
||||
|
||||
std::string* getValue ();
|
||||
|
||||
protected:
|
||||
std::string m_value;
|
||||
|
||||
static const std::string Type;
|
||||
};
|
||||
}
|
@ -7,10 +7,17 @@
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector3.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector4.h"
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableFloatPointer.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Variables/CShaderVariableVector2Pointer.h"
|
||||
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstant.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstantFloat.h"
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstantInteger.h"
|
||||
|
||||
using namespace WallpaperEngine;
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Effects;
|
||||
|
||||
using namespace WallpaperEngine::Render::Objects;
|
||||
using namespace WallpaperEngine::Render::Shaders::Variables;
|
||||
|
||||
@ -94,7 +101,7 @@ void CImage::generateMaterial ()
|
||||
|
||||
for (; cur != end; cur++)
|
||||
{
|
||||
this->generatePass (*cur);
|
||||
this->generatePass (*cur, nullptr);
|
||||
}
|
||||
|
||||
auto effectCur = this->m_image->getEffects ().begin ();
|
||||
@ -112,13 +119,13 @@ void CImage::generateMaterial ()
|
||||
|
||||
for (; cur != end; cur++)
|
||||
{
|
||||
this->generatePass (*cur);
|
||||
this->generatePass (*cur, *effectCur);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CImage::generatePass (Core::Objects::Images::Materials::CPassess* pass)
|
||||
void CImage::generatePass (Core::Objects::Images::Materials::CPassess* pass, Core::Objects::CEffect* effect)
|
||||
{
|
||||
std::vector<std::string>* textures = pass->getTextures ();
|
||||
irr::video::SMaterial material;
|
||||
@ -166,6 +173,43 @@ void CImage::generatePass (Core::Objects::Images::Materials::CPassess* pass)
|
||||
this, irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL, this->m_passes, irr::video::EGSL_DEFAULT
|
||||
);
|
||||
|
||||
if (effect)
|
||||
{
|
||||
// find variables in the shaders and set the value with the constants if possible
|
||||
auto cur = effect->getConstants ().begin ();
|
||||
auto end = effect->getConstants ().end ();
|
||||
|
||||
for (; cur != end; cur ++)
|
||||
{
|
||||
CShaderVariable* vertexVar = vertexShader->findParameter ((*cur).first);
|
||||
CShaderVariable* pixelVar = pixelShader->findParameter ((*cur).first);
|
||||
|
||||
if (pixelVar)
|
||||
{
|
||||
if (pixelVar->is <CShaderVariableFloat> () && (*cur).second->is <CShaderConstantFloat> ())
|
||||
{
|
||||
pixelVar->as <CShaderVariableFloat> ()->setValue (*(*cur).second->as <CShaderConstantFloat> ()->getValue ());
|
||||
}
|
||||
else if (pixelVar->is <CShaderVariableInteger> () && (*cur).second->is <CShaderConstantInteger> ())
|
||||
{
|
||||
pixelVar->as <CShaderVariableInteger> ()->setValue (*(*cur).second->as <CShaderConstantInteger> ()->getValue ());
|
||||
}
|
||||
}
|
||||
|
||||
if (vertexVar)
|
||||
{
|
||||
if (vertexVar->is <CShaderVariableFloat> () && (*cur).second->is <CShaderConstantFloat> ())
|
||||
{
|
||||
vertexVar->as <CShaderVariableFloat> ()->setValue (*(*cur).second->as <CShaderConstantFloat> ()->getValue ());
|
||||
}
|
||||
else if (vertexVar->is <CShaderVariableInteger> () && (*cur).second->is <CShaderConstantInteger> ())
|
||||
{
|
||||
vertexVar->as <CShaderVariableInteger> ()->setValue (*(*cur).second->as <CShaderConstantInteger> ()->getValue ());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: TAKE INTO ACCOUNT BLENDING AND CULLING METHODS FROM THE JSON
|
||||
material.setFlag (irr::video::EMF_LIGHTING, false);
|
||||
material.setFlag (irr::video::EMF_BLEND_OPERATION, true);
|
||||
|
@ -26,7 +26,7 @@ namespace WallpaperEngine::Render::Objects
|
||||
|
||||
private:
|
||||
void generateMaterial ();
|
||||
void generatePass (Core::Objects::Images::Materials::CPassess* pass);
|
||||
void generatePass (Core::Objects::Images::Materials::CPassess* pass, Core::Objects::CEffect* effect);
|
||||
|
||||
irr::video::S3DVertex m_vertex [4];
|
||||
irr::u32 m_passes;
|
||||
|
Loading…
Reference in New Issue
Block a user