added emission as ambient component of the phong material
This commit is contained in:
parent
96619f4f0f
commit
f2f1965a2d
@ -1,6 +1,7 @@
|
||||
#version 330 core
|
||||
|
||||
// material
|
||||
uniform vec3 materialAmbient;
|
||||
uniform vec3 materialKd;
|
||||
uniform vec3 materialKs;
|
||||
uniform float materialNs;
|
||||
@ -40,6 +41,6 @@ void main(void) {
|
||||
for(i=1; i<nbPointLights+1; ++i)
|
||||
light += computeLight(kd, materialKs, materialNs, pointLights[i*2 -1], varNormal, lightDirInView[i], halfVecInView[i]);
|
||||
|
||||
outColor = vec4(light, 1);
|
||||
outColor = vec4(materialAmbient + light, 1);
|
||||
}
|
||||
|
||||
|
@ -12,9 +12,10 @@ void PhongMaterial::updateShader()
|
||||
void PhongMaterial::bindAttributes()
|
||||
{
|
||||
shader->bind();
|
||||
shader->bindVec3(shader->getLocation("materialKd"), kd);
|
||||
shader->bindVec3(shader->getLocation("materialKs"), ks);
|
||||
shader->bindFloat(shader->getLocation("materialNs"), ns);
|
||||
shader->bindVec3(shader->getLocation("materialAmbient"), emission);
|
||||
shader->bindVec3(shader->getLocation("materialKd"), diffuse);
|
||||
shader->bindVec3(shader->getLocation("materialKs"), specular);
|
||||
shader->bindFloat(shader->getLocation("materialNs"), shininess);
|
||||
if(diffuse_texture != NULL)
|
||||
{
|
||||
diffuse_texture->bind(TEX_ID);
|
||||
|
@ -9,17 +9,18 @@ class Texture;
|
||||
class PhongMaterial : public Material
|
||||
{
|
||||
public:
|
||||
glm::vec3 kd;
|
||||
glm::vec3 ks;
|
||||
float ns;
|
||||
glm::vec3 emission;
|
||||
glm::vec3 diffuse;
|
||||
glm::vec3 specular;
|
||||
float shininess;
|
||||
Texture* diffuse_texture;
|
||||
Texture* normal_map;
|
||||
|
||||
PhongMaterial() : kd(0.5f), ks(0.5f), ns(10), diffuse_texture(NULL)
|
||||
PhongMaterial() : emission(0), diffuse(0.5f), specular(0.5f), shininess(10), diffuse_texture(NULL)
|
||||
{
|
||||
updateShader();
|
||||
}
|
||||
PhongMaterial(glm::vec3 myKd, glm::vec3 myKs, float myNs) : kd(myKd), ks(myKs), ns(myNs), diffuse_texture(NULL)
|
||||
PhongMaterial(glm::vec3 myKd, glm::vec3 myKs, float myNs) : emission(0), diffuse(myKd), specular(myKs), shininess(myNs), diffuse_texture(NULL)
|
||||
{
|
||||
updateShader();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#version 330 core
|
||||
|
||||
// material
|
||||
uniform vec3 materialAmbient;
|
||||
uniform vec3 materialKd;
|
||||
uniform vec3 materialKs;
|
||||
uniform float materialNs;
|
||||
@ -43,6 +44,6 @@ void main(void) {
|
||||
for(i=1; i<nbPointLights+1; ++i)
|
||||
light += computeLight(kd, materialKs, materialNs, pointLights[i*2 -1], varNormal, lightDirInView[i], halfVecInView[i]);
|
||||
|
||||
outColor = vec4(light, 1);
|
||||
outColor = vec4(materialAmbient + light, 1);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user