summaryrefslogtreecommitdiffstats
path: root/src/RenderConfigs.hpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/RenderConfigs.hpp60
1 files changed, 47 insertions, 13 deletions
diff --git a/src/RenderConfigs.hpp b/src/RenderConfigs.hpp
index 9b535ca..793dbb2 100644
--- a/src/RenderConfigs.hpp
+++ b/src/RenderConfigs.hpp
@@ -2,11 +2,49 @@
#include "Gal.hpp"
+std::shared_ptr<Gal::Shader> LoadVertexShader(std::string_view assetPath);
+
+std::shared_ptr<Gal::Shader> LoadPixelShader(std::string_view assetPath);
+
+class PostProcess {
+ std::shared_ptr<Gal::Framebuffer> framebuffer;
+ std::shared_ptr<Gal::Buffer> fbBuffer;
+ std::shared_ptr<Gal::Pipeline> pipeline;
+ std::shared_ptr<Gal::PipelineInstance> pipelineInstance;
+ std::shared_ptr<Gal::Texture> result;
+public:
+
+ PostProcess(
+ std::shared_ptr<Gal::Shader> pixelShader,
+ std::vector<std::pair<std::string_view, std::shared_ptr<Gal::Texture>>> inputTextures,
+ std::vector<std::pair<std::string_view, Gal::Type>> inputParameters,
+ size_t width,
+ size_t height,
+ Gal::Format format,
+ Gal::Filtering filtering);
+
+ void Clear() {
+ framebuffer->Clear();
+ }
+
+ void Render() {
+ pipeline->Activate();
+ pipelineInstance->Activate();
+ pipelineInstance->Render(0, 6);
+ }
+
+ template<typename T>
+ void SetShaderParameter(std::string_view name, T value) {
+ pipeline->SetShaderParameter(name, value);
+ }
+
+ std::shared_ptr<Gal::Texture> GetResultTexture() {
+ return result;
+ }
+};
+
class Gbuffer {
- std::shared_ptr<Gal::Framebuffer> lightFramebuffer;
- std::shared_ptr<Gal::Buffer> lightBuffer;
- std::shared_ptr<Gal::Pipeline> lightPipeline;
- std::shared_ptr<Gal::PipelineInstance> lightPipelineInstance;
+ std::unique_ptr<PostProcess> lightingPass;
std::shared_ptr<Gal::Texture> color; //RGB - color
std::shared_ptr<Gal::Texture> normal; //RGB - normal
std::shared_ptr<Gal::Texture> addColor; //RGB - addColor
@@ -14,8 +52,6 @@ class Gbuffer {
std::shared_ptr<Gal::Texture> depthStencil;
std::shared_ptr<Gal::Framebuffer> geomFramebuffer;
- std::shared_ptr<Gal::Texture> finalColor;
-
public:
Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH);
@@ -24,22 +60,20 @@ public:
}
std::shared_ptr<Gal::Texture> GetFinalTexture() {
- return finalColor;
+ return lightingPass->GetResultTexture();
}
void Render() {
- lightPipeline->Activate();
- lightPipelineInstance->Activate();
- lightPipelineInstance->Render(0, 6);
+ lightingPass->Render();
}
void Clear() {
geomFramebuffer->Clear();
- lightFramebuffer->Clear();
+ lightingPass->Clear();
}
void SetDayTime(float dayTime) {
- lightPipeline->SetShaderParameter("dayTime", dayTime);
+ lightingPass->SetShaderParameter("dayTime", dayTime);
}
int GetMaxRenderBuffers() {
@@ -47,6 +81,6 @@ public:
}
void SetRenderBuff(int renderBuff) {
- lightPipeline->SetShaderParameter("renderBuff", renderBuff);
+ lightingPass->SetShaderParameter("renderBuff", renderBuff);
}
};