mmp / pbrt-v3

Source code for pbrt, the renderer described in the third edition of "Physically Based Rendering: From Theory To Implementation", by Matt Pharr, Wenzel Jakob, and Greg Humphreys.
http://pbrt.org
BSD 2-Clause "Simplified" License
4.86k stars 1.18k forks source link

question about AddSample #246

Closed tototuo closed 4 years ago

tototuo commented 5 years ago

there is one line subtract 0.5 to each sample at filter->addsample Point2f pFilmDiscrete = pFilm - Vector2f(0.5f, 0.5f); the description about it is converts the continuous sample coordinates to discrete coordinates but why we should doing this. for example,

pixel : (5, 5) sample: (5.20, 5.06) filter radius: 1

if we follow the code in pbrt, the sample will contributes to the pixels (4,4), (4,5), (5,4), (5,5). but if we draw these points in a graph, we can conclude that this sample will contributes to the pixels (5,5), (5,6), (6,5) and (6,6)

Does anything get wrong?

mmp commented 4 years ago

The (discrete coordinates) pixel (5,5) has its center in (continuous coordinates) (5.5, 5.5). Similarly, (4,4) has its center at (4.5, 4.5), and so forth.

Thus, with a filter of radius 1 at pixel (4,4)'s center, the filter covers the box from (3.5,3.5) up to (5.5,5.5) (in continuous coordinates), and thus that sample is inside the filter's extent.

And then similarly for the other pixels.

Does that make sense?

tototuo commented 4 years ago

thank you very much. I was just start learning pbrt at that time, and now I'm totally understand, thanks again!