Arbitrary changes

This commit is contained in:
arvid schröder 2022-11-29 00:56:08 +01:00
parent 71502fe38b
commit e0038838d4

View file

@ -14,13 +14,11 @@ Color PhongShader::shade(Scene const &scene, Ray const &ray) const {
for (auto &light: scene.lights()) {
auto illum = light->illuminate(scene, ray);
auto omegaI = normalized(illum.direction);
auto omegaR = 2 * dotProduct(omegaI, ray.normal) * ray.normal - omegaI;
auto cosPsi = dotProduct(ray.direction, omegaR);
auto colorI = diffuseCoefficient * diffuseColor / PI +
(specularCoefficient * specularColor * std::pow(cosPsi, shininessExponent));
fragmentColor += illum.color * colorI;
Vector3d omegaI = normalized(illum.direction);
Vector3d omegaR = 2 * dotProduct(omegaI, ray.normal) * ray.normal - omegaI;
float cosPsi = std::max(0.0f, dotProduct(ray.direction, omegaR));
fragmentColor += illum.color * diffuseCoefficient * diffuseColor / PI
+ illum.color * specularCoefficient * specularColor * std::pow(cosPsi, shininessExponent);
}
return fragmentColor;