-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLight.cpp
More file actions
30 lines (26 loc) · 762 Bytes
/
Copy pathLight.cpp
File metadata and controls
30 lines (26 loc) · 762 Bytes
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
#include "Light.h"
PointLight::PointLight(vec3 pos, Color col){
this->lightPos = pos;
this->lightCol = col;
this->type = LightType::Point;
}
void PointLight::generateLightRay(LocalGeo& geo, Ray* lray, Color* lcol){
vec3 source = geo.pos;
vec3 dir = glm::normalize(this->lightPos - source);
lray -> pos = source;
lray -> dir = dir;
*lcol = this->lightCol;
}
DirectionalLight::DirectionalLight(vec3 dir, Color col){
this->lightPos = dir;
this->lightCol = col;
this->type = LightType::Directional;
}
void DirectionalLight::generateLightRay(LocalGeo& geo, Ray* lray, Color* lcol){
vec3 source = geo.pos;
vec3 zero = vec3(0,0,0);
vec3 dir = glm::normalize(zero-(this->lightPos));
lray -> pos = source;
lray -> dir = dir;
*lcol = this->lightCol;
}