summaryrefslogtreecommitdiff
path: root/viewport.h
diff options
context:
space:
mode:
authorKeuin <[email protected]>2022-04-16 19:08:28 +0800
committerKeuin <[email protected]>2022-04-16 19:08:28 +0800
commit60d8221109304bc4f207dda8a42623cae488af5d (patch)
tree5f4c59a81d58d14666226ee1f7da5299db98f9f5 /viewport.h
parent52d11df35ca9846085b910e2e40434b48847d9d8 (diff)
Move trace logging to tracelog.h.
Pixel-wise, comprehensive, beautiful trace logging.
Diffstat (limited to 'viewport.h')
-rw-r--r--viewport.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/viewport.h b/viewport.h
index 85d17f5..2924582 100644
--- a/viewport.h
+++ b/viewport.h
@@ -10,6 +10,7 @@
#include "ray.h"
#include "vec.h"
#include "hitlist.h"
+#include "tracelog.h"
#include <cstdlib>
#include <memory>
#include <limits>
@@ -97,7 +98,19 @@ public:
const auto dir = r + off; // direction vector from camera to current pixel on screen
ray3d ray{viewpoint, dir}; // from camera to pixel (on the viewport)
const auto pixel = world.color<T>(ray, ruvg);
- image.set(i + img_hw, -j + img_hh, pixel);
+ const auto x_ = i + img_hw, y_ = -j + img_hh;
+ image.set(x_, y_, pixel);
+
+#ifdef LOG_TRACE
+ const auto ret = pixel;
+ const auto ret8b = pixel8b::from(ret);
+ const auto ret8bg2 = pixel8b::from(ret.gamma2());
+ TRACELOG(" ^ apply to pixel: (%d, %d), color: [%f, %f, %f] (8bit: [%d, %d, %d], 8bit-gamma2: [%d, %d, %d])\n",
+ x_, y_,
+ (double) ret.r, (double) ret.g, (double) ret.b,
+ ret8b.r, ret8b.g, ret8b.b,
+ ret8bg2.r, ret8bg2.g, ret8bg2.b);
+#endif
}
}
return image;