Merge remote-tracking branch 'upstream/main'

This commit is contained in:
vaxerski 2023-04-20 22:11:54 +01:00
commit 1f6cc8206f
5 changed files with 66 additions and 10 deletions

View File

@ -13,6 +13,7 @@
float g_Time; float g_Time;
float g_TimeLast; float g_TimeLast;
float g_Daytime;
namespace WallpaperEngine::Application namespace WallpaperEngine::Application
{ {
@ -349,7 +350,14 @@ namespace WallpaperEngine::Application
void CWallpaperApplication::renderFrame() { void CWallpaperApplication::renderFrame() {
float startTime, endTime, minimumTime = 1.0f / this->m_context.settings.render.maximumFPS; static float startTime, endTime, minimumTime = 1.0f / this->m_context.settings.render.maximumFPS;
static time_t seconds;
static struct tm* timeinfo;
// update g_Daytime
time (&seconds);
timeinfo = localtime(&seconds);
g_Daytime = ((timeinfo->tm_hour * 60) + timeinfo->tm_min) / (24.0 * 60.0);
// update audio recorder // update audio recorder
audioDriver->update (); audioDriver->update ();

View File

@ -263,6 +263,8 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
this->getScene ()->getCamera ()->getLookAt (); this->getScene ()->getCamera ()->getLookAt ();
this->m_modelViewProjectionCopy = glm::ortho <float> (0.0, size.x, 0.0, size.y); this->m_modelViewProjectionCopy = glm::ortho <float> (0.0, size.x, 0.0, size.y);
this->m_modelMatrix = glm::ortho <float> (0.0, size.x, 0.0, size.y);
this->m_viewProjectionMatrix = glm::mat4 (1.0);
} }
void CImage::setup () void CImage::setup ()
@ -363,6 +365,9 @@ void CImage::setupPasses ()
glm::mat4* projection = (first) ? &this->m_modelViewProjectionCopy : &this->m_modelViewProjectionPass; glm::mat4* projection = (first) ? &this->m_modelViewProjectionCopy : &this->m_modelViewProjectionPass;
first = false; first = false;
pass->setModelMatrix (&this->m_modelMatrix);
pass->setViewProjectionMatrix (&this->m_viewProjectionMatrix);
// set viewport and target texture if needed // set viewport and target texture if needed
if (pass->getMaterial ()->getMaterial ()->hasTarget ()) if (pass->getMaterial ()->getMaterial ()->hasTarget ())
{ {

View File

@ -74,6 +74,9 @@ namespace WallpaperEngine::Render::Objects
glm::mat4 m_modelViewProjectionPass; glm::mat4 m_modelViewProjectionPass;
glm::mat4 m_modelViewProjectionCopy; glm::mat4 m_modelViewProjectionCopy;
glm::mat4 m_modelMatrix;
glm::mat4 m_viewProjectionMatrix;
CFBO* m_mainFBO; CFBO* m_mainFBO;
CFBO* m_subFBO; CFBO* m_subFBO;
CFBO* m_currentMainFBO; CFBO* m_currentMainFBO;

View File

@ -21,6 +21,7 @@ using namespace WallpaperEngine::Render::Shaders::Variables;
using namespace WallpaperEngine::Render::Objects::Effects; using namespace WallpaperEngine::Render::Objects::Effects;
extern float g_Time; extern float g_Time;
extern float g_Daytime;
CPass::CPass (CMaterial* material, Core::Objects::Images::Materials::CPass* pass) : CPass::CPass (CMaterial* material, Core::Objects::Images::Materials::CPass* pass) :
Helpers::CContextAware (material), Helpers::CContextAware (material),
@ -201,6 +202,9 @@ void CPass::render ()
case Matrix4: case Matrix4:
glUniformMatrix4fv (entry->id, 1, GL_FALSE, glm::value_ptr (*reinterpret_cast <const glm::mat4*> (entry->value))); glUniformMatrix4fv (entry->id, 1, GL_FALSE, glm::value_ptr (*reinterpret_cast <const glm::mat4*> (entry->value)));
break; break;
case Matrix3:
glUniformMatrix3fv (entry->id, 1, GL_FALSE, glm::value_ptr (*reinterpret_cast <const glm::mat3*> (entry->value)));
break;
} }
} }
// add reference uniforms // add reference uniforms
@ -231,6 +235,9 @@ void CPass::render ()
case Matrix4: case Matrix4:
glUniformMatrix4fv (entry->id, 1, GL_FALSE, glm::value_ptr (*reinterpret_cast <const glm::mat4*> (*entry->value))); glUniformMatrix4fv (entry->id, 1, GL_FALSE, glm::value_ptr (*reinterpret_cast <const glm::mat4*> (*entry->value)));
break; break;
case Matrix3:
glUniformMatrix3fv (entry->id, 1, GL_FALSE, glm::value_ptr (*reinterpret_cast <const glm::mat3*> (*entry->value)));
break;
} }
} }
@ -301,11 +308,16 @@ void CPass::setModelViewProjectionMatrix (const glm::mat4* projection)
this->m_modelViewProjectionMatrix = projection; this->m_modelViewProjectionMatrix = projection;
} }
void CPass::setModelMatrix (glm::mat4 model) void CPass::setModelMatrix (const glm::mat4* model)
{ {
this->m_modelMatrix = model; this->m_modelMatrix = model;
} }
void CPass::setViewProjectionMatrix (const glm::mat4* viewProjection)
{
this->m_viewProjectionMatrix = viewProjection;
}
void CPass::setTexCoord (GLuint texcoord) void CPass::setTexCoord (GLuint texcoord)
{ {
this->a_TexCoord = texcoord; this->a_TexCoord = texcoord;
@ -579,6 +591,9 @@ void CPass::setupUniforms ()
auto projection = this->getMaterial ()->getImage ()->getScene ()->getScene ()->getOrthogonalProjection (); auto projection = this->getMaterial ()->getImage ()->getScene ()->getScene ()->getOrthogonalProjection ();
// lighting variables
this->addUniform ("g_LightAmbientColor", this->m_material->getImage ()->getScene ()->getScene ()->getAmbientColor ());
this->addUniform ("g_LightSkylightColor", this->m_material->getImage ()->getScene ()->getScene ()->getSkylightColor ());
// register variables like brightness and alpha with some default value // register variables like brightness and alpha with some default value
this->addUniform ("g_Brightness", this->m_material->getImage ()->getImage ()->getBrightness ()); this->addUniform ("g_Brightness", this->m_material->getImage ()->getImage ()->getBrightness ());
this->addUniform ("g_UserAlpha", this->m_material->getImage ()->getImage ()->getAlpha ()); this->addUniform ("g_UserAlpha", this->m_material->getImage ()->getImage ()->getAlpha ());
@ -588,8 +603,12 @@ void CPass::setupUniforms ()
this->addUniform ("g_CompositeColor", this->m_material->getImage ()->getImage ()->getColor ()); this->addUniform ("g_CompositeColor", this->m_material->getImage ()->getImage ()->getColor ());
// add some external variables // add some external variables
this->addUniform ("g_Time", &g_Time); this->addUniform ("g_Time", &g_Time);
this->addUniform ("g_Daytime", &g_Daytime);
// add model-view-projection matrix // add model-view-projection matrix
this->addUniform ("g_ModelViewProjectionMatrix", &this->m_modelViewProjectionMatrix); this->addUniform ("g_ModelViewProjectionMatrix", &this->m_modelViewProjectionMatrix);
this->addUniform ("g_ModelMatrix", &this->m_modelMatrix);
this->addUniform ("g_NormalModelMatrix", glm::identity <glm::mat3> ());
this->addUniform ("g_ViewProjectionMatrix", &this->m_viewProjectionMatrix);
this->addUniform ("g_PointerPosition", this->m_material->getImage ()->getScene ()->getMousePosition ()); this->addUniform ("g_PointerPosition", this->m_material->getImage ()->getScene ()->getMousePosition ());
this->addUniform ("g_PointerPositionLast", this->m_material->getImage ()->getScene ()->getMousePositionLast ()); this->addUniform ("g_PointerPositionLast", this->m_material->getImage ()->getScene ()->getMousePositionLast ());
this->addUniform ("g_EffectTextureProjectionMatrix", glm::mat4(1.0)); this->addUniform ("g_EffectTextureProjectionMatrix", glm::mat4(1.0));
@ -899,6 +918,21 @@ void CPass::addUniform (const std::string& name, const glm::vec4** value)
this->addUniform (name, UniformType::Vector4, value); this->addUniform (name, UniformType::Vector4, value);
} }
void CPass::addUniform (const std::string& name, glm::mat3 value)
{
this->addUniform (name, UniformType::Matrix3, value);
}
void CPass::addUniform (const std::string& name, const glm::mat3* value)
{
this->addUniform (name, UniformType::Matrix3, value, 1);
}
void CPass::addUniform (const std::string& name, const glm::mat3** value)
{
this->addUniform (name, UniformType::Matrix3, value);
}
void CPass::addUniform (const std::string& name, glm::mat4 value) void CPass::addUniform (const std::string& name, glm::mat4 value)
{ {
this->addUniform (name, UniformType::Matrix4, value); this->addUniform (name, UniformType::Matrix4, value);

View File

@ -32,7 +32,8 @@ namespace WallpaperEngine::Render::Objects::Effects
void setTexCoord (GLuint texcoord); void setTexCoord (GLuint texcoord);
void setPosition (GLuint position); void setPosition (GLuint position);
void setModelViewProjectionMatrix (const glm::mat4* projection); void setModelViewProjectionMatrix (const glm::mat4* projection);
void setModelMatrix (glm::mat4 model); void setModelMatrix (const glm::mat4* model);
void setViewProjectionMatrix (const glm::mat4* viewProjection);
const CMaterial* getMaterial () const; const CMaterial* getMaterial () const;
Core::Objects::Images::Materials::CPass* getPass (); Core::Objects::Images::Materials::CPass* getPass ();
@ -41,12 +42,13 @@ namespace WallpaperEngine::Render::Objects::Effects
enum UniformType enum UniformType
{ {
Float = 0, Float = 0,
Matrix4 = 1, Matrix3 = 1,
Integer = 2, Matrix4 = 2,
Vector2 = 3, Integer = 3,
Vector3 = 4, Vector2 = 4,
Vector4 = 5, Vector3 = 5,
Double = 6 Vector4 = 6,
Double = 7
}; };
class UniformEntry class UniformEntry
@ -102,6 +104,7 @@ namespace WallpaperEngine::Render::Objects::Effects
void addUniform (const std::string& name, glm::vec2 value); void addUniform (const std::string& name, glm::vec2 value);
void addUniform (const std::string& name, glm::vec3 value); void addUniform (const std::string& name, glm::vec3 value);
void addUniform (const std::string& name, glm::vec4 value); void addUniform (const std::string& name, glm::vec4 value);
void addUniform (const std::string& name, glm::mat3 value);
void addUniform (const std::string& name, glm::mat4 value); void addUniform (const std::string& name, glm::mat4 value);
void addUniform (const std::string& name, const int* value, int count = 1); void addUniform (const std::string& name, const int* value, int count = 1);
void addUniform (const std::string& name, const double* value, int count = 1); void addUniform (const std::string& name, const double* value, int count = 1);
@ -109,6 +112,7 @@ namespace WallpaperEngine::Render::Objects::Effects
void addUniform (const std::string& name, const glm::vec2* value); void addUniform (const std::string& name, const glm::vec2* value);
void addUniform (const std::string& name, const glm::vec3* value); void addUniform (const std::string& name, const glm::vec3* value);
void addUniform (const std::string& name, const glm::vec4* value); void addUniform (const std::string& name, const glm::vec4* value);
void addUniform (const std::string& name, const glm::mat3* value);
void addUniform (const std::string& name, const glm::mat4* value); void addUniform (const std::string& name, const glm::mat4* value);
void addUniform (const std::string& name, const int** value); void addUniform (const std::string& name, const int** value);
void addUniform (const std::string& name, const double** value); void addUniform (const std::string& name, const double** value);
@ -116,6 +120,7 @@ namespace WallpaperEngine::Render::Objects::Effects
void addUniform (const std::string& name, const glm::vec2** value); void addUniform (const std::string& name, const glm::vec2** value);
void addUniform (const std::string& name, const glm::vec3** value); void addUniform (const std::string& name, const glm::vec3** value);
void addUniform (const std::string& name, const glm::vec4** value); void addUniform (const std::string& name, const glm::vec4** value);
void addUniform (const std::string& name, const glm::mat3** value);
void addUniform (const std::string& name, const glm::mat4** value); void addUniform (const std::string& name, const glm::mat4** value);
template <typename T> void addUniform (const std::string& name, UniformType type, T value); template <typename T> void addUniform (const std::string& name, UniformType type, T value);
template <typename T> void addUniform (const std::string& name, UniformType type, T* value, int count = 1); template <typename T> void addUniform (const std::string& name, UniformType type, T* value, int count = 1);
@ -132,7 +137,8 @@ namespace WallpaperEngine::Render::Objects::Effects
std::map<std::string, UniformEntry*> m_uniforms; std::map<std::string, UniformEntry*> m_uniforms;
std::map<std::string, ReferenceUniformEntry*> m_referenceUniforms; std::map<std::string, ReferenceUniformEntry*> m_referenceUniforms;
const glm::mat4* m_modelViewProjectionMatrix; const glm::mat4* m_modelViewProjectionMatrix;
glm::mat4 m_modelMatrix; const glm::mat4* m_modelMatrix;
const glm::mat4* m_viewProjectionMatrix;
/** /**
* Contains the final map of textures to be used * Contains the final map of textures to be used