-
Notifications
You must be signed in to change notification settings - Fork 0
/
A5.hpp
90 lines (66 loc) · 1.58 KB
/
A5.hpp
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Term--Spring 2022
#pragma once
#include <glm/glm.hpp>
#include "Atmosphere.hpp"
#include "Common.hpp"
#include "Options.hpp"
#include "SceneNode.hpp"
#include "Light.hpp"
#include "Image.hpp"
// forward declaration
class Material;
// void A4_Render(
// // What to render
// SceneNode *root,
// // Image to write to, set to a given width and height
// Image &image,
// // Viewing parameters
// const glm::vec3 &eye,
// const glm::vec3 &view,
// const glm::vec3 &up,
// double fovy,
// // Lighting parameters
// const glm::vec3 &ambient,
// const std::list<Light *> &lights);
class A5_Raytracer
{
public:
A5_Raytracer(
// Scene to render
SceneNode *root,
// Viewing parameters
const glm::vec3 &eye,
const glm::vec3 &view,
const glm::vec3 &up,
double fovy,
// Lighting parameters
const glm::vec3 &ambient,
std::list<Light *> &lights,
// DOF
double focalDistance,
double blurAmount);
int render(Image &image, double time=0);
private:
glm::vec3 getShading(const Ray &ray, int depth);
glm::vec3 getLightSample(Light *light, const Ray &primaryRay, const Material &material, const HitInfo &hit);
glm::vec3 tonemap(const glm::vec3 &in, float whitePoint=1.f);
/* PROVIDED DATA */
// Scene to render
SceneNode *m_root;
// Viewing parameters
const glm::vec3 &m_eye;
const glm::vec3 &m_view;
const glm::vec3 &m_up;
double m_fovy;
// Lighting parameters
const glm::vec3 &m_ambient;
std::list<Light *> &m_lights;
Light m_sun;
// DOF
double m_focalDistance;
double m_blurAmount;
Atmosphere atmosphere;
/* COMPUTED DATA */
size_t w;
size_t h;
};