#ifndef COMBINE_STAGE_HPP_
#define COMBINE_STAGE_HPP_

#include <PipelineStage/DrawStage/DrawStage.hpp>
#include <Vk/DescriptorSet/DescriptorSet.hpp>
#include <Vk/Framebuffer/Framebuffer.hpp>

/**
 * @brief The draw stage at which we combine the skybox, solid and translucent layers, with lighting.
 */
class CombineStage : public DrawStage
{
private:
    std::shared_ptr<Vk::Buffer> combineDataBuffer;
    std::shared_ptr<Vk::DescriptorSet> skyboxDescSet;

    struct CombineData
    {
        alignas(16) glm::mat4 proj;
        alignas(16) glm::mat4 view;
        alignas(16) glm::mat4 model;
        alignas(16) glm::vec3 color;
        alignas(8) glm::vec2 screenSize;
        float playerZ;
        float farZ;
        float verticalViewDistance;
        int debugMode;
        int fxaaEnabled;
        int godRaySamples;
    };

protected:
    virtual VkExtent2D getFramebufferExtent() override;

public:
    CombineStage(
        FrameDrawer &frameDrawer,
        std::shared_ptr<Vk::DescriptorPool> combineDescriptorPool
    );

    /**
     * @brief Update the shader data.
     */
    void updateData();

    virtual void onFrameBegins() override;
};

#endif