improve shading & enable disabled elements

This commit is contained in:
MihailRis
2025-05-09 21:52:29 +03:00
parent c1608fe8e2
commit 657b4304b4
9 changed files with 70 additions and 45 deletions
+1
View File
@@ -111,6 +111,7 @@ GBuffer::~GBuffer() {
void GBuffer::bind() {
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glClear(GL_COLOR_BUFFER_BIT);
}
void GBuffer::unbind() {
+17 -8
View File
@@ -72,17 +72,21 @@ void PostProcessing::use(DrawContext& context, bool gbufferPipeline) {
}
context.setFramebuffer(gbuffer.get());
} else {
if (fbo) {
fbo->resize(vp.x, vp.y);
fboSecond->resize(vp.x, vp.y);
} else {
fbo = std::make_unique<Framebuffer>(vp.x, vp.y);
fboSecond = std::make_unique<Framebuffer>(vp.x, vp.y);
}
refreshFbos(vp.x, vp.y);
context.setFramebuffer(fbo.get());
}
}
void PostProcessing::refreshFbos(uint width, uint height) {
if (fbo) {
fbo->resize(width, height);
fboSecond->resize(width, height);
} else {
fbo = std::make_unique<Framebuffer>(width, height);
fboSecond = std::make_unique<Framebuffer>(width, height);
}
}
void PostProcessing::configureEffect(
const DrawContext& context,
Shader& shader,
@@ -127,6 +131,9 @@ void PostProcessing::render(
totalPasses += (effect != nullptr && effect->isActive());
}
const auto& vp = context.getViewport();
refreshFbos(vp.x, vp.y);
if (gbuffer) {
gbuffer->bindBuffers();
@@ -157,7 +164,9 @@ void PostProcessing::render(
auto& shader = effect->use();
configureEffect(context, shader, timer, camera, shadowMap);
fbo->getTexture()->bind();
if (currentPass > 1) {
fbo->getTexture()->bind();
}
if (currentPass < totalPasses) {
fboSecond->bind();
+2
View File
@@ -64,6 +64,8 @@ private:
uint shadowMap
);
void refreshFbos(uint width, uint height);
/// @brief Main framebuffer (lasy field)
std::unique_ptr<Framebuffer> fbo;
std::unique_ptr<Framebuffer> fboSecond;