summaryrefslogtreecommitdiff
path: root/material_reflective.cpp
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 /material_reflective.cpp
parent52d11df35ca9846085b910e2e40434b48847d9d8 (diff)
Move trace logging to tracelog.h.
Pixel-wise, comprehensive, beautiful trace logging.
Diffstat (limited to 'material_reflective.cpp')
-rw-r--r--material_reflective.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/material_reflective.cpp b/material_reflective.cpp
index aa0d361..6cffcf3 100644
--- a/material_reflective.cpp
+++ b/material_reflective.cpp
@@ -5,6 +5,7 @@
#include "vec.h"
#include "material.h"
#include "material_reflective.h"
+#include "tracelog.h"
// perfectly-smooth reflective
template<>
@@ -15,7 +16,16 @@ bool material_reflective_<false>::scatter(ray3d &r, const object &hit_obj, doubl
r.source(hit_point);
r.direction(reflected);
r.decay(albedo);
- return dot(reflected, nv) > 0;
+ const auto alive = dot(reflected, nv) > 0;
+#ifdef LOG_TRACE
+ if (!alive) {
+ TRACELOG(" absorbed (perfectly smooth material) (reflected: [%-10f,%-10f,%-10f], nv: [%-10f,%-10f,%-10f])\n",
+ reflected.x, reflected.y, reflected.z, nv.x, nv.y, nv.z);
+ } else {
+ TRACELOG(" reflected (perfectly smooth material)\n");
+ }
+#endif
+ return alive;
}
// fuzzy reflective
@@ -27,5 +37,14 @@ bool material_reflective_<true>::scatter(ray3d &r, const object &hit_obj, double
r.source(hit_point);
r.direction(reflected.unit_vec());
r.decay(albedo);
- return dot(reflected, nv) > 0;
+ const auto alive = dot(reflected, nv) > 0;
+#ifdef LOG_TRACE
+ if (!alive) {
+ TRACELOG(" absorbed (fuzzy reflective material) (reflected: [%-10f,%-10f,%-10f], nv: [%-10f,%-10f,%-10f])\n",
+ reflected.x, reflected.y, reflected.z, nv.x, nv.y, nv.z);
+ } else {
+ TRACELOG(" reflected (fuzzy reflective material)\n");
+ }
+#endif
+ return alive;
} \ No newline at end of file