From a5818dfd044c7c66fcb5870fee026a80415c9500 Mon Sep 17 00:00:00 2001 From: 4VRDriver <44267643+4VRDriver@users.noreply.github.com> Date: Sun, 20 Sep 2020 12:46:45 +0200 Subject: [PATCH] Implement Blinn-Phong instead of Phong --- res/shaders/basic.frag | 4 ++-- src/World.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/res/shaders/basic.frag b/res/shaders/basic.frag index e6f71e6..9919065 100644 --- a/res/shaders/basic.frag +++ b/res/shaders/basic.frag @@ -166,8 +166,8 @@ void computeShading( float diffuseShading = max(dot(normal, lightDir), 0.0f); // Specular shading - vec3 reflectDir = reflect(-lightDir, normal); - float specularShading = pow(max(dot(viewDir, reflectDir), 0.0f), u_material.shininess); + vec3 halfwayDir = normalize(lightDir + viewDir); + float specularShading = pow(max(dot(normal, halfwayDir), 0.0f), u_material.shininess); vec4 diffuseTex = texture(u_material.texture_diffuse0, v_texCoord); vec4 specularTex = texture(u_material.texture_specular0, v_texCoord); diff --git a/src/World.cpp b/src/World.cpp index 5bac0af..edf570e 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -20,7 +20,7 @@ World::World(ShaderProgram *shaderProgram) // This will be removed in future when gloss maps are implemented shaderProgram->bind(); - shaderProgram->setUniform("u_material.shininess", 32.0f); + shaderProgram->setUniform("u_material.shininess", 64.0f); shaderProgram->unbind(); }