-
Notifications
You must be signed in to change notification settings - Fork 0
/
Light.cpp
48 lines (40 loc) · 1.27 KB
/
Light.cpp
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
#include "Light.h"
//Refer https://learnopengl.com/Lighting/Basic-Lighting
Light::Light()
:AmbientColour{ glm::vec3(1.0f,0.0f,0.0f) },
AmbientIntensity{ 1.0f },
DiffuseIntensity{ 1.0f },
LightProjection{ glm::mat4(1.f) },
ShadowMapWidth{1024},
ShadowMapHeight{1024 },
//LightProjection{ glm::mat4(1.f) },
sMap{nullptr}
{
sMap = new ShadowMap();
}
Light::Light(glm::vec4 AmbientLightParams, GLfloat DiffuseIntensity, GLuint SMapWidth, GLuint SMapHeight)
: AmbientColour{ glm::vec3(AmbientLightParams.x,AmbientLightParams.y,AmbientLightParams.z) },
AmbientIntensity{ AmbientLightParams.w },
DiffuseIntensity{DiffuseIntensity},
ShadowMapWidth{SMapWidth},
ShadowMapHeight{SMapHeight},
LightProjection{ glm::mat4(1.f) },
sMap{ nullptr }
{
sMap = new ShadowMap();
}
void Light::UseLight(GLuint AmbientColorLocation, GLuint AmbientIntensityLocation,GLuint DiffuseIntensityUniformLocation)
{
//Passes light information into the shaders
glUniform3f(AmbientColorLocation, AmbientColour.x, AmbientColour.y, AmbientColour.z);
glUniform1f(AmbientIntensityLocation, AmbientIntensity);
glUniform1f(DiffuseIntensityUniformLocation, DiffuseIntensity);
}
void Light::CreateShadowMap()
{
sMap->Init(ShadowMapWidth, ShadowMapHeight);
}
ShadowMap* Light::GetShadowMap()
{
return sMap;
}