summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2019-11-05 20:29:13 -0500
committerDavid Thompson <dthompson2@worcester.edu>2019-11-05 20:29:13 -0500
commit3499f89b1ac683ee8d52e7963b108b712239215d (patch)
treee11b4268c7ed4f4077e01eb4c0e2f1afc0caef91
parent3cd5be71054fae67705c306726b65631c13b7634 (diff)
render: phong: Zero out specular factor when material shininess is 0.
-rw-r--r--chickadee/render/phong.scm5
1 files changed, 4 insertions, 1 deletions
diff --git a/chickadee/render/phong.scm b/chickadee/render/phong.scm
index a07f682..886e910 100644
--- a/chickadee/render/phong.scm
+++ b/chickadee/render/phong.scm
@@ -192,7 +192,10 @@ void main() {
float diffuseFactor = max(dot(lightDir, fragNorm), 0.0);
vec3 diffuseColor = diffuseFactor * baseDiffuseColor * material.diffuse;
vec3 reflectDir = reflect(-lightDir, fragNorm);
- float specularFactor = pow(max(dot(lightDir, reflectDir), 0.0), material.shininess);
+ float specularFactor = 0;
+ if(material.shininess > 0) {
+ specularFactor = pow(max(dot(lightDir, reflectDir), 0.0), material.shininess);
+ }
vec3 specularColor = specularFactor * baseSpecularColor * material.specular;
gl_FragColor = vec4(ambientColor + diffuseColor + specularColor, 1.0);
}