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.88k stars 1.19k forks source link

Incorrect parenthesization in fp error bounds computation #181

Open mmp opened 6 years ago

mmp commented 6 years ago

(Via Kostya Smolenskiy)

pages 228 and 229. In earlier section, You had mentioned that since the compiler can't rearrange floating point computation, it executes it like it's written in code. Code for transforming points is written like, for example:

 T xp = m.m[0][0] * x + m.m[0][1] * y + m.m[0][2] * z + m.m[0][3];

But in derivation of error bounds on that computation parentheses are as if it is:

 T xp = (m.m[0][0] * x + m.m[0][1] * y) + (m.m[0][2] * z + m.m[0][3]);

From which it stems that maximum gamma is gamma(3), but with former code, maximum gamma is gamma(4).