blob: bdb49a414c4caac43d72937a732e7f144eb61cd1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
//
// Created by Michael Foiani on 11/4/23.
//
#include "raytracer/raytracer.h"
// Helper function to convert illumination to RGBA, applying some form of tone-mapping (e.g. clamping) in the process
RGBA RayTracer::toRGBA(const glm::vec4 &illumination) {
// Task 1
return RGBA
{
(std::uint8_t) (255 * std::clamp(illumination.r, 0.f, 1.f)),
(std::uint8_t) (255 * std::clamp(illumination.g, 0.f, 1.f)),
(std::uint8_t) (255 * std::clamp(illumination.b, 0.f, 1.f)),
(std::uint8_t) (255 * std::clamp(illumination.b, 0.f, 1.f))
};
}
bool RayTracer::floatEquals(float a, float b, float epsilon) {
return std::abs(a - b) <= epsilon;
}
|