mmatl / pyrender

Easy-to-use glTF 2.0-compliant OpenGL renderer for visualization of 3D scenes.
http://pyrender.readthedocs.io/
MIT License
1.29k stars 226 forks source link

Bug in IntrinsicsCamera.get_projection_matrix? #54

Open snavely opened 5 years ago

snavely commented 5 years ago

In the get_projection_matrix method of IntrinsicsCamera there are the lines:

    P[0][2] = 1.0 - 2.0 * cx / (width - 1.0)
    P[1][2] = 2.0 * cy / (height - 1.0) - 1.0

I am unsure of why cx and cy are divided by width - 1.0/height - 1.0, and not just width/height. Specifying cx = 0.5 width and cy = 0.5 height should reproduce the behavior of PerspectiveCamera for those matrix entries, where those entries are 0.0 (which would occur if dividing by width/height, but not width - 1.0/height - 1.0. Is this perhaps a bug? Or maybe this is meant to address some pixel centering issue? When I modify to remove the -1s, I get the behavior I expect, but leaving them in produces renderings that are shifted with respect to what I expect.

rodrigodzf commented 4 years ago

I had exactly the same problem. The -1 seems superfluous and causes an unexpected shift. What was the reason for this?