Added directional light type
This commit is contained in:
1 parent
5c10fdc1a4
commit
f749b29c31
10 files changed
+66
-54
No files matched your search
@@ -67,6 +67,10 @@ namespace nf {
|
||||
return m_position;
|
||||
}
|
||||
|
||||
const Vec3& Camera::getRotation() {
|
||||
return m_front;
|
||||
}
|
||||
|
||||
void Camera::bind(Shader* shader) {
|
||||
glm::mat4 view;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace nf {
|
||||
|
||||
}
|
||||
|
||||
void Light::create(const Vec3& position, const Vec3& color, Type type, float strength) {
|
||||
void Light::create(const Vec3& position, const Vec3& color, float strength, Type type) {
|
||||
m_constructed = true;
|
||||
m_position = position;
|
||||
m_color = color;
|
||||
@@ -32,37 +32,33 @@ namespace nf {
|
||||
m_color = color;
|
||||
}
|
||||
|
||||
void Light::setStrength(double strength) {
|
||||
m_strength = (float)strength;
|
||||
}
|
||||
|
||||
void Light::bind(Shader* shader, unsigned int lightNumber) {
|
||||
glm::vec3 pos(m_position.x, m_position.y, m_position.z);
|
||||
glm::vec3 color(m_color.x, m_color.y, m_color.z);
|
||||
std::string stringPos = "light[";
|
||||
std::string stringLocation = std::to_string(lightNumber);
|
||||
stringPos += stringLocation;
|
||||
stringPos += std::to_string(lightNumber);
|
||||
stringPos += "].";
|
||||
std::string lightPos = stringPos + (std::string)"pos";
|
||||
std::string lightColor = stringPos + (std::string)"color";
|
||||
std::string lightStrength = stringPos + (std::string)"strength";
|
||||
glm::vec3 pos(m_position.x, m_position.y, m_position.z);
|
||||
glm::vec3 color(m_color.x, m_color.y, m_color.z);
|
||||
shader->setUniform(lightPos, pos);
|
||||
shader->setUniform(lightColor, color);
|
||||
//switch (m_type) {
|
||||
// case Type::DIRECTIONAL: {
|
||||
// shader->setUniform(lightType.c_str(), 1);
|
||||
// std::string lightConsant = light + (std::string)"falloffConstant";
|
||||
// std::string lightLinear = light + (std::string)"falloffLinear";
|
||||
// std::string lightQuad = light + (std::string)"falloffQuad";
|
||||
// shader->setUniform(lightConsant.c_str(), 1.0f);
|
||||
// shader->setUniform(lightLinear.c_str(), 0.7f);
|
||||
// shader->setUniform(lightQuad.c_str(), 1.8f);
|
||||
// break;
|
||||
// }
|
||||
// case Type::POINT: {
|
||||
// //shader->setUniform(lightType.c_str(), 2);
|
||||
// break;
|
||||
// }
|
||||
// case Type::SPOTLIGHT: {
|
||||
// shader->setUniform(lightType.c_str(), 3);
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
shader->setUniform(lightStrength, m_strength);
|
||||
std::string lightType = stringPos + (std::string)"type";
|
||||
switch (m_type) {
|
||||
case Type::DIRECTIONAL: {
|
||||
shader->setUniform(lightType, 1);
|
||||
break;
|
||||
}
|
||||
case Type::POINT: {
|
||||
shader->setUniform(lightType, 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Light::Type Light::getType() {
|
||||
|
||||
Reference in new issue
Block a user