mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
102.72k stars 35.38k forks source link

Why does the specular term in Phong contain a diffuse component? #1470

Closed WestLangley closed 12 years ago

WestLangley commented 12 years ago

@alteredq In the Phong lighting calculations, you have added a diffuse term into the specular component like so:

dirSpecular += directionalLightColor[ i ] * uSpecularColor * dirSpecularWeight * dirDiffuseWeight;

From commit notes, you said you did this to avoid artefacts. Can you please explain what what going on? Could the artefacts, by chance, have been caused by something else?

alteredq commented 12 years ago

If I remember well, this was prompted by SIGGRAPH course from gamedev / FX guys about physically based shading. Check pages 12-15 here:

http://renderwonk.com/publications/s2010-shading-course/hoffman/s2010_physically_based_shading_hoffman_b.pdf

We kinda came full circle here - started with diffuse term multiplication (because it looked right), then changed to if (because everybody in tutorials did that), then changed back to diffuse term multiplication after reading this was indeed the correct way.

WestLangley commented 12 years ago

@alteredq Thank you. I have a lot of studying to do now. :-)