diff options
Diffstat (limited to 'src/render.hpp')
-rw-r--r-- | src/render.hpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/render.hpp b/src/render.hpp index bb4e9c5..1274bb5 100644 --- a/src/render.hpp +++ b/src/render.hpp @@ -5,13 +5,28 @@ #include "ray.hpp" #include "scene.hpp" +// Samples a random direction in a hemisphere, cosine weighed +// https://blog.thomaspoulet.fr/uniform-sampling-on-unit-hemisphere/ +class Sampler { + public: + Sampler(); + void seed(unsigned seed); + + Vec3d sample(const Vec3d &norm); + + private: + double random(); + unsigned m_seed; +}; + class Renderer { public: - Renderer(const Scene &scn, Vec3d eye, Vec3d target, unsigned width, unsigned height); + Renderer(const Scene &scn, Vec3d eye, Vec3d target, unsigned width, unsigned height, unsigned maxhops); - Color render(unsigned x, unsigned y); + Color render(unsigned x, unsigned y, unsigned samples); unsigned m_width, m_height; + Sampler m_sampler; private: void recalculate(); @@ -27,6 +42,7 @@ class Renderer { // User options Vec3d m_eye, m_target; + unsigned m_maxhops; // Calculated values Vec3d m_qx, m_qy, m_blc; |