mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 13:56:48 +08:00
Better approach on rendering the bloom effect, uses one less draw call
Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
parent
cdaebbe893
commit
b5b7824233
10
main.cpp
10
main.cpp
@ -227,16 +227,6 @@ CVirtualContainer* buildVirtualContainer ()
|
|||||||
"\t\t\t\t\t\"index\": 1"
|
"\t\t\t\t\t\"index\": 1"
|
||||||
"\t\t\t\t}"
|
"\t\t\t\t}"
|
||||||
"\t\t\t]"
|
"\t\t\t]"
|
||||||
"\t\t},"
|
|
||||||
"\t\t{"
|
|
||||||
"\t\t\t\"material\": \"materials/wpenginelinux.json\","
|
|
||||||
"\t\t\t\"bind\":"
|
|
||||||
"\t\t\t["
|
|
||||||
"\t\t\t\t{"
|
|
||||||
"\t\t\t\t\t\"name\": \"_rt_imageLayerComposite_-1_b\","
|
|
||||||
"\t\t\t\t\t\"index\": 0"
|
|
||||||
"\t\t\t\t}"
|
|
||||||
"\t\t\t]"
|
|
||||||
"\t\t}"
|
"\t\t}"
|
||||||
"\t]"
|
"\t]"
|
||||||
"}"
|
"}"
|
||||||
|
@ -102,15 +102,6 @@ CScene::CScene (Core::CScene* scene, CContext* context) :
|
|||||||
sceneWidth / 8, sceneHeight / 8
|
sceneWidth / 8, sceneHeight / 8
|
||||||
);
|
);
|
||||||
|
|
||||||
this->_rt_FullFrameBuffer_b = this->createFBO (
|
|
||||||
"_rt_FullFrameBuffer_b",
|
|
||||||
ITexture::TextureFormat::ARGB8888,
|
|
||||||
ITexture::TextureFlags::NoInterpolation,
|
|
||||||
1.0,
|
|
||||||
sceneWidth, sceneHeight,
|
|
||||||
sceneWidth, sceneHeight
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Had to get a little creative with the effects to achieve the same bloom effect without any custom code
|
// Had to get a little creative with the effects to achieve the same bloom effect without any custom code
|
||||||
// this custom image loads some effect files from the virtual container to achieve the same bloom effect
|
// this custom image loads some effect files from the virtual container to achieve the same bloom effect
|
||||||
@ -164,14 +155,15 @@ CScene::CScene (Core::CScene* scene, CContext* context) :
|
|||||||
auto json = nlohmann::json::parse (imagejson);
|
auto json = nlohmann::json::parse (imagejson);
|
||||||
|
|
||||||
// create image for bloom passes
|
// create image for bloom passes
|
||||||
auto bloomPass = this->createObject (
|
if (this->getScene ()->isBloom () == true)
|
||||||
|
this->m_bloomObject = this->createObject (
|
||||||
WallpaperEngine::Core::CObject::fromJSON (
|
WallpaperEngine::Core::CObject::fromJSON (
|
||||||
json, this->getContainer ()
|
json, this->getContainer ()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this->getScene ()->isBloom () == true)
|
this->_rt_imageCompositeLayer_bloom = this->findFBO ("_rt_imageLayerComposite_-1_b");
|
||||||
this->m_objectsByRenderOrder.emplace_back (bloomPass);
|
this->_rt_FullFrameBuffer = this->m_sceneFBO;
|
||||||
}
|
}
|
||||||
|
|
||||||
Render::CObject* CScene::createObject (Core::CObject* object)
|
Render::CObject* CScene::createObject (Core::CObject* object)
|
||||||
@ -252,6 +244,8 @@ void CScene::renderFrame (glm::ivec4 viewport)
|
|||||||
this->m_parallaxDisplacement.y = glm::mix (this->m_parallaxDisplacement.y, (this->m_mousePosition.y * amount) * influence, delay);
|
this->m_parallaxDisplacement.y = glm::mix (this->m_parallaxDisplacement.y, (this->m_mousePosition.y * amount) * influence, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->m_sceneFBO = this->_rt_FullFrameBuffer;
|
||||||
|
|
||||||
// use the scene's framebuffer by default
|
// use the scene's framebuffer by default
|
||||||
glBindFramebuffer (GL_FRAMEBUFFER, this->getWallpaperFramebuffer());
|
glBindFramebuffer (GL_FRAMEBUFFER, this->getWallpaperFramebuffer());
|
||||||
// ensure we render over the whole screen
|
// ensure we render over the whole screen
|
||||||
@ -261,6 +255,12 @@ void CScene::renderFrame (glm::ivec4 viewport)
|
|||||||
|
|
||||||
for (; cur != end; cur ++)
|
for (; cur != end; cur ++)
|
||||||
(*cur)->render ();
|
(*cur)->render ();
|
||||||
|
|
||||||
|
if (this->getScene ()->isBloom () == true)
|
||||||
|
{
|
||||||
|
this->m_sceneFBO = this->_rt_imageCompositeLayer_bloom;
|
||||||
|
this->m_bloomObject->render ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScene::updateMouse (glm::ivec4 viewport)
|
void CScene::updateMouse (glm::ivec4 viewport)
|
||||||
|
@ -36,6 +36,7 @@ namespace WallpaperEngine::Render
|
|||||||
Render::CObject* createObject (Core::CObject* object);
|
Render::CObject* createObject (Core::CObject* object);
|
||||||
|
|
||||||
CCamera* m_camera;
|
CCamera* m_camera;
|
||||||
|
CObject* m_bloomObject;
|
||||||
std::map<int, CObject*> m_objects;
|
std::map<int, CObject*> m_objects;
|
||||||
std::vector<CObject*> m_objectsByRenderOrder;
|
std::vector<CObject*> m_objectsByRenderOrder;
|
||||||
glm::vec2 m_mousePosition;
|
glm::vec2 m_mousePosition;
|
||||||
@ -43,6 +44,7 @@ namespace WallpaperEngine::Render
|
|||||||
CFBO* _rt_4FrameBuffer;
|
CFBO* _rt_4FrameBuffer;
|
||||||
CFBO* _rt_8FrameBuffer;
|
CFBO* _rt_8FrameBuffer;
|
||||||
CFBO* _rt_Bloom;
|
CFBO* _rt_Bloom;
|
||||||
CFBO* _rt_FullFrameBuffer_b; // this one doesn't exist on the official wallpaper engine, but our approach requires it
|
CFBO* _rt_imageCompositeLayer_bloom; // this one doesn't exist on the official wallpaper engine, but our approach requires it
|
||||||
|
CFBO* _rt_FullFrameBuffer;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -92,14 +92,6 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
|
|||||||
GLfloat realWidth = this->m_texture->getRealWidth () / 2.0f;
|
GLfloat realWidth = this->m_texture->getRealWidth () / 2.0f;
|
||||||
GLfloat realHeight = this->m_texture->getRealHeight () / 2.0f;
|
GLfloat realHeight = this->m_texture->getRealHeight () / 2.0f;
|
||||||
|
|
||||||
// TODO: XXXHACK: QUICK HACK TO MAKE BLOOM LAYER BEHAVE IN A SPECIAL WAY, PREVENTS VERTICAL FLIP
|
|
||||||
if (this->getId () == 0xFFFFFFFF)
|
|
||||||
{
|
|
||||||
float tmpy = this->m_pos.y;
|
|
||||||
this->m_pos.y = this->m_pos.w;
|
|
||||||
this->m_pos.w = tmpy;
|
|
||||||
}
|
|
||||||
|
|
||||||
// build a list of vertices, these might need some change later (or maybe invert the camera)
|
// build a list of vertices, these might need some change later (or maybe invert the camera)
|
||||||
GLfloat sceneSpacePosition [] = {
|
GLfloat sceneSpacePosition [] = {
|
||||||
this->m_pos.x, this->m_pos.y, 0.0f,
|
this->m_pos.x, this->m_pos.y, 0.0f,
|
||||||
|
Loading…
Reference in New Issue
Block a user