Book 1 Antialiasing random number generation error? #983
-
In book 1 under the Antialiasing Chapter there is code that generates random numbers to sample surrounding pixels. auto u = (i + random_double()) / (image_width-1);
auto v = (j + random_double()) / (image_height-1); I believe this random_double() function generates a number [0, 1). Shouldn't this be more like [-1, 1)? This causes the sampling to only sample from pixels to top right of the pixel. Notably I don't think this creates a noticable effect on the render. But just wanted to point it out. I noticed because I had a bug where I was only rendering my unit sphere random function the same way and there was a noticable shadow bias. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I do NOT think the aim is to sample surrounding pixels. I think the sampling should uniformly cover the area of one pixel, which can be thought of as a 1x1 square. So, it depends where you assume the center of the pixel is. In that section of the book, it appears the the integer coordinates (x, y) are assumed to point to the lower left corner of the (x, y) pixel, with the x axis pointing to the right, and the y axis pointing up. So, the center of the pixel would be (x + 0.5, y + 0.5). The pixel area extends from its lower left corner (x, y) to its upper right corner (x + 1, y + 1). If you choose the center of the (x, y) pixel to be (x, y), then I think you should use a range of [-0.5, +0.5). What I don't quite understand is the choice of dividing by |
Beta Was this translation helpful? Give feedback.
I do NOT think the aim is to sample surrounding pixels. I think the sampling should uniformly cover the area of one pixel, which can be thought of as a 1x1 square.
So, it depends where you assume the center of the pixel is. In that section of the book, it appears the the integer coordinates (x, y) are assumed to point to the lower left corner of the (x, y) pixel, with the x axis pointing to the right, and the y axis pointing up. So, the center of the pixel would be (x + 0.5, y + 0.5). The pixel area extends from its lower left corner (x, y) to its upper right corner (x + 1, y + 1).
If you choose the center of the (x, y) pixel to be (x, y), then I think you should use a range of [-0.5, +0.5).