-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLight.h
80 lines (66 loc) · 1.84 KB
/
Light.h
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
/*
Light.h
*/
#ifndef I_LIGHT
#define I_LIGHT
#include <glm/glm.hpp>
enum LightType { POINT, DIRECTIONAL, AREA };
enum AreaType { RECT };
// Raytracing //
typedef struct _Light {
glm::dvec4 posdir;
glm::dvec3 color;
LightType type;
AreaType areaType;
int numSamples; // Per square side! So numSamples = 3 -> 9 samples taken.
glm::dvec4 upStep;
glm::dvec4 rightStep;
} Light;
// Pathtracing //
class AreaLight {
public:
virtual void getSample(const glm::dvec3& position, const glm::dvec3& normal, glm::dvec3& lightIntensity,
glm::dvec3& incidentRay) = 0;
};
/*
Quad light is defined py a position, an upVec, and a rightVec.
^ = = = = = = o
| <-upVec |
| |
*------------>o
^ ^
position rightVec
*/
class QuadLight : public AreaLight {
public:
QuadLight(glm::dvec3 position, glm::dvec3 upVec, glm::dvec3 rightVec, glm::dvec3 color);
~QuadLight();
void getSample(const glm::dvec3& position, const glm::dvec3& normal, glm::dvec3& lightIntensity,
glm::dvec3& lightRay);
private:
glm::dvec3 position;
glm::dvec3 upVec;
glm::dvec3 rightVec;
glm::dvec3 color;
double area;
glm::dvec3 normal;
};
/*
Circle light defined by a position, a normal, and a radius
*/
/*
class CircleLight : public Arealight {
public:
CircleLight(glm::vec4 position, glm::vec3 normal, float radius, glm::vec3 color);
~CircleLight();
void getSample(const glm::vec3& position, const glm::vec3& normal,
glm::vec3& lightIntensity, glm::vec3& incidentRay);
private:
glm::vec4 position;
glm::vec3 normal;
float radius;
glm::vec3 color;
float area;
};
*/
#endif