From 7976b6e48429c1180a7f94a32e5455ebcb310a1f Mon Sep 17 00:00:00 2001 From: Anselme Date: Sun, 6 Sep 2015 21:24:43 +0200 Subject: [PATCH] cf sparrowEditor commit --- phongmaterial.h | 16 ++++++++++++++-- phongtexture.frag | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/phongmaterial.h b/phongmaterial.h index 78a8d1c..4a9e2e1 100644 --- a/phongmaterial.h +++ b/phongmaterial.h @@ -16,11 +16,23 @@ public: Texture* diffuse_texture; Texture* normal_map; - PhongMaterial() : emission(0), diffuse(0.5f), specular(0.5f), shininess(10), diffuse_texture(NULL) + PhongMaterial() : + emission(0), + diffuse(0.5f), + specular(0.5f), + shininess(10), + diffuse_texture(NULL), + normal_map(NULL) { updateShader(); } - PhongMaterial(glm::vec3 myKd, glm::vec3 myKs, float myNs) : emission(0), diffuse(myKd), specular(myKs), shininess(myNs), diffuse_texture(NULL) + PhongMaterial(glm::vec3 myKd, glm::vec3 myKs, float myNs) : + emission(0), + diffuse(myKd), + specular(myKs), + shininess(myNs), + diffuse_texture(NULL), + normal_map(NULL) { updateShader(); } diff --git a/phongtexture.frag b/phongtexture.frag index bc8151c..edcf858 100644 --- a/phongtexture.frag +++ b/phongtexture.frag @@ -39,7 +39,7 @@ vec3 computeLight(in vec3 kd, in vec3 ks, in float ns, in vec3 color, in vec3 no void main(void) { int i; - vec3 kd = vec3(texture2D(baseTexture, varTexCoord)); + vec3 kd = vec3(texture2D(baseTexture, varTexCoord))*materialKd; vec3 light = 0.1*kd + computeLight(kd, materialKs, materialNs, dirLight[1], varNormal, lightDirInView[0], halfVecInView[0]); for(i=1; i