1
0
mirror of https://github.com/ssloy/tinyraytracer.git synced 2025-01-17 14:18:14 +01:00

randomish seed image

This commit is contained in:
Dmitry V. Sokolov 2019-02-03 15:09:43 +01:00
parent 09bf2208e5
commit 6842f67bb7
2 changed files with 4 additions and 4 deletions

BIN
doc/randomish.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

@ -77,11 +77,11 @@ int main() {
compute_depthmap(width, height, fov, 23.f, spheres, zbuffer);
std::vector<unsigned char> framebuffer(width*height*3);
for (size_t j=0; j<height; j++) {
for (size_t j=0; j<height; j++) { // generate a random-ish image
for (size_t i=0; i<width; i++) {
for (size_t d=0; d<3; d++) {
framebuffer[(i+j*width)*3 + d] = 255*zbuffer[i+j*width];
}
framebuffer[(i+j*width)*3 + 0] = (rand()%256)*(sin(i*2*M_PI/200)+1)/2; // the sine generates vertical strips to ease focusing
framebuffer[(i+j*width)*3 + 1] = (rand()%256);
framebuffer[(i+j*width)*3 + 2] = (rand()%256);
}
}