mirror of
https://github.com/vonhyou/ray-tracer-comp371.git
synced 2025-06-08 07:22:01 +00:00
reformat geometry
This commit is contained in:
parent
d95b0f85e2
commit
08cbf7733f
4 changed files with 39 additions and 39 deletions
11
src/Light.cc
11
src/Light.cc
|
@ -27,20 +27,19 @@ Vector3f PointLight::illumination(const HitRecord &hit,
|
|||
|
||||
for (auto g : geometries)
|
||||
if (g != geometry && g->intersect(shadowRay).hasValue() &&
|
||||
g->getType() == Geometry::Type::SPHERE)
|
||||
g->type() == Geometry::Type::SPHERE)
|
||||
return Vector3f::Zero();
|
||||
|
||||
Vector3f ambient_ = geometry->coefAmbient() * geometry->ambient();
|
||||
Vector3f ambient_ = geometry->ka() * geometry->ca();
|
||||
|
||||
Vector3f diffuse_ = geometry->coefDiffuse() * geometry->diffuse().array() *
|
||||
Vector3f diffuse_ = geometry->kd() * geometry->cd().array() *
|
||||
diffuse.array() *
|
||||
std::max(0.0f, hit.normal().dot(rayDirection));
|
||||
|
||||
Vector3f halfWay = (hit.viewDirection() + rayDirection).normalized();
|
||||
Vector3f specular_ =
|
||||
geometry->coefSpecular() * geometry->specular().array() *
|
||||
specular.array() *
|
||||
pow(std::max(0.0f, hit.normal().dot(halfWay)), geometry->getPhong());
|
||||
geometry->ks() * geometry->cs().array() * specular.array() *
|
||||
pow(std::max(0.0f, hit.normal().dot(halfWay)), geometry->phong());
|
||||
|
||||
return specular_ + ambient_ + diffuse_;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue