Math cleanup.
This commit is contained in:
parent
373ebda28d
commit
ca47d4a84b
1 changed files with 2 additions and 2 deletions
|
@ -14,10 +14,10 @@ Color PhongShader::shade(Scene const &scene, Ray const &ray) const {
|
|||
for (auto &light: scene.lights()) {
|
||||
auto illum = light->illuminate(scene, ray);
|
||||
|
||||
Vector3d reflection = illum.direction - 2 * dotProduct(illum.direction, ray.normal) * ray.normal;
|
||||
Vector3d reflection = 2 * dotProduct(illum.direction, ray.normal) * ray.normal - illum.direction;
|
||||
Color diffuse = diffuseCoefficient * dotProduct(illum.direction, -ray.normal) * diffuseColor;
|
||||
Color specular = specularCoefficient * specularColor
|
||||
* std::pow(dotProduct(ray.direction, -reflection), shininessExponent);
|
||||
* std::pow(dotProduct(ray.direction, reflection), shininessExponent);
|
||||
fragmentColor += illum.color * diffuse + illum.color * specular;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue