From 94217187eb2785939458f08d96c7b1b9e55439ab Mon Sep 17 00:00:00 2001 From: Julian T Date: Sun, 17 Jan 2021 00:09:15 +0100 Subject: Minor changed and draft for random sampling --- src/sampling/sampler.hpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/sampling/sampler.hpp (limited to 'src/sampling/sampler.hpp') diff --git a/src/sampling/sampler.hpp b/src/sampling/sampler.hpp new file mode 100644 index 0000000..cd52421 --- /dev/null +++ b/src/sampling/sampler.hpp @@ -0,0 +1,52 @@ +#ifndef SAMPLER_H +#define SAMPLER_H + +#include + +#include + +static const double LargestBelowOne = 0x1.fffffffffffffp-1; + +class Sampler { + public: + Sampler(long sampleCount) : m_sampleCount(sampleCount) {} + + /** @brief Start a new pixel sample + * + * Some samplers might find it usefull to get the position + */ + void startPixel(const Vec2d &p); + + /** @brief Called by renderers when a new sample begins + * + * @return Whether this is the last sample + */ + bool startNextSample(); + + /** @brief Get a single sample */ + virtual double getSample() = 0; + + /** @brief Get a 2d sample + * + * Algorithms can optimize for getting 2d samples + */ + virtual Vec2d get2dSample() = 0; + + /** @brief Clones the sampler + * + * Usefull when multiple threads need a sampler. + * + * @param seed Seed to set in cloned sampler + */ + virtual std::unique_ptr clone(int seed) = 0; + + const long m_sampleCount; + + protected: + Vec2d m_curPixel; + long m_curPixelSampleIndex; + +}; + + +#endif -- cgit v1.2.3