-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntegrators.hpp
More file actions
67 lines (55 loc) · 2.96 KB
/
Integrators.hpp
File metadata and controls
67 lines (55 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#pragma once
#include "Interaction.hpp"
#include "LightSampler.hpp"
#include "Util.hpp"
class Scene;
class Camera;
class Sampler;
class Integrator{
public:
virtual ~Integrator() = default;
virtual void Render(unsigned int threadCount = std::thread::hardware_concurrency()) const = 0;
Integrator(const std::shared_ptr<Scene>& scene, const std::shared_ptr<Camera>& camera, const std::shared_ptr<Sampler>& sampler) : scene(scene), camera(camera), sampler(sampler){}
bool Unoccluded(const Ray& ray, float t) const;
bool Intersect(const Ray& ray, SurfaceInteraction& interaction, float max = std::numeric_limits<float>::infinity()) const;
bool IntersectTr(const Ray& ray, SurfaceInteraction& interaction, glm::vec3& Tr, float max = std::numeric_limits<float>::infinity()) const;
virtual glm::vec3 Li(Ray ray) const = 0;
protected:
std::shared_ptr<Scene> scene;
std::shared_ptr<Camera> camera;
std::shared_ptr<Sampler> sampler;
};
class TileIntegrator : public Integrator{
public:
virtual ~TileIntegrator() = default;
TileIntegrator(const std::shared_ptr<Scene>& scene, const std::shared_ptr<Camera>& camera, const std::shared_ptr<Sampler>& sampler) : Integrator(scene, camera, sampler){}
void Render(unsigned int threadCount = std::thread::hardware_concurrency()) const override;
};
class SimplePathIntegrator : public TileIntegrator{
public:
virtual ~SimplePathIntegrator() = default;
SimplePathIntegrator(const std::shared_ptr<Scene>& scene, const std::shared_ptr<Camera>& camera, const std::shared_ptr<Sampler>& sampler, uint32_t maxDepth) : TileIntegrator(scene, camera, sampler), maxDepth(maxDepth){}
glm::vec3 Li(Ray ray) const override;
protected:
uint32_t maxDepth;
};
class PathIntegrator : public TileIntegrator{
public:
virtual ~PathIntegrator() = default;
PathIntegrator(const std::shared_ptr<Scene>& scene, const std::shared_ptr<Camera>& camera, const std::shared_ptr<Sampler>& sampler, const std::shared_ptr<LightSampler>& lightSampler, uint32_t maxDepth) : TileIntegrator(scene, camera, sampler), lightSampler(lightSampler), maxDepth(maxDepth){}
glm::vec3 Li(Ray ray) const override;
protected:
glm::vec3 SampleLd(const Ray& ray, const SurfaceInteraction& interaction, float u, const glm::vec2& UV) const;
std::shared_ptr<LightSampler> lightSampler;
uint32_t maxDepth;
};
class VolPathIntegrator : public TileIntegrator{
public:
virtual ~VolPathIntegrator() = default;
VolPathIntegrator(const std::shared_ptr<Scene>& scene, const std::shared_ptr<Camera>& camera, const std::shared_ptr<Sampler>& sampler, const std::shared_ptr<LightSampler>& lightSampler, uint32_t maxDepth) : TileIntegrator(scene, camera, sampler), lightSampler(lightSampler), maxDepth(maxDepth){}
glm::vec3 Li(Ray ray) const override;
protected:
glm::vec3 SampleLd(const Ray& ray, const GeometricInteraction& interaction, float u, const glm::vec2& UV) const;
std::shared_ptr<LightSampler> lightSampler;
uint32_t maxDepth;
};