Forgot a `facing` component
mysteryDate opened this issue · 0 comments
mysteryDate commented
From http://developer.download.nvidia.com/CgTutorial/cg_tutorial_chapter05.html:
Additionally, the specular term is forced to zero if the diffuse term is zero because N · L (from diffuse lighting) is negative. This ensures that specular highlights do not appear on geometry that faces away from the light.
So line 9 should read:
return pow(step(0.0, dot(surfaceNormal, lightDirection)) * max(0.0, dot(viewDirection, R)), shininess);
Or something like that.