diff --git a/doc/stereoscope.jpg b/doc/stereoscope.jpg new file mode 100644 index 0000000..8a0d181 Binary files /dev/null and b/doc/stereoscope.jpg differ diff --git a/tinyraytracer.cpp b/tinyraytracer.cpp index ffbc2e0..68bfd73 100644 --- a/tinyraytracer.cpp +++ b/tinyraytracer.cpp @@ -144,7 +144,7 @@ void render(const std::vector &spheres, const std::vector &lights } } - std::vector pixmap((width-delta)*height*3); + std::vector pixmap((width-delta)*height*3*2); for (size_t j = 0; j &spheres, const std::vector &lights if (max1>1) c1 = c1*(1./max1); float max2 = std::max(c2[0], std::max(c2[1], c2[2])); if (max2>1) c2 = c2*(1./max2); - float avg1 = (c1.x+c1.y+c1.z)/3.; - float avg2 = (c2.x+c2.y+c2.z)/3.; - pixmap[(j*(width-delta) + i)*3 ] = 255*avg1; - pixmap[(j*(width-delta) + i)*3+1] = 0; - pixmap[(j*(width-delta) + i)*3+2] = 255*avg2; + for (size_t d=0; d<3; d++) { + pixmap[(j*(width-delta)*2 + i )*3+d] = 255*c1[d]; + pixmap[(j*(width-delta)*2 + i+width-delta)*3+d] = 255*c2[d]; + } } } - stbi_write_jpg("out.jpg", width-delta, height, 3, pixmap.data(), 100); + stbi_write_jpg("out.jpg", (width-delta)*2, height, 3, pixmap.data(), 100); } int main() {