|
1053 | 1053 | inline double ffmin(double a, double b) { return a <= b ? a : b; } |
1054 | 1054 | inline double ffmax(double a, double b) { return a >= b ? a : b; } |
1055 | 1055 |
|
1056 | | - inline double clamp(double x, double min, double max) { |
1057 | | - if (x < min) return min; |
1058 | | - if (x > max) return max; |
1059 | | - return x; |
1060 | | - } |
1061 | | - |
1062 | 1056 | // Common Headers |
1063 | 1057 |
|
1064 | 1058 | #include "common/ray.h" |
|
1266 | 1260 | auto b = scale * e[2]; |
1267 | 1261 |
|
1268 | 1262 | // Write the translated [0,255] value of each color component. |
1269 | | - out << static_cast<int>(256.0 * clamp(r, 0.0, 0.999999)) << ' ' |
1270 | | - << static_cast<int>(256.0 * clamp(g, 0.0, 0.999999)) << ' ' |
1271 | | - << static_cast<int>(256.0 * clamp(b, 0.0, 0.999999)) << '\n'; |
| 1263 | + out << static_cast<int>(256 * clamp(r, 0.0, 0.999)) << ' ' |
| 1264 | + << static_cast<int>(256 * clamp(g, 0.0, 0.999)) << ' ' |
| 1265 | + << static_cast<int>(256 * clamp(b, 0.0, 0.999)) << '\n'; |
1272 | 1266 | } |
1273 | 1267 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1274 | 1268 | [Listing [write-color-clamped]: <kbd>[vec3.h]</kbd> The write_color() function] |
|
1502 | 1496 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ |
1503 | 1497 |
|
1504 | 1498 | // Write the translated [0,255] value of each color component. |
1505 | | - out << static_cast<int>(256.0 * clamp(r, 0.0, 0.999999)) << ' ' |
1506 | | - << static_cast<int>(256.0 * clamp(g, 0.0, 0.999999)) << ' ' |
1507 | | - << static_cast<int>(256.0 * clamp(b, 0.0, 0.999999)) << '\n'; |
| 1499 | + out << static_cast<int>(256 * clamp(r, 0.0, 0.999)) << ' ' |
| 1500 | + << static_cast<int>(256 * clamp(g, 0.0, 0.999)) << ' ' |
| 1501 | + << static_cast<int>(256 * clamp(b, 0.0, 0.999)) << '\n'; |
1508 | 1502 | } |
1509 | 1503 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1510 | 1504 | [Listing [write-color-gamma]: <kbd>[vec3.h]</kbd> write_color(), with gamma correction] |
|
0 commit comments