aboutsummaryrefslogtreecommitdiff
path: root/src/render.hpp
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2020-08-13 20:06:29 +0200
committerJulian T <julian@jtle.dk>2020-08-13 20:06:29 +0200
commit5b0b916c561f602723b9ae80f5462a7939b652a1 (patch)
tree6ee419f0dd1649b2c329585551f06a555a631db8 /src/render.hpp
parent690b72664ca8d471f5c117f6ed87aeae2de0a208 (diff)
Pathtracing working with defuse and emissive lighting
Diffstat (limited to 'src/render.hpp')
-rw-r--r--src/render.hpp20
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;