|
1046 | 1046 | inline double ffmin(double a, double b) { return a <= b ? a : b; }
|
1047 | 1047 | inline double ffmax(double a, double b) { return a >= b ? a : b; }
|
1048 | 1048 |
|
1049 |
| - inline double clamp(double x, double min, double max) { |
1050 |
| - if (x < min) return min; |
1051 |
| - if (x > max) return max; |
1052 |
| - return x; |
1053 |
| - } |
1054 |
| - |
1055 | 1049 | // Common Headers
|
1056 | 1050 |
|
1057 | 1051 | #include "common/ray.h"
|
|
1259 | 1253 | auto b = scale * e[2];
|
1260 | 1254 |
|
1261 | 1255 | // Write the translated [0,255] value of each color component.
|
1262 |
| - out << static_cast<int>(256.0 * clamp(r, 0.0, 0.999999)) << ' ' |
1263 |
| - << static_cast<int>(256.0 * clamp(g, 0.0, 0.999999)) << ' ' |
1264 |
| - << static_cast<int>(256.0 * clamp(b, 0.0, 0.999999)) << '\n'; |
| 1256 | + out << static_cast<int>(256 * clamp(r, 0.0, 0.999)) << ' ' |
| 1257 | + << static_cast<int>(256 * clamp(g, 0.0, 0.999)) << ' ' |
| 1258 | + << static_cast<int>(256 * clamp(b, 0.0, 0.999)) << '\n'; |
1265 | 1259 | }
|
1266 | 1260 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
1267 | 1261 | [Listing [write-color-clamped]: <kbd>[vec3.h]</kbd> The write_color() function]
|
|
1495 | 1489 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
|
1496 | 1490 |
|
1497 | 1491 | // Write the translated [0,255] value of each color component.
|
1498 |
| - out << static_cast<int>(256.0 * clamp(r, 0.0, 0.999999)) << ' ' |
1499 |
| - << static_cast<int>(256.0 * clamp(g, 0.0, 0.999999)) << ' ' |
1500 |
| - << static_cast<int>(256.0 * clamp(b, 0.0, 0.999999)) << '\n'; |
| 1492 | + out << static_cast<int>(256 * clamp(r, 0.0, 0.999)) << ' ' |
| 1493 | + << static_cast<int>(256 * clamp(g, 0.0, 0.999)) << ' ' |
| 1494 | + << static_cast<int>(256 * clamp(b, 0.0, 0.999)) << '\n'; |
1501 | 1495 | }
|
1502 | 1496 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
1503 | 1497 | [Listing [write-color-gamma]: <kbd>[vec3.h]</kbd> write_color(), with gamma correction]
|
|
0 commit comments