14 Xyz(
const float x,
const float y,
const float z)
23 *
this = *
this + other;
29 sum.data = data + other.data;
35 result.data = data * factor;
41 result.data = data / factor;
71 const float r = 3.2404542f * c.
x() - 1.5371385f * c.
y() - 0.4985314f * c.
z();
72 const float g = -0.9692660f * c.
x() + 1.8760108f * c.
y() + 0.0415560f * c.
z();
73 const float b = 0.0556434f * c.
x() - 0.2040259f * c.
y() + 1.0572252f * c.
z();
79 { 0.0014f, 0.0000f, 0.0065f },
80 { 0.0022f, 0.0001f, 0.0105f },
81 { 0.0042f, 0.0001f, 0.0201f },
82 { 0.0077f, 0.0002f, 0.0362f },
83 { 0.0143f, 0.0004f, 0.0679f },
84 { 0.0232f, 0.0006f, 0.1102f },
85 { 0.0435f, 0.0012f, 0.2074f },
86 { 0.0776f, 0.0022f, 0.3713f },
87 { 0.1344f, 0.0040f, 0.6456f },
88 { 0.2148f, 0.0073f, 1.0391f },
89 { 0.2839f, 0.0116f, 1.3856f },
90 { 0.3285f, 0.0168f, 1.6230f },
91 { 0.3483f, 0.0230f, 1.7471f },
92 { 0.3481f, 0.0298f, 1.7826f },
93 { 0.3362f, 0.0380f, 1.7721f },
94 { 0.3187f, 0.0480f, 1.7441f },
95 { 0.2908f, 0.0600f, 1.6692f },
96 { 0.2511f, 0.0739f, 1.5281f },
97 { 0.1954f, 0.0910f, 1.2876f },
98 { 0.1421f, 0.1126f, 1.0419f },
99 { 0.0956f, 0.1390f, 0.8130f },
100 { 0.0580f, 0.1693f, 0.6162f },
101 { 0.0320f, 0.2080f, 0.4652f },
102 { 0.0147f, 0.2586f, 0.3533f },
103 { 0.0049f, 0.3230f, 0.2720f },
104 { 0.0024f, 0.4073f, 0.2123f },
105 { 0.0093f, 0.5030f, 0.1582f },
106 { 0.0291f, 0.6082f, 0.1117f },
107 { 0.0633f, 0.7100f, 0.0782f },
108 { 0.1096f, 0.7932f, 0.0573f },
109 { 0.1655f, 0.8620f, 0.0422f },
110 { 0.2257f, 0.9149f, 0.0298f },
111 { 0.2904f, 0.9540f, 0.0203f },
112 { 0.3597f, 0.9803f, 0.0134f },
113 { 0.4334f, 0.9950f, 0.0087f },
114 { 0.5121f, 1.0000f, 0.0057f },
115 { 0.5945f, 0.9950f, 0.0039f },
116 { 0.6784f, 0.9786f, 0.0027f },
117 { 0.7621f, 0.9520f, 0.0021f },
118 { 0.8425f, 0.9154f, 0.0018f },
119 { 0.9163f, 0.8700f, 0.0017f },
120 { 0.9786f, 0.8163f, 0.0014f },
121 { 1.0263f, 0.7570f, 0.0011f },
122 { 1.0567f, 0.6949f, 0.0010f },
123 { 1.0622f, 0.6310f, 0.0008f },
124 { 1.0456f, 0.5668f, 0.0006f },
125 { 1.0026f, 0.5030f, 0.0003f },
126 { 0.9384f, 0.4412f, 0.0002f },
127 { 0.8544f, 0.3810f, 0.0002f },
128 { 0.7514f, 0.3210f, 0.0001f },
129 { 0.6424f, 0.2650f, 0.0000f },
130 { 0.5419f, 0.2170f, 0.0000f },
131 { 0.4479f, 0.1750f, 0.0000f },
132 { 0.3608f, 0.1382f, 0.0000f },
133 { 0.2835f, 0.1070f, 0.0000f },
134 { 0.2187f, 0.0816f, 0.0000f },
135 { 0.1649f, 0.0610f, 0.0000f },
136 { 0.1212f, 0.0446f, 0.0000f },
137 { 0.0874f, 0.0320f, 0.0000f },
138 { 0.0636f, 0.0232f, 0.0000f },
139 { 0.0468f, 0.0170f, 0.0000f },
140 { 0.0329f, 0.0119f, 0.0000f },
141 { 0.0227f, 0.0082f, 0.0000f },
142 { 0.0158f, 0.0057f, 0.0000f },
143 { 0.0114f, 0.0041f, 0.0000f },
144 { 0.0081f, 0.0029f, 0.0000f },
145 { 0.0058f, 0.0021f, 0.0000f },
146 { 0.0041f, 0.0015f, 0.0000f },
147 { 0.0029f, 0.0010f, 0.0000f },
148 { 0.0020f, 0.0007f, 0.0000f },
149 { 0.0014f, 0.0005f, 0.0000f },
150 { 0.0010f, 0.0004f, 0.0000f },
151 { 0.0007f, 0.0002f, 0.0000f },
152 { 0.0005f, 0.0002f, 0.0000f },
153 { 0.0003f, 0.0001f, 0.0000f },
154 { 0.0002f, 0.0001f, 0.0000f },
155 { 0.0002f, 0.0001f, 0.0000f },
156 { 0.0001f, 0.0000f, 0.0000f },
157 { 0.0001f, 0.0000f, 0.0000f },
158 { 0.0001f, 0.0000f, 0.0000f },
159 { 0.0000f, 0.0000f, 0.0000f },
164 constexpr
float b = 2.8977729e-3f;
165 return b / temperature;
173 constexpr
Float factor1 =
175 constexpr
Float factor2 =
177 const Float denom =
exp(factor2 / (wavelength * temperature)) - 1._f;
179 const Float result = factor1 /
pow<5>(wavelength) * 1._f / denom;
181 return float(result);
185 const Interval range = wavelengthToXyzLut.getRange();
186 Xyz result(0.f, 0.f, 0.f);
188 for (
float wavelength =
float(range.
lower()); wavelength < range.
upper(); wavelength += 5.f) {
189 const Xyz xyz = wavelengthToXyzLut(wavelength);
200 for (
Size i = 0; i < points.
size(); ++i) {
201 const float temperature = float(range.
lower()) + float(i) / (points.
size() - 1) *
float(range.
size());
204 points[i].value = temperature;
207 points[i].color = color /
max(color.
r(), color.
g(), color.
b());
213 const float draperPoint = 798.f;
214 const float pureEmissionColor = draperPoint * 1.5f;
217 for (
Size i = 0; i < points.
size(); ++i) {
218 const float temperature = float(range.
lower()) + float(i) / (points.
size() - 1) *
float(range.
size());
219 points[i].value = temperature;
221 if (temperature < draperPoint) {
222 points[i].color = darkColor;
226 const Rgba normColor = color /
max(color.
r(), color.
g(), color.
b());
227 const float weight =
min((temperature - draperPoint) / (pureEmissionColor - draperPoint), 1.f);
228 points[i].color =
lerp(darkColor, normColor,
weight);
INLINE bool isReal(const AntisymmetricTensor &t)
#define SPH_ASSERT(x,...)
Definitions of physical constaints (in SI units).
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Approximation of generic function by look-up table.
INLINE Float weight(const Vector &r1, const Vector &r2)
constexpr INLINE T max(const T &f1, const T &f2)
NAMESPACE_SPH_BEGIN constexpr INLINE T min(const T &f1, const T &f2)
Minimum & Maximum value.
constexpr INLINE Float pow< 5 >(const Float v)
INLINE T lerp(const T v1, const T v2, const TAmount amount)
constexpr INLINE T sqr(const T &f) noexcept
Return a squared value.
#define NAMESPACE_SPH_END
@ LINEAR
Control points are interpolated on linear scale.
Palette getEmissionPalette(const Interval range)
Xyz getBlackBodyColor(const float temperature)
float spectralRadiance(const float wavelength, const float temperature)
Planck law.
float getMaxEmissionWavelength(const float temperature)
Returns wavelength of maximum emission for given temperature, according to Wien's law.
Rgba xyzToRgb(const Xyz &c)
Palette getBlackBodyPalette(const Interval range)
Returns palette with colors for black body emission for given temperature.
Generic dynamically allocated resizable storage.
INLINE TCounter size() const noexcept
3-dimensional vector, float precision
Object representing a 1D interval of real numbers.
INLINE Float lower() const
Returns lower bound of the interval.
INLINE Float upper() const
Returns upper bound of the interval.
INLINE Float size() const
Returns the size of the interval.
Callable representing a generic R->T function, approximated using look-up table.
Represents a color palette, used for mapping arbitrary number to a color.
static Rgba gray(const float value=0.5f)
Xyz operator+(const Xyz &other) const
Xyz operator*(const float factor) const
Xyz operator/(const float factor) const
Xyz & operator+=(const Xyz &other)
Xyz(const float x, const float y, const float z)
float & operator[](const int index)
constexpr Float planckConstant
Planck constant.
constexpr Float speedOfLight
Speed of light in vacuum (exactly)
constexpr Float boltzmann
Boltzmann constant.