mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-14 05:12:25 +08:00
+ Added parsing of shader constants for effects
~ Improved Shader Compiler parameter list to a better approach + Added support for one-pass effects with shaders (only first shader/pass will be applied) Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
fc8778ab64
commit
32a6a7af65
@ -25,6 +25,19 @@ add_executable(
|
||||
src/WallpaperEngine/Core/Core.h
|
||||
src/WallpaperEngine/Core/Core.cpp
|
||||
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.h
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.cpp
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterFloat.h
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterFloat.cpp
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterInteger.h
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterInteger.cpp
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector2.h
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector2.cpp
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector3.h
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector3.cpp
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector4.h
|
||||
src/WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector4.cpp
|
||||
|
||||
src/WallpaperEngine/Render/Shaders/Compiler.h
|
||||
src/WallpaperEngine/Render/Shaders/Compiler.cpp
|
||||
|
||||
@ -76,6 +89,15 @@ add_executable(
|
||||
src/WallpaperEngine/Core/Objects/CParticle.cpp
|
||||
src/WallpaperEngine/Core/Objects/CParticle.h
|
||||
|
||||
src/WallpaperEngine/Core/Objects/Effects/CShaderConstant.h
|
||||
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
|
||||
|
||||
src/WallpaperEngine/Core/Objects/Particles/CControlPoint.cpp
|
||||
src/WallpaperEngine/Core/Objects/Particles/CControlPoint.h
|
||||
src/WallpaperEngine/Core/Objects/Particles/CEmitter.cpp
|
||||
|
10
main.cpp
10
main.cpp
@ -301,6 +301,9 @@ int main (int argc, char* argv[])
|
||||
|
||||
while (IrrlichtContext && IrrlichtContext->getDevice () && IrrlichtContext->getDevice ()->run ())
|
||||
{
|
||||
if (IrrlichtContext->getDevice ()->getVideoDriver () == nullptr)
|
||||
continue;
|
||||
|
||||
// if (device->isWindowActive ())
|
||||
{
|
||||
currentTime = startTime = IrrlichtContext->getDevice ()->getTimer ()->getTime ();
|
||||
@ -316,17 +319,14 @@ int main (int argc, char* argv[])
|
||||
// change viewport to render to the correct portion of the display
|
||||
IrrlichtContext->getDevice ()->getVideoDriver ()->setViewPort (*cur);
|
||||
|
||||
if (IrrlichtContext->getDevice ()->getVideoDriver () == nullptr)
|
||||
continue;
|
||||
|
||||
IrrlichtContext->getDevice ()->getVideoDriver ()->beginScene(false, true, irr::video::SColor(0, 0, 0, 0));
|
||||
IrrlichtContext->getDevice ()->getVideoDriver ()->beginScene (false, true, irr::video::SColor(0, 0, 0, 0));
|
||||
IrrlichtContext->getDevice ()->getSceneManager ()->drawAll ();
|
||||
IrrlichtContext->getDevice ()->getVideoDriver ()->endScene ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IrrlichtContext->getDevice ()->getVideoDriver ()->beginScene(false, true, irr::video::SColor(0, 0, 0, 0));
|
||||
IrrlichtContext->getDevice ()->getVideoDriver ()->beginScene (true, true, irr::video::SColor(0, 0, 0, 0));
|
||||
IrrlichtContext->getDevice ()->getSceneManager ()->drawAll ();
|
||||
IrrlichtContext->getDevice ()->getVideoDriver ()->endScene ();
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ CObject* CObject::fromJSON (json data)
|
||||
json::const_iterator visible_it = data.find ("visible");
|
||||
json::const_iterator origin_it = data.find ("origin");
|
||||
json::const_iterator scale_it = data.find ("scale");
|
||||
json::const_iterator size_it = data.find ("size");
|
||||
json::const_iterator angles_it = data.find ("angles");
|
||||
json::const_iterator name_it = data.find ("name");
|
||||
json::const_iterator effects_it = data.find ("effects");
|
||||
@ -152,6 +151,11 @@ std::vector<Objects::CEffect*>* CObject::getEffects ()
|
||||
return &this->m_effects;
|
||||
}
|
||||
|
||||
bool CObject::isVisible ()
|
||||
{
|
||||
return this->m_visible;
|
||||
}
|
||||
|
||||
int CObject::getId ()
|
||||
{
|
||||
return this->m_id;
|
||||
|
@ -31,6 +31,7 @@ namespace WallpaperEngine::Core
|
||||
irr::core::vector3df* getScale ();
|
||||
irr::core::vector3df* getAngles ();
|
||||
|
||||
bool isVisible ();
|
||||
protected:
|
||||
CObject (
|
||||
bool visible,
|
||||
|
@ -3,6 +3,10 @@
|
||||
#include <utility>
|
||||
|
||||
#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"
|
||||
|
||||
using namespace WallpaperEngine;
|
||||
@ -111,6 +115,38 @@ CEffect* CEffect::fromJSON (json data, Core::CObject* object)
|
||||
|
||||
for (int passNumber = 0; cur != end; cur ++, passNumber ++)
|
||||
{
|
||||
json::const_iterator constants_it = (*cur).find ("constantshadervalues");
|
||||
|
||||
if (constants_it == (*cur).end ())
|
||||
continue;
|
||||
|
||||
json::const_iterator constantCur = (*constants_it).begin ();
|
||||
json::const_iterator constantEnd = (*constants_it).end ();
|
||||
|
||||
for (; constantCur != constantEnd; constantCur ++)
|
||||
{
|
||||
Effects::CShaderConstant* constant = nullptr;
|
||||
|
||||
if ((*constantCur).is_number_float () == true)
|
||||
{
|
||||
constant = new Effects::CShaderConstantFloat ((*constantCur).get <irr::f32> ());
|
||||
}
|
||||
else if ((*constantCur).is_number_integer () == true)
|
||||
{
|
||||
constant = new Effects::CShaderConstantInteger ((*constantCur).get <irr::s32> ());
|
||||
}
|
||||
else if ((*constantCur).is_string () == true)
|
||||
{
|
||||
constant = new Effects::CShaderConstantString ((*constantCur).get <std::string> ());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error ("unknown shader constant type");
|
||||
}
|
||||
|
||||
effect->insertConstant (constantCur.key (), constant);
|
||||
}
|
||||
|
||||
json::const_iterator textures_it = (*cur).find ("textures");
|
||||
|
||||
if (textures_it == (*cur).end ())
|
||||
@ -172,6 +208,11 @@ std::vector<Images::CMaterial*>* CEffect::getMaterials ()
|
||||
return &this->m_materials;
|
||||
}
|
||||
|
||||
std::map<std::string, Effects::CShaderConstant*>* CEffect::getConstants ()
|
||||
{
|
||||
return &this->m_constants;
|
||||
}
|
||||
|
||||
void CEffect::insertDependency (const std::string& dep)
|
||||
{
|
||||
this->m_dependencies.push_back (dep);
|
||||
@ -180,4 +221,9 @@ void CEffect::insertDependency (const std::string& dep)
|
||||
void CEffect::insertMaterial (Images::CMaterial* material)
|
||||
{
|
||||
this->m_materials.push_back (material);
|
||||
}
|
||||
|
||||
void CEffect::insertConstant (const std::string& name, Effects::CShaderConstant* constant)
|
||||
{
|
||||
this->m_constants.insert (std::pair <std::string, Effects::CShaderConstant*> (name, constant));
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Core/Objects/Effects/CShaderConstant.h"
|
||||
#include "WallpaperEngine/Core/CObject.h"
|
||||
#include "WallpaperEngine/Core/Objects/Images/CMaterial.h"
|
||||
|
||||
@ -30,9 +31,11 @@ namespace WallpaperEngine::Core::Objects
|
||||
|
||||
std::vector<std::string>* getDependencies ();
|
||||
std::vector<Images::CMaterial*>* getMaterials ();
|
||||
std::map<std::string, Effects::CShaderConstant*>* getConstants ();
|
||||
protected:
|
||||
void insertDependency (const std::string& dep);
|
||||
void insertMaterial (Images::CMaterial* material);
|
||||
void insertConstant (const std::string& name, Effects::CShaderConstant* constant);
|
||||
private:
|
||||
std::string m_name;
|
||||
std::string m_description;
|
||||
@ -42,5 +45,6 @@ namespace WallpaperEngine::Core::Objects
|
||||
|
||||
std::vector<std::string> m_dependencies;
|
||||
std::vector<Images::CMaterial*> m_materials;
|
||||
std::map<std::string, Effects::CShaderConstant*> m_constants;
|
||||
};
|
||||
}
|
||||
|
@ -64,4 +64,10 @@ Images::CMaterial* CImage::getMaterial ()
|
||||
return this->m_material;
|
||||
}
|
||||
|
||||
irr::core::vector2df* CImage::getSize ()
|
||||
{
|
||||
return &this->m_size;
|
||||
}
|
||||
|
||||
|
||||
const std::string CImage::Type = "image";
|
@ -27,6 +27,7 @@ namespace WallpaperEngine::Core::Objects
|
||||
);
|
||||
|
||||
Images::CMaterial* getMaterial ();
|
||||
irr::core::vector2df* getSize ();
|
||||
|
||||
protected:
|
||||
CImage (
|
||||
|
@ -0,0 +1,8 @@
|
||||
#include "CShaderConstant.h"
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Effects;
|
||||
|
||||
CShaderConstant::CShaderConstant (std::string type) :
|
||||
m_type (std::move(type))
|
||||
{
|
||||
}
|
20
src/WallpaperEngine/Core/Objects/Effects/CShaderConstant.h
Normal file
20
src/WallpaperEngine/Core/Objects/Effects/CShaderConstant.h
Normal file
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Effects
|
||||
{
|
||||
class CShaderConstant
|
||||
{
|
||||
public:
|
||||
CShaderConstant (std::string type);
|
||||
|
||||
template<class T> const T* As () const { assert (Is<T> ()); return (const T*) this; }
|
||||
template<class T> T* As () { assert (Is<T> ()); return (T*) this; }
|
||||
|
||||
template<class T> bool Is () { return this->m_type == T::Type; }
|
||||
|
||||
private:
|
||||
std::string m_type;
|
||||
};
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
#include "CShaderConstantFloat.h"
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Effects;
|
||||
|
||||
|
||||
CShaderConstantFloat::CShaderConstantFloat (irr::f32 value) :
|
||||
CShaderConstant (Type),
|
||||
m_value (value)
|
||||
{
|
||||
}
|
||||
|
||||
irr::f32* CShaderConstantFloat::getValue ()
|
||||
{
|
||||
return &this->m_value;
|
||||
}
|
||||
|
||||
const std::string CShaderConstantFloat::Type = "float";
|
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "CShaderConstant.h"
|
||||
|
||||
#include <string>
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Effects
|
||||
{
|
||||
class CShaderConstantFloat : public CShaderConstant
|
||||
{
|
||||
public:
|
||||
CShaderConstantFloat (irr::f32 value);
|
||||
|
||||
irr::f32* getValue ();
|
||||
|
||||
protected:
|
||||
irr::f32 m_value;
|
||||
|
||||
static const std::string Type;
|
||||
};
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
#include "CShaderConstantInteger.h"
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects::Effects;
|
||||
|
||||
|
||||
CShaderConstantInteger::CShaderConstantInteger (irr::s32 value) :
|
||||
CShaderConstant (Type),
|
||||
m_value (value)
|
||||
{
|
||||
}
|
||||
|
||||
irr::u32* CShaderConstantInteger::getValue ()
|
||||
{
|
||||
return &this->m_value;
|
||||
}
|
||||
|
||||
const std::string CShaderConstantInteger::Type = "integer";
|
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "CShaderConstant.h"
|
||||
|
||||
#include <string>
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Core::Objects::Effects
|
||||
{
|
||||
class CShaderConstantInteger : public CShaderConstant
|
||||
{
|
||||
public:
|
||||
CShaderConstantInteger (irr::s32 value);
|
||||
|
||||
irr::u32* getValue ();
|
||||
|
||||
protected:
|
||||
irr::u32 m_value;
|
||||
|
||||
static const std::string Type;
|
||||
};
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
#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";
|
@ -0,0 +1,22 @@
|
||||
#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;
|
||||
};
|
||||
}
|
@ -1,9 +1,18 @@
|
||||
#include "CImage.h"
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Compiler.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterFloat.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterInteger.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector2.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector3.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector4.h"
|
||||
|
||||
using namespace WallpaperEngine;
|
||||
using namespace WallpaperEngine::Render::Objects;
|
||||
using namespace WallpaperEngine::Render::Shaders::Parameters;
|
||||
|
||||
extern irr::f32 g_Time;
|
||||
|
||||
CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
|
||||
Render::CObject (scene, Type, image),
|
||||
@ -82,17 +91,17 @@ void CImage::generateMaterial ()
|
||||
// TODO: MOVE SHADER INITIALIZATION ELSEWHERE
|
||||
irr::io::path vertpath = std::string ("shaders/" + shader + ".vert").c_str ();
|
||||
irr::io::path fragpath = std::string ("shaders/" + shader + ".frag").c_str ();
|
||||
Render::Shaders::Compiler* vertshader = new Render::Shaders::Compiler (vertpath, Render::Shaders::Compiler::Type::Type_Vertex, pass->getCombos (), false);
|
||||
Render::Shaders::Compiler* fragshader = new Render::Shaders::Compiler (fragpath, Render::Shaders::Compiler::Type::Type_Pixel, pass->getCombos (), false);
|
||||
this->m_vertexShader = new Render::Shaders::Compiler (vertpath, Render::Shaders::Compiler::Type::Type_Vertex, pass->getCombos (), false);
|
||||
this->m_pixelShader = new Render::Shaders::Compiler (fragpath, Render::Shaders::Compiler::Type::Type_Pixel, pass->getCombos (), false);
|
||||
|
||||
this->m_material.MaterialType = (irr::video::E_MATERIAL_TYPE)
|
||||
this->getScene ()->getContext ()->getDevice ()->getVideoDriver ()->getGPUProgrammingServices ()->addHighLevelShaderMaterial (
|
||||
vertshader->precompile ().c_str (), "main", irr::video::EVST_VS_2_0,
|
||||
fragshader->precompile ().c_str (), "main", irr::video::EPST_PS_2_0,
|
||||
this, irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL, 0, irr::video::EGSL_DEFAULT
|
||||
);
|
||||
this->getScene ()->getContext ()->getDevice ()->getVideoDriver ()->getGPUProgrammingServices ()->addHighLevelShaderMaterial (
|
||||
this->m_vertexShader->precompile ().c_str (), "main", irr::video::EVST_VS_2_0,
|
||||
this->m_pixelShader->precompile ().c_str (), "main", irr::video::EPST_PS_2_0,
|
||||
this, irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL, 0, irr::video::EGSL_DEFAULT
|
||||
);
|
||||
|
||||
this->m_material.MaterialType = irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
// this->m_material.MaterialType = irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
this->m_material.setFlag (irr::video::EMF_LIGHTING, false);
|
||||
this->m_material.setFlag (irr::video::EMF_BLEND_OPERATION, true);
|
||||
}
|
||||
@ -105,14 +114,133 @@ const irr::core::aabbox3d<irr::f32>& CImage::getBoundingBox() const
|
||||
|
||||
void CImage::OnRegisterSceneNode ()
|
||||
{
|
||||
SceneManager->registerNodeForRendering (this);
|
||||
if (this->m_image->isVisible () == true)
|
||||
SceneManager->registerNodeForRendering (this);
|
||||
|
||||
ISceneNode::OnRegisterSceneNode ();
|
||||
}
|
||||
|
||||
void CImage::OnSetConstants (irr::video::IMaterialRendererServices *services, int32_t userData)
|
||||
{
|
||||
// TODO: SUPPORT SHADER PARAMETERS HERE
|
||||
irr::f32 g_Texture0 = 0;
|
||||
irr::f32 g_Texture1 = 1;
|
||||
irr::f32 g_Texture2 = 2;
|
||||
irr::f32 g_Texture3 = 3;
|
||||
irr::f32 g_Texture4 = 4;
|
||||
irr::f32 g_Texture5 = 5;
|
||||
irr::f32 g_Texture6 = 6;
|
||||
irr::f32 g_Texture7 = 7;
|
||||
|
||||
irr::f32 g_Texture0Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z};
|
||||
irr::f32 g_Texture1Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z};
|
||||
irr::f32 g_Texture2Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z};
|
||||
irr::f32 g_Texture3Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z};
|
||||
irr::f32 g_Texture4Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z};
|
||||
irr::f32 g_Texture5Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z};
|
||||
irr::f32 g_Texture6Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z};
|
||||
irr::f32 g_Texture7Rotation [4] = { this->m_image->getAngles ()->X, this->m_image->getAngles ()->Y, this->m_image->getAngles ()->Z, this->m_image->getAngles ()->Z};
|
||||
|
||||
irr::f32 g_Texture0Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y};
|
||||
irr::f32 g_Texture1Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y};
|
||||
irr::f32 g_Texture2Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y};
|
||||
irr::f32 g_Texture3Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y};
|
||||
irr::f32 g_Texture4Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y};
|
||||
irr::f32 g_Texture5Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y};
|
||||
irr::f32 g_Texture6Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y};
|
||||
irr::f32 g_Texture7Resolution [4] = { this->m_image->getSize ()->X, this->m_image->getSize ()->Y, this->m_image->getSize ()->X, this->m_image->getSize ()->Y};
|
||||
|
||||
irr::video::IVideoDriver* driver = services->getVideoDriver ();
|
||||
|
||||
irr::core::matrix4 worldViewProj;worldViewProj.makeIdentity();
|
||||
worldViewProj = driver->getTransform(irr::video::ETS_PROJECTION);
|
||||
worldViewProj *= driver->getTransform(irr::video::ETS_VIEW);
|
||||
worldViewProj *= driver->getTransform(irr::video::ETS_WORLD);
|
||||
|
||||
std::vector<Render::Shaders::Parameters::CShaderParameter*>::const_iterator cur = this->m_vertexShader->getParameters ().begin ();
|
||||
std::vector<Render::Shaders::Parameters::CShaderParameter*>::const_iterator end = this->m_vertexShader->getParameters ().end ();
|
||||
|
||||
for (; cur != end; cur ++)
|
||||
{
|
||||
if ((*cur)->Is <CShaderParameterInteger> () == true)
|
||||
{
|
||||
services->setVertexShaderConstant (
|
||||
(*cur)->getName ().c_str (),
|
||||
(irr::s32*) (*cur)->getValue (),
|
||||
(*cur)->getSize ()
|
||||
);
|
||||
}
|
||||
else if (
|
||||
(*cur)->Is <CShaderParameterFloat> () == true ||
|
||||
(*cur)->Is <CShaderParameterVector2> () == true ||
|
||||
(*cur)->Is <CShaderParameterVector3> () == true ||
|
||||
(*cur)->Is <CShaderParameterVector4> () == true)
|
||||
{
|
||||
services->setVertexShaderConstant (
|
||||
(*cur)->getName ().c_str (),
|
||||
(irr::f32*) (*cur)->getValue (),
|
||||
(*cur)->getSize ()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
cur = this->m_pixelShader->getParameters ().begin ();
|
||||
end = this->m_pixelShader->getParameters ().end ();
|
||||
|
||||
for (; cur != end; cur ++)
|
||||
{
|
||||
if ((*cur)->Is <CShaderParameterInteger> () == true)
|
||||
{
|
||||
services->setPixelShaderConstant (
|
||||
(*cur)->getName ().c_str (),
|
||||
(irr::s32*) (*cur)->getValue (),
|
||||
(*cur)->getSize ()
|
||||
);
|
||||
}
|
||||
else if (
|
||||
(*cur)->Is <CShaderParameterFloat> () == true ||
|
||||
(*cur)->Is <CShaderParameterVector2> () == true ||
|
||||
(*cur)->Is <CShaderParameterVector3> () == true ||
|
||||
(*cur)->Is <CShaderParameterVector4> () == true)
|
||||
{
|
||||
services->setPixelShaderConstant (
|
||||
(*cur)->getName ().c_str (),
|
||||
(irr::f32*) (*cur)->getValue (),
|
||||
(*cur)->getSize ()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
services->setVertexShaderConstant ("g_Time", &g_Time, 1);
|
||||
services->setPixelShaderConstant ("g_Time", &g_Time, 1);
|
||||
|
||||
services->setVertexShaderConstant ("g_ModelViewProjectionMatrix", worldViewProj.pointer(), 16);
|
||||
|
||||
services->setVertexShaderConstant ("g_Texture0Resolution", g_Texture0Resolution, 4);
|
||||
services->setVertexShaderConstant ("g_Texture1Resolution", g_Texture1Resolution, 4);
|
||||
services->setVertexShaderConstant ("g_Texture2Resolution", g_Texture2Resolution, 4);
|
||||
services->setVertexShaderConstant ("g_Texture3Resolution", g_Texture3Resolution, 4);
|
||||
services->setVertexShaderConstant ("g_Texture4Resolution", g_Texture4Resolution, 4);
|
||||
services->setVertexShaderConstant ("g_Texture5Resolution", g_Texture5Resolution, 4);
|
||||
services->setVertexShaderConstant ("g_Texture6Resolution", g_Texture6Resolution, 4);
|
||||
services->setVertexShaderConstant ("g_Texture7Resolution", g_Texture7Resolution, 4);
|
||||
|
||||
services->setVertexShaderConstant ("g_Texture0Rotation", g_Texture0Rotation, 4);
|
||||
services->setVertexShaderConstant ("g_Texture1Rotation", g_Texture1Rotation, 4);
|
||||
services->setVertexShaderConstant ("g_Texture2Rotation", g_Texture2Rotation, 4);
|
||||
services->setVertexShaderConstant ("g_Texture3Rotation", g_Texture3Rotation, 4);
|
||||
services->setVertexShaderConstant ("g_Texture4Rotation", g_Texture4Rotation, 4);
|
||||
services->setVertexShaderConstant ("g_Texture5Rotation", g_Texture5Rotation, 4);
|
||||
services->setVertexShaderConstant ("g_Texture6Rotation", g_Texture6Rotation, 4);
|
||||
services->setVertexShaderConstant ("g_Texture7Rotation", g_Texture7Rotation, 4);
|
||||
|
||||
services->setPixelShaderConstant ("g_Texture0", &g_Texture0, 1);
|
||||
services->setPixelShaderConstant ("g_Texture1", &g_Texture1, 1);
|
||||
services->setPixelShaderConstant ("g_Texture2", &g_Texture2, 1);
|
||||
services->setPixelShaderConstant ("g_Texture3", &g_Texture3, 1);
|
||||
services->setPixelShaderConstant ("g_Texture4", &g_Texture4, 1);
|
||||
services->setPixelShaderConstant ("g_Texture5", &g_Texture5, 1);
|
||||
services->setPixelShaderConstant ("g_Texture6", &g_Texture6, 1);
|
||||
services->setPixelShaderConstant ("g_Texture7", &g_Texture7, 1);
|
||||
}
|
||||
|
||||
const std::string CImage::Type = "image";
|
@ -5,6 +5,8 @@
|
||||
#include "WallpaperEngine/Render/CObject.h"
|
||||
#include "WallpaperEngine/Render/CScene.h"
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Compiler.h"
|
||||
|
||||
using namespace WallpaperEngine;
|
||||
|
||||
namespace WallpaperEngine::Render::Objects
|
||||
@ -32,5 +34,8 @@ namespace WallpaperEngine::Render::Objects
|
||||
|
||||
Core::Objects::CImage* m_image;
|
||||
irr::core::aabbox3d<irr::f32> m_boundingBox;
|
||||
|
||||
Render::Shaders::Compiler* m_vertexShader;
|
||||
Render::Shaders::Compiler* m_pixelShader;
|
||||
};
|
||||
}
|
||||
|
@ -10,6 +10,13 @@
|
||||
#include <WallpaperEngine/Render/Shaders/Compiler.h>
|
||||
#include <WallpaperEngine/Core/Core.h>
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterFloat.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterInteger.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector2.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector3.h"
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameterVector4.h"
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders
|
||||
{
|
||||
Compiler::Compiler (irr::io::path& file, Type type, std::map<std::string, int>* combos, bool recursive)
|
||||
@ -438,6 +445,13 @@ namespace WallpaperEngine::Render::Shaders
|
||||
}
|
||||
}
|
||||
|
||||
if (this->m_recursive == false)
|
||||
{
|
||||
|
||||
std::cout << "======================== COMPILED SHADER " << this->m_file.c_str () << " ========================" << std::endl;
|
||||
std::cout << this->m_compiledContent << std::endl;
|
||||
}
|
||||
|
||||
return this->m_compiledContent;
|
||||
#undef BREAK_IF_ERROR
|
||||
}
|
||||
@ -499,102 +513,60 @@ namespace WallpaperEngine::Render::Shaders
|
||||
return;
|
||||
}
|
||||
|
||||
ShaderParameter* param = new ShaderParameter;
|
||||
Parameters::CShaderParameter* parameter = nullptr;
|
||||
|
||||
param->identifierName = (*material).get <std::string> ();
|
||||
param->variableName = name;
|
||||
param->type = type;
|
||||
|
||||
if (type == "vec4" || type == "vec3")
|
||||
if (type == "vec4")
|
||||
{
|
||||
if ((*defvalue).is_string () == false)
|
||||
{
|
||||
irr::core::vector3df* vector = new irr::core::vector3df;
|
||||
|
||||
vector->X = 0.0f;
|
||||
vector->Y = 0.0f;
|
||||
vector->Z = 0.0f;
|
||||
|
||||
param->defaultValue = vector;
|
||||
}
|
||||
else
|
||||
{
|
||||
irr::core::vector3df tmp = WallpaperEngine::Core::ato3vf ((*defvalue).get <std::string> ().c_str ());
|
||||
irr::core::vector3df* vector = new irr::core::vector3df;
|
||||
|
||||
vector->X = tmp.X;
|
||||
vector->Y = tmp.Y;
|
||||
vector->Z = tmp.Z;
|
||||
|
||||
param->defaultValue = vector;
|
||||
}
|
||||
parameter = new Parameters::CShaderParameterVector4 (
|
||||
WallpaperEngine::Core::ato3vf (*defvalue)
|
||||
);
|
||||
}
|
||||
else if (type == "vec3")
|
||||
{
|
||||
parameter = new Parameters::CShaderParameterVector3 (
|
||||
WallpaperEngine::Core::ato3vf (*defvalue)
|
||||
);
|
||||
}
|
||||
else if (type == "vec2")
|
||||
{
|
||||
if ((*defvalue).is_string () == false)
|
||||
{
|
||||
irr::core::vector2df* vector = new irr::core::vector2df;
|
||||
|
||||
vector->X = 0.0f;
|
||||
vector->Y = 0.0f;
|
||||
|
||||
param->defaultValue = vector;
|
||||
}
|
||||
else
|
||||
{
|
||||
irr::core::vector2df* vector = new irr::core::vector2df;
|
||||
irr::core::vector2df tmp = WallpaperEngine::Core::ato2vf ((*defvalue).get <std::string> ().c_str ());
|
||||
|
||||
vector->X = tmp.X;
|
||||
vector->Y = tmp.Y;
|
||||
|
||||
param->defaultValue = vector;
|
||||
}
|
||||
parameter = new Parameters::CShaderParameterVector2 (
|
||||
WallpaperEngine::Core::ato2vf (*defvalue)
|
||||
);
|
||||
}
|
||||
else if (type == "float")
|
||||
{
|
||||
if ((*defvalue).is_number () == false)
|
||||
{
|
||||
irr::f32* val = new irr::f32;
|
||||
|
||||
*val = 0.0f;
|
||||
|
||||
param->defaultValue = val;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
irr::f32* val = new irr::f32;
|
||||
|
||||
*val = (*defvalue).get <irr::f32> ();
|
||||
|
||||
param->defaultValue = val;
|
||||
}
|
||||
parameter = new Parameters::CShaderParameterFloat ((*defvalue).get <irr::f32> ());
|
||||
}
|
||||
else if (type == "int")
|
||||
{
|
||||
parameter = new Parameters::CShaderParameterInteger ((*defvalue).get <irr::s32> ());
|
||||
}
|
||||
else if (type == "sampler2D")
|
||||
{
|
||||
// samplers are not saved, we can ignore them for now
|
||||
delete param;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_error = true;
|
||||
this->m_errorInfo = "Unknown parameter type: " + type + " for " + param->identifierName + " (" + param->variableName + ")";
|
||||
this->m_errorInfo = "Unknown parameter type: " + type + " for " + name;
|
||||
return;
|
||||
}
|
||||
|
||||
this->m_parameters.push_back (param);
|
||||
parameter->setIdentifierName (*material);
|
||||
parameter->setName (name);
|
||||
|
||||
this->m_parameters.push_back (parameter);
|
||||
}
|
||||
|
||||
Compiler::ShaderParameter* Compiler::findParameter (std::string identifier)
|
||||
Parameters::CShaderParameter* Compiler::findParameter (std::string identifier)
|
||||
{
|
||||
std::vector<ShaderParameter*>::const_iterator cur = this->m_parameters.begin ();
|
||||
std::vector<ShaderParameter*>::const_iterator end = this->m_parameters.end ();
|
||||
std::vector<Parameters::CShaderParameter*>::const_iterator cur = this->m_parameters.begin ();
|
||||
std::vector<Parameters::CShaderParameter*>::const_iterator end = this->m_parameters.end ();
|
||||
|
||||
for (; cur != end; cur ++)
|
||||
{
|
||||
if ((*cur)->identifierName == identifier)
|
||||
if ((*cur)->getIdentifierName () == identifier)
|
||||
{
|
||||
return (*cur);
|
||||
}
|
||||
@ -603,7 +575,7 @@ namespace WallpaperEngine::Render::Shaders
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector <Compiler::ShaderParameter*>& Compiler::getParameters ()
|
||||
std::vector <Parameters::CShaderParameter*>& Compiler::getParameters ()
|
||||
{
|
||||
return this->m_parameters;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <WallpaperEngine/FileSystem/FileSystem.h>
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.h"
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders
|
||||
{
|
||||
@ -18,32 +19,6 @@ namespace WallpaperEngine::Render::Shaders
|
||||
class Compiler
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Basic struct used to define all the shader variables
|
||||
* the compiler will replace in pre-processing time
|
||||
* to make sure the shaders compile under OpenGL
|
||||
*/
|
||||
struct VariableReplacement
|
||||
{
|
||||
const char* original;
|
||||
const char* replacement;
|
||||
};
|
||||
|
||||
struct TypeName
|
||||
{
|
||||
const char* name;
|
||||
int size;
|
||||
};
|
||||
|
||||
struct ShaderParameter
|
||||
{
|
||||
std::string type;
|
||||
std::string variableName;
|
||||
std::string identifierName;
|
||||
void* defaultValue;
|
||||
void* range [2];
|
||||
};
|
||||
|
||||
/**
|
||||
* Types of shaders
|
||||
*/
|
||||
@ -87,12 +62,12 @@ namespace WallpaperEngine::Render::Shaders
|
||||
* @param identifier The identifier to search for
|
||||
* @return The shader information
|
||||
*/
|
||||
ShaderParameter* findParameter (std::string identifier);
|
||||
Parameters::CShaderParameter* findParameter (std::string identifier);
|
||||
|
||||
/**
|
||||
* @return The list of parameters available for this shader with their default values
|
||||
*/
|
||||
std::vector <ShaderParameter*>& getParameters ();
|
||||
std::vector <Parameters::CShaderParameter*>& getParameters ();
|
||||
|
||||
private:
|
||||
/**
|
||||
@ -227,7 +202,7 @@ namespace WallpaperEngine::Render::Shaders
|
||||
/**
|
||||
* The parameters the shader needs
|
||||
*/
|
||||
std::vector <ShaderParameter*> m_parameters;
|
||||
std::vector <Parameters::CShaderParameter*> m_parameters;
|
||||
/**
|
||||
* The combos the shader should be generated with
|
||||
*/
|
||||
|
@ -0,0 +1,46 @@
|
||||
#include "CShaderParameter.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Parameters;
|
||||
|
||||
CShaderParameter::CShaderParameter (void* defaultValue, void* value, std::string type) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (value),
|
||||
m_type (std::move(type))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void* CShaderParameter::getValue ()
|
||||
{
|
||||
if (this->m_value)
|
||||
return this->m_value;
|
||||
|
||||
return this->m_defaultValue;
|
||||
}
|
||||
|
||||
void CShaderParameter::setValue (void* value)
|
||||
{
|
||||
this->m_value = value;
|
||||
}
|
||||
|
||||
std::string CShaderParameter::getIdentifierName ()
|
||||
{
|
||||
return this->m_identifierName;
|
||||
}
|
||||
|
||||
std::string CShaderParameter::getName ()
|
||||
{
|
||||
return this->m_name;
|
||||
}
|
||||
|
||||
void CShaderParameter::setIdentifierName (std::string identifierName)
|
||||
{
|
||||
this->m_identifierName = std::move(identifierName);
|
||||
}
|
||||
|
||||
void CShaderParameter::setName (std::string name)
|
||||
{
|
||||
this->m_name = std::move(name);
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Parameters
|
||||
{
|
||||
class CShaderParameter
|
||||
{
|
||||
public:
|
||||
CShaderParameter (void* defaultValue, void* value, std::string type);
|
||||
|
||||
template<class T> const T* As () const { assert (Is<T> ()); return (const T*) this; }
|
||||
template<class T> T* As () { assert (Is<T> ()); return (T*) this; }
|
||||
|
||||
template<class T> bool Is () { return this->m_type == T::Type; }
|
||||
|
||||
std::string getIdentifierName ();
|
||||
std::string getName ();
|
||||
|
||||
void setIdentifierName (std::string identifierName);
|
||||
void setName (std::string name);
|
||||
void* getValue ();
|
||||
|
||||
virtual int getSize () = 0;
|
||||
|
||||
protected:
|
||||
void setValue (void* value);
|
||||
|
||||
private:
|
||||
std::string m_identifierName;
|
||||
std::string m_name;
|
||||
std::string m_type;
|
||||
|
||||
void* m_defaultValue;
|
||||
void* m_value;
|
||||
};
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
#include "CShaderParameterFloat.h"
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Parameters;
|
||||
|
||||
CShaderParameterFloat::CShaderParameterFloat(irr::f32 defaultValue) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (0),
|
||||
CShaderParameter (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CShaderParameterFloat::setValue (irr::f32 value)
|
||||
{
|
||||
this->m_value = value;
|
||||
|
||||
CShaderParameter::setValue (&this->m_value);
|
||||
}
|
||||
|
||||
int CShaderParameterFloat::getSize ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
const std::string CShaderParameterFloat::Type = "float";
|
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "CShaderParameter.h"
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Parameters
|
||||
{
|
||||
class CShaderParameterFloat : public CShaderParameter
|
||||
{
|
||||
public:
|
||||
CShaderParameterFloat (irr::f32 defaultValue);
|
||||
|
||||
int getSize () override;
|
||||
|
||||
void setValue (irr::f32 value);
|
||||
|
||||
static const std::string Type;
|
||||
|
||||
private:
|
||||
irr::f32 m_defaultValue;
|
||||
irr::f32 m_value;
|
||||
};
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
#include "CShaderParameterInteger.h"
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Parameters;
|
||||
|
||||
CShaderParameterInteger::CShaderParameterInteger(irr::s32 defaultValue) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (0),
|
||||
CShaderParameter (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CShaderParameterInteger::setValue (irr::s32 value)
|
||||
{
|
||||
this->m_value = value;
|
||||
CShaderParameter::setValue (&this->m_value);
|
||||
}
|
||||
|
||||
int CShaderParameterInteger::getSize ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
const std::string CShaderParameterInteger::Type = "int";
|
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "CShaderParameter.h"
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Parameters
|
||||
{
|
||||
class CShaderParameterInteger : public CShaderParameter
|
||||
{
|
||||
public:
|
||||
CShaderParameterInteger (irr::s32 defaultValue);
|
||||
|
||||
int getSize () override;
|
||||
|
||||
static const std::string Type;
|
||||
|
||||
void setValue (irr::s32 value);
|
||||
|
||||
private:
|
||||
irr::s32 m_defaultValue;
|
||||
irr::s32 m_value;
|
||||
};
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
#include "CShaderParameterVector2.h"
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Parameters;
|
||||
|
||||
CShaderParameterVector2::CShaderParameterVector2 (const irr::core::vector2df& defaultValue) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (irr::core::vector2df ()),
|
||||
CShaderParameter (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CShaderParameterVector2::setValue (irr::core::vector2df value)
|
||||
{
|
||||
this->m_value = value;
|
||||
|
||||
CShaderParameter::setValue (&this->m_value);
|
||||
}
|
||||
|
||||
int CShaderParameterVector2::getSize ()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
const std::string CShaderParameterVector2::Type = "vec2";
|
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.h"
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Parameters
|
||||
{
|
||||
class CShaderParameterVector2 : public CShaderParameter
|
||||
{
|
||||
public:
|
||||
CShaderParameterVector2 (const irr::core::vector2df& defaultValue);
|
||||
|
||||
int getSize () override;
|
||||
|
||||
void setValue (irr::core::vector2df value);
|
||||
|
||||
static const std::string Type;
|
||||
|
||||
private:
|
||||
irr::core::vector2df m_defaultValue;
|
||||
irr::core::vector2df m_value;
|
||||
};
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
#include "CShaderParameterVector3.h"
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Parameters;
|
||||
|
||||
CShaderParameterVector3::CShaderParameterVector3 (const irr::core::vector3df& defaultValue) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (irr::core::vector3df ()),
|
||||
CShaderParameter (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CShaderParameterVector3::setValue (irr::core::vector3df value)
|
||||
{
|
||||
this->m_value = value;
|
||||
CShaderParameter::setValue (&this->m_value);
|
||||
}
|
||||
|
||||
int CShaderParameterVector3::getSize ()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
const std::string CShaderParameterVector3::Type = "vec3";
|
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.h"
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Parameters
|
||||
{
|
||||
class CShaderParameterVector3 : public CShaderParameter
|
||||
{
|
||||
public:
|
||||
CShaderParameterVector3 (const irr::core::vector3df& defaultValue);
|
||||
|
||||
int getSize () override;
|
||||
|
||||
void setValue (irr::core::vector3df value);
|
||||
|
||||
static const std::string Type;
|
||||
|
||||
private:
|
||||
irr::core::vector3df m_defaultValue;
|
||||
irr::core::vector3df m_value;
|
||||
};
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
#include "CShaderParameterVector4.h"
|
||||
|
||||
using namespace WallpaperEngine::Render::Shaders::Parameters;
|
||||
|
||||
CShaderParameterVector4::CShaderParameterVector4 (const irr::core::vector3df& defaultValue) :
|
||||
m_defaultValue (defaultValue),
|
||||
m_value (irr::core::vector3df ()),
|
||||
CShaderParameter (&this->m_defaultValue, nullptr, Type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CShaderParameterVector4::setValue (irr::core::vector3df value)
|
||||
{
|
||||
this->m_value = value;
|
||||
CShaderParameter::setValue (&this->m_value);
|
||||
}
|
||||
|
||||
int CShaderParameterVector4::getSize ()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
const std::string CShaderParameterVector4::Type = "vec4";
|
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
|
||||
#include "WallpaperEngine/Render/Shaders/Parameters/CShaderParameter.h"
|
||||
|
||||
namespace WallpaperEngine::Render::Shaders::Parameters
|
||||
{
|
||||
class CShaderParameterVector4 : public CShaderParameter
|
||||
{
|
||||
public:
|
||||
CShaderParameterVector4 (const irr::core::vector3df& defaultValue);
|
||||
|
||||
int getSize () override;
|
||||
|
||||
void setValue (irr::core::vector3df value);
|
||||
|
||||
static const std::string Type;
|
||||
|
||||
private:
|
||||
irr::core::vector3df m_defaultValue;
|
||||
irr::core::vector3df m_value;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user