split render pipelines

This commit is contained in:
MihailRis 2025-05-09 15:31:04 +03:00
parent fc46b7c434
commit c1608fe8e2
13 changed files with 176 additions and 191 deletions

View file

@ -12,6 +12,8 @@ class DrawContext;
class ImageData;
class PostEffect;
class Camera;
class GBuffer;
class Shader;
struct PostProcessingVertex {
glm::vec2 position;
@ -25,29 +27,25 @@ struct PostProcessingVertex {
/// @attention Current implementation does not support multiple render passes
/// for multiple effects. Will be implemented in v0.21
class PostProcessing {
/// @brief Main framebuffer (lasy field)
std::unique_ptr<Framebuffer> fbo;
std::unique_ptr<Framebuffer> fboSecond;
/// @brief Fullscreen quad mesh as the post-processing canvas
std::unique_ptr<Mesh<PostProcessingVertex>> quadMesh;
std::vector<std::shared_ptr<PostEffect>> effectSlots;
std::vector<glm::vec3> ssaoKernel;
uint noiseTexture;
bool ssaoConfigured = false;
public:
PostProcessing(size_t effectSlotsCount);
~PostProcessing();
/// @brief Prepare and bind framebuffer
/// @param context graphics context will be modified
void use(DrawContext& context);
void use(DrawContext& context, bool gbufferPipeline);
/// @brief Render fullscreen quad using the passed shader
/// with framebuffer texture bound
/// @param context graphics context
/// @throws std::runtime_error if use(...) wasn't called before
void render(const DrawContext& context, const Assets& assets, float timer, const Camera& camera, uint depthMap);
void render(
const DrawContext& context,
const Assets& assets,
float timer,
const Camera& camera,
uint shadowMap
);
void setEffect(size_t slot, std::shared_ptr<PostEffect> effect);
@ -57,4 +55,24 @@ public:
std::unique_ptr<ImageData> toImage();
Framebuffer* getFramebuffer() const;
private:
void configureEffect(
const DrawContext& context,
Shader& shader,
float timer,
const Camera& camera,
uint shadowMap
);
/// @brief Main framebuffer (lasy field)
std::unique_ptr<Framebuffer> fbo;
std::unique_ptr<Framebuffer> fboSecond;
/// @brief Fullscreen quad mesh as the post-processing canvas
std::unique_ptr<Mesh<PostProcessingVertex>> quadMesh;
std::vector<std::shared_ptr<PostEffect>> effectSlots;
std::unique_ptr<GBuffer> gbuffer;
std::vector<glm::vec3> ssaoKernel;
uint noiseTexture;
bool ssaoConfigured = false;
};