mmp / pbrt-v2

Source code for the version of pbrt described in the second edition of "Physically Based Rendering"
http://pbrt.org
990 stars 343 forks source link

Distribution1D::SampleContinuous problem #44

Closed mario007 closed 9 years ago

mario007 commented 9 years ago

Hi guys,

First of all i find the book extreamly instructive and interesting. I noticed some inconsistency in Distribution1D::SampleContinuous: values of pdf can be greater than 1.0. In my opinion funcInt should be sum of all input values as stated in Monte Carlo Rendering with Natural Illumination paper(http://www.cs.virginia.edu/~gfx/courses/2007/ImageSynthesis/assignments/envsample.pdf).

// Compute PDF for sampled offset if (pdf) *pdf = func[offset] / funcInt;

Thanks, Looking forward to 3rd edition of your book.

Regards, Mario Vidov

mmp commented 9 years ago

I think that actually isn't a bug; it's fine for PDF values to be greater than one--it's just that the integral of the PDF over the domain must be one.

For Distribution1D, the domain is the range [0,1], so summing the function values divided by the number of segments n normalizes it, since each segment only has length 1/n.