| 718 | } |
| 719 | |
| 720 | void RendererBackend::ClearFramebufferData_(const bool clearScreen) { |
| 721 | // Always clear the main screen buffer, but only |
| 722 | // conditionally clean the custom frame buffer |
| 723 | glBindFramebuffer(GL_FRAMEBUFFER, 0); // default |
| 724 | glDepthMask(GL_TRUE); |
| 725 | glClearDepthf(1.0f); |
| 726 | glClearColor(frame_->clearColor.r, frame_->clearColor.g, frame_->clearColor.b, frame_->clearColor.a); |
| 727 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 728 | |
| 729 | if (clearScreen) { |
| 730 | const glm::vec4& color = frame_->clearColor; |
| 731 | state_.currentFrame.fbo.Clear(color); |
| 732 | state_.ssaoOcclusionBuffer.Clear(color); |
| 733 | state_.ssaoOcclusionBlurredBuffer.Clear(color); |
| 734 | state_.atmosphericFbo.Clear(glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); |
| 735 | state_.lightingFbo.Clear(glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); |
| 736 | state_.vpls.vplGIFbo.Clear(glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); |
| 737 | state_.vpls.vplGIDenoisedFbo1.Clear(glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); |
| 738 | state_.vpls.vplGIDenoisedFbo2.Clear(glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); |
| 739 | |
| 740 | // Depending on when this happens we may not have generated cascadeFbo yet |
| 741 | if (frame_->csc.fbo.Valid()) { |
| 742 | frame_->csc.fbo.Clear(glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); |
| 743 | //const int index = Engine::Instance()->FrameCount() % 4; |
| 744 | //_frame->csc.fbo.ClearDepthStencilLayer(index); |
| 745 | } |
| 746 | |
| 747 | for (auto& gaussian : state_.gaussianBuffers) { |
| 748 | gaussian.fbo.Clear(glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); |
| 749 | } |
| 750 | |
| 751 | for (auto& postFx : state_.postFxBuffers) { |
| 752 | postFx.fbo.Clear(glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)); |
| 753 | } |
| 754 | |
| 755 | state_.atmosphericPostFxBuffer.fbo.Clear(glm::vec4(0.0f)); |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | void RendererBackend::InitSSAO_() { |
| 760 | // Create k values 0 to 15 and randomize them |