diff options
author | Keuin <[email protected]> | 2022-04-20 22:18:51 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-04-20 22:26:37 +0800 |
commit | 7dd2b9e3696c1723f0cf30f6b82b3c61440d7ded (patch) | |
tree | 0c72e9a832105d7a3ae576604ba72dc0aaecf39c | |
parent | 0dd04488da92753cbbc3d96cad9d2bffb32a48eb (diff) |
Bugfix: image is upside down. render result is inconsistent with previous versions (introduced in commit bfc5e815), because scan range in y-axis is slightly different from before.
-rw-r--r-- | viewport.h | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -111,7 +111,7 @@ public: assert(dot(r, v) < 1e-8); assert(dot(u, v) < 1e-8); // iterate over every pixel on the image - for (int j = -img_hh; j < img_hh; ++j) { // axis y, transformation is needed + for (int j = -img_hh + 1; j <= img_hh; ++j) { // axis y, transformation is needed for (int i = -img_hw; i < img_hw; ++i) { // axis x bias(bx, by); // get a random bias (bx, by) for sub-pixel sampling assert(0 <= bx); @@ -124,7 +124,7 @@ public: const auto dir = r + off; // direction vector from camera to current pixel on screen ray3d ray{cxyz, dir}; // from camera to pixel (on the viewport) const auto pixel = world.color<U>(ray, ruvg); - const auto x_ = i + img_hw, y_ = j + img_hh; + const auto x_ = i + img_hw, y_ = -j + img_hh; image.set(x_, y_, pixel); #ifdef LOG_TRACE |