mirror of
https://github.com/vonhyou/ray-tracer-comp371.git
synced 2025-06-08 07:22:01 +00:00
bugfix: clamp
This commit is contained in:
parent
efab58561a
commit
b5878e06c9
4 changed files with 13 additions and 12 deletions
12
src/Light.cc
12
src/Light.cc
|
@ -30,16 +30,18 @@ Vector3f PointLight::illumination(const HitRecord &hit,
|
|||
return Vector3f::Zero();
|
||||
|
||||
Vector3f ambient_ = geometry->coefAmbient() * geometry->ambient();
|
||||
Vector3f diffuse_ = geometry->coefDiffuse() * diffuse.array() *
|
||||
geometry->diffuse().array() *
|
||||
|
||||
Vector3f diffuse_ = geometry->coefDiffuse() * geometry->diffuse().array() *
|
||||
diffuse.array() *
|
||||
std::max(0.0f, hit.normal().dot(rayDirection));
|
||||
|
||||
Vector3f halfWay = (hit.viewDirection() + rayDirection).normalized();
|
||||
Vector3f specular_ =
|
||||
geometry->coefSpecular() * specular.array() *
|
||||
geometry->specular().array() *
|
||||
geometry->coefSpecular() * geometry->specular().array() *
|
||||
specular.array() *
|
||||
pow(std::max(0.0f, hit.normal().dot(halfWay)), geometry->getPhong());
|
||||
return diffuse_ + specular_ + ambient_;
|
||||
|
||||
return specular_ + ambient_ + diffuse_;
|
||||
}
|
||||
|
||||
Vector3f AreaLight::illumination(const HitRecord &hit,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue