#pragma once
#include "../Global.h"

#include <bgfx/bgfx.h>
#include <imgui.h>

struct DitherData
{
    static constexpr uint32_t BrightnessBucketCount = 256;
    Vec2 Points[4096];
    uint32_t PointCount = 0;
    Vec4 DitherTex[256 * 256 * 64];
    uint32_t DitherTexWH = 0;
    uint32_t DitherTexDepth = 0;
    int32_t BrightnessBuckets[BrightnessBucketCount];
    float BrightnessRamp[BrightnessBucketCount + 1];
    bgfx::TextureHandle PreviewTex = BGFX_INVALID_HANDLE;
    bgfx::TextureHandle FinalTex = BGFX_INVALID_HANDLE;
    bgfx::TextureHandle RampTex = BGFX_INVALID_HANDLE;

    bgfx::UniformHandle DitherSampler = BGFX_INVALID_HANDLE;
    bgfx::UniformHandle RampSampler = BGFX_INVALID_HANDLE;
    ImTextureID PreviewID = 0;
};

void DitherGen(DitherData& data, int32_t recursion);
