mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-14 13:22:23 +08:00
Fixes #160, xray effects on full image layers weren't working properly. Should fix anything using the inverse matrix of modelViewProjection
Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
73ef4d6dbf
commit
a713ad001a
@ -18,8 +18,11 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
|
|||||||
m_texcoordPass (GL_NONE),
|
m_texcoordPass (GL_NONE),
|
||||||
m_passSpacePosition (GL_NONE),
|
m_passSpacePosition (GL_NONE),
|
||||||
m_modelViewProjectionScreen (),
|
m_modelViewProjectionScreen (),
|
||||||
|
m_modelViewProjectionScreenInverse (),
|
||||||
m_modelViewProjectionCopy (),
|
m_modelViewProjectionCopy (),
|
||||||
|
m_modelViewProjectionCopyInverse (),
|
||||||
m_modelViewProjectionPass (glm::mat4 (1.0)),
|
m_modelViewProjectionPass (glm::mat4 (1.0)),
|
||||||
|
m_modelViewProjectionPassInverse (glm::inverse (m_modelViewProjectionPass)),
|
||||||
m_pos ()
|
m_pos ()
|
||||||
{
|
{
|
||||||
auto projection = this->getScene ()->getScene ()->getOrthogonalProjection ();
|
auto projection = this->getScene ()->getScene ()->getOrthogonalProjection ();
|
||||||
@ -262,7 +265,10 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
|
|||||||
this->getScene ()->getCamera ()->getProjection () *
|
this->getScene ()->getCamera ()->getProjection () *
|
||||||
this->getScene ()->getCamera ()->getLookAt ();
|
this->getScene ()->getCamera ()->getLookAt ();
|
||||||
|
|
||||||
|
this->m_modelViewProjectionScreenInverse = glm::inverse (this->m_modelViewProjectionScreen);
|
||||||
|
|
||||||
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_modelViewProjectionCopyInverse = glm::inverse (this->m_modelViewProjectionCopy);
|
||||||
this->m_modelMatrix = 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);
|
this->m_viewProjectionMatrix = glm::mat4 (1.0);
|
||||||
}
|
}
|
||||||
@ -363,6 +369,7 @@ void CImage::setupPasses ()
|
|||||||
const CFBO* prevDrawTo = drawTo;
|
const CFBO* prevDrawTo = drawTo;
|
||||||
GLuint spacePosition = (first) ? this->getCopySpacePosition () : this->getPassSpacePosition ();
|
GLuint spacePosition = (first) ? this->getCopySpacePosition () : this->getPassSpacePosition ();
|
||||||
glm::mat4* projection = (first) ? &this->m_modelViewProjectionCopy : &this->m_modelViewProjectionPass;
|
glm::mat4* projection = (first) ? &this->m_modelViewProjectionCopy : &this->m_modelViewProjectionPass;
|
||||||
|
glm::mat4* inverseProjection = (first) ? &this->m_modelViewProjectionCopyInverse : &this->m_modelViewProjectionPassInverse;
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
pass->setModelMatrix (&this->m_modelMatrix);
|
pass->setModelMatrix (&this->m_modelMatrix);
|
||||||
@ -388,6 +395,7 @@ void CImage::setupPasses ()
|
|||||||
spacePosition = this->getSceneSpacePosition ();
|
spacePosition = this->getSceneSpacePosition ();
|
||||||
drawTo = this->getScene ()->getFBO ();
|
drawTo = this->getScene ()->getFBO ();
|
||||||
projection = &this->m_modelViewProjectionScreen;
|
projection = &this->m_modelViewProjectionScreen;
|
||||||
|
inverseProjection = &this->m_modelViewProjectionScreenInverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
pass->setDestination (drawTo);
|
pass->setDestination (drawTo);
|
||||||
@ -395,6 +403,7 @@ void CImage::setupPasses ()
|
|||||||
pass->setPosition (spacePosition);
|
pass->setPosition (spacePosition);
|
||||||
pass->setTexCoord (texcoord);
|
pass->setTexCoord (texcoord);
|
||||||
pass->setModelViewProjectionMatrix (projection);
|
pass->setModelViewProjectionMatrix (projection);
|
||||||
|
pass->setModelViewProjectionMatrixInverse (inverseProjection);
|
||||||
|
|
||||||
texcoord = this->getTexCoordPass ();
|
texcoord = this->getTexCoordPass ();
|
||||||
drawTo = prevDrawTo;
|
drawTo = prevDrawTo;
|
||||||
|
@ -73,6 +73,9 @@ namespace WallpaperEngine::Render::Objects
|
|||||||
glm::mat4 m_modelViewProjectionScreen;
|
glm::mat4 m_modelViewProjectionScreen;
|
||||||
glm::mat4 m_modelViewProjectionPass;
|
glm::mat4 m_modelViewProjectionPass;
|
||||||
glm::mat4 m_modelViewProjectionCopy;
|
glm::mat4 m_modelViewProjectionCopy;
|
||||||
|
glm::mat4 m_modelViewProjectionScreenInverse;
|
||||||
|
glm::mat4 m_modelViewProjectionPassInverse;
|
||||||
|
glm::mat4 m_modelViewProjectionCopyInverse;
|
||||||
|
|
||||||
glm::mat4 m_modelMatrix;
|
glm::mat4 m_modelMatrix;
|
||||||
glm::mat4 m_viewProjectionMatrix;
|
glm::mat4 m_viewProjectionMatrix;
|
||||||
|
@ -308,6 +308,11 @@ void CPass::setModelViewProjectionMatrix (const glm::mat4* projection)
|
|||||||
this->m_modelViewProjectionMatrix = projection;
|
this->m_modelViewProjectionMatrix = projection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CPass::setModelViewProjectionMatrixInverse (const glm::mat4* projection)
|
||||||
|
{
|
||||||
|
this->m_modelViewProjectionMatrixInverse = projection;
|
||||||
|
}
|
||||||
|
|
||||||
void CPass::setModelMatrix (const glm::mat4* model)
|
void CPass::setModelMatrix (const glm::mat4* model)
|
||||||
{
|
{
|
||||||
this->m_modelMatrix = model;
|
this->m_modelMatrix = model;
|
||||||
@ -605,6 +610,7 @@ void CPass::setupUniforms ()
|
|||||||
this->addUniform ("g_Time", &g_Time);
|
this->addUniform ("g_Time", &g_Time);
|
||||||
this->addUniform ("g_Daytime", &g_Daytime);
|
this->addUniform ("g_Daytime", &g_Daytime);
|
||||||
// add model-view-projection matrix
|
// add model-view-projection matrix
|
||||||
|
this->addUniform("g_ModelViewProjectionMatrixInverse", &this->m_modelViewProjectionMatrixInverse);
|
||||||
this->addUniform ("g_ModelViewProjectionMatrix", &this->m_modelViewProjectionMatrix);
|
this->addUniform ("g_ModelViewProjectionMatrix", &this->m_modelViewProjectionMatrix);
|
||||||
this->addUniform ("g_ModelMatrix", &this->m_modelMatrix);
|
this->addUniform ("g_ModelMatrix", &this->m_modelMatrix);
|
||||||
this->addUniform ("g_NormalModelMatrix", glm::identity <glm::mat3> ());
|
this->addUniform ("g_NormalModelMatrix", glm::identity <glm::mat3> ());
|
||||||
|
@ -32,6 +32,7 @@ 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 setModelViewProjectionMatrixInverse (const glm::mat4* projection);
|
||||||
void setModelMatrix (const glm::mat4* model);
|
void setModelMatrix (const glm::mat4* model);
|
||||||
void setViewProjectionMatrix (const glm::mat4* viewProjection);
|
void setViewProjectionMatrix (const glm::mat4* viewProjection);
|
||||||
|
|
||||||
@ -137,6 +138,7 @@ 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;
|
||||||
|
const glm::mat4* m_modelViewProjectionMatrixInverse;
|
||||||
const glm::mat4* m_modelMatrix;
|
const glm::mat4* m_modelMatrix;
|
||||||
const glm::mat4* m_viewProjectionMatrix;
|
const glm::mat4* m_viewProjectionMatrix;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user