Skip to content

Commit

Permalink
Fix SampleTwoNormal implementation
Browse files Browse the repository at this point in the history
Fixes #481.
  • Loading branch information
mmp committed Jan 30, 2025
1 parent fb5988a commit 6a43ed9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/pbrt/util/sampling.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ inline Float InvertNormalSample(Float x, Float mu = 0, Float sigma = 1) {
}

PBRT_CPU_GPU inline Point2f SampleTwoNormal(Point2f u, Float mu = 0, Float sigma = 1) {
Float r2 = -2 * std::log(1 - u[0]);
return {mu + sigma * std::sqrt(r2 * std::cos(2 * Pi * u[1])),
mu + sigma * std::sqrt(r2 * std::sin(2 * Pi * u[1]))};
Float r2 = -2 * std::log1p(-u[0]); // log(1-u[0]), robustly.
return {mu + sigma * std::sqrt(r2) * std::cos(2 * Pi * u[1]),
mu + sigma * std::sqrt(r2) * std::sin(2 * Pi * u[1])};
}

PBRT_CPU_GPU inline Float LogisticPDF(Float x, Float s) {
Expand Down

0 comments on commit 6a43ed9

Please sign in to comment.