diff options
author | Julian T <julian@jtle.dk> | 2021-01-14 00:56:57 +0100 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2021-01-14 00:56:57 +0100 |
commit | 57c2f9241543a7d18eab98077530730d49ee10c2 (patch) | |
tree | 9dcb819f6c89621f214346a3cbbc88762d05d831 /src/core/spectrum.hpp | |
parent | 8251be3e7ec0e381391c951fd4c8f1ab8080bef9 (diff) |
Replace color with pbr-book inspired Spectrum class
Diffstat (limited to 'src/core/spectrum.hpp')
-rw-r--r-- | src/core/spectrum.hpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/core/spectrum.hpp b/src/core/spectrum.hpp new file mode 100644 index 0000000..de9355d --- /dev/null +++ b/src/core/spectrum.hpp @@ -0,0 +1,29 @@ +#ifndef SPECTRUM_H +#define SPECTRUM_H + +#include "core/common.hpp" + +// Contains a RGB spectrum value +class Spectrum { +public: + Spectrum(double v = 0); + static Spectrum FromRGB(double r, double g, double b); + + Spectrum &operator+=(const Spectrum &o); + Spectrum &operator*=(double o); + Spectrum operator+(const Spectrum &o) const; + Spectrum operator-(const Spectrum &o) const; + Spectrum operator*(const Spectrum &o) const; + Spectrum operator/(const Spectrum &o) const; + + Spectrum clamp(double low = 0, double high = INFINITY) const; + + double R() const { return c[0]; } + double G() const { return c[1]; } + double B() const { return c[2]; } + +private: + double c[3]; +}; + +#endif |