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

Orthographic Camera #177

Closed ksmolenskiy closed 6 years ago

ksmolenskiy commented 6 years ago

Hello.

Orthographic transform now is Transform Orthographic(Float zNear, Float zFar) { return Scale(1, 1, 1 / (zFar - zNear)) * Translate(Vector3f(0, 0, -zNear)); } With only call in OrthographicCamera constructor: Orthographic(0, 1) Which makes it identity matrix. As a consequence: 1) there is no control of "zoom". It always captures scene with extents of width 2 and height 2 in camera space, with aspect modification. Usually ortho matrix has 2/width and 2/height in (0,0) and (1,1) entries for that kind of control. 2) book states that screen space, NDC and raster space have depth from 0 to 1, but with a call with 1 for zFar this isn't fulfilled.

mmp commented 6 years ago

For what it's worth, that "zoom" control is provided via the "screenwindow" parameter, which gives a 2D extent on the projection plane. (In turn, that is passed to the ProjectiveCamera constructor, which uses it to set the ScreenToRaster transformation.) So I believe that it's all consistent / has the expected flexibility in that respect.

Good point about the depth range in those spaces; this is definitely one of those places where rasterizers need near and far clipping planes for everything to work, but for a ray tracer, we don't need to worry about it. I've made a note to improve the discussion of this topic in the 4th edition.

Thanks!