summaryrefslogtreecommitdiff
path: root/data/shaders/phong-frag.glsl
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2021-08-08 14:15:25 -0400
committerDavid Thompson <dthompson2@worcester.edu>2021-08-08 14:15:25 -0400
commit16e1b624d6191ffc876f9dcd15d305606f04ddc0 (patch)
tree18df526a202d665bea373e31e3c69f7c445528dc /data/shaders/phong-frag.glsl
parentc513792d394a180ca9deada60b4d5091fc478f4f (diff)
graphics: phong: Use Blinn-Phong method for specular highlights.
Diffstat (limited to 'data/shaders/phong-frag.glsl')
-rw-r--r--data/shaders/phong-frag.glsl3
1 files changed, 2 insertions, 1 deletions
diff --git a/data/shaders/phong-frag.glsl b/data/shaders/phong-frag.glsl
index 9d8e40c..7cab3f8 100644
--- a/data/shaders/phong-frag.glsl
+++ b/data/shaders/phong-frag.glsl
@@ -174,7 +174,8 @@ void main() {
float diffuseFactor = posDot(lightDir, normal);
vec3 reflectDir = reflect(-lightDir, normal);
vec3 diffuseColor = baseDiffuseColor * diffuseFactor;
- float specularFactor = pow(posDot(viewDir, reflectDir), material.shininess);
+ vec3 halfVector = normalize(lightDir + viewDir);
+ float specularFactor = pow(posDot(halfVector, normal), material.shininess);
vec3 specularColor = baseSpecularColor * specularFactor;
color += (diffuseColor + specularColor) * radiance;
}