reformat rt

This commit is contained in:
Shuo Feng 2024-03-14 19:03:40 -04:00
parent 9aaed2d6e8
commit ef5df2fa64
Signed by: sfeng
GPG key ID: 1E83AE6CD1C037B1

View file

@ -28,18 +28,15 @@ Ray getRay(int x, int y, const Vector3f &camPos, const Vector3f &pxUpperLeft,
} }
void RayTracer::calculateColor(const HitRecord &hit, Output *buffer, int i) { void RayTracer::calculateColor(const HitRecord &hit, Output *buffer, int i) {
buffer->r(i, 0);
buffer->g(i, 0);
buffer->b(i, 0);
Vector3f result(0, 0, 0); Vector3f result(0, 0, 0);
for (auto light : lights) for (auto light : lights)
if (light->isUse()) result += light->isUse() ? light->illumination(hit, geometries)
result += light->illumination(hit, geometries); : Vector3f::Zero();
result = result.cwiseMax(0.0f).cwiseMin(1.0f); result = result.cwiseMax(0.0f).cwiseMin(1.0f);
buffer->r(i, buffer->r(i) + result.x()); buffer->r(i, result.x());
buffer->g(i, buffer->g(i) + result.y()); buffer->g(i, result.y());
buffer->b(i, buffer->b(i) + result.z()); buffer->b(i, result.z());
} }
void RayTracer::render(Scene *scene) { void RayTracer::render(Scene *scene) {