#ifndef __UNIFORM_SAMPLER_H__
#define __UNIFORM_SAMPLER_H__

#include "AbstractSampler.h"

#define UNIFORM_PIXEL_LODS 4
#define UNIFORM_SUBPIXEL_LODS 5
#define UNIFORM_LODS (UNIFORM_PIXEL_LODS + UNIFORM_SUBPIXEL_LODS)
#define TILE_SUBSIZE (1 << UNIFORM_SUBPIXEL_LODS)

namespace VRUT
{

	class UniformSampler : public AbstractSampler
	{

	protected:

		static const float stepTable[];
		int LOD0;

		void GenerateSamples(int LOD0);
		void GenerateSubSamples(int LOD0);

        //Generates indices for sparse pixel sotrage
        bool GenPixMapIsNecessary(std::map<uint64_t, unsigned int>& m, const Tile* tile, int numPixels) override;
	public:

		UniformSampler(int LOD0);
		virtual ~UniformSampler(void);

		virtual bool SamplePixels(Vector2 pixels[], Tile & tile);

	};


	class InfiniteUniformSampler : public AbstractSampler
	{

	protected:

		void GenerateSamples(int step);
		int step;
		bool half;
		float log2arr[100];
	public:

		//step = grid step size for 1 sample, half = use half of the samples
		InfiniteUniformSampler(int step, bool halfNow = false);
		virtual ~InfiniteUniformSampler(void);

		virtual bool SamplePixels(Vector2 pixels[], Tile & tile);
		bool GenPixMapIsNecessary(std::map<uint64_t, unsigned int>& m, const Tile* tile, int numPixels) override;
	};

}

#endif /* __UNIFORM_SAMPLER_H__ */
