Open Ligo04 opened 8 months ago
Hi @Ligo04 !
Off the top of my head (I still need to empirically test how it plays with the rest of the code) I think you're right -
The ortho matrix is:
$$ \left(\begin{array}{cc} \frac{2}{right-left} & 0 & 0 & -\frac{right+left}{right-left} \ 0 & \frac{2}{top-bottom} & 0 & -\frac{top+bottom}{top-bottom} \ 0 & 0 & -\frac{2}{far-near} & -\frac{far+near}{far-near} \ 0 & 0 & 0 & 1 \ \end{array}\right) $$
Subbing the current case (1):
$$ \left(\begin{array}{cc} \frac{H}{W} & 0 & 0 & 0 \ 0 & 1 & 0 & 0 \ 0 & 0 & -\frac{2}{far-near} & -\frac{far+near}{far-near} \ 0 & 0 & 0 & 1 \ \end{array}\right) $$
Subbing the commented out case (2):
$$ \left(\begin{array}{cc} \frac{2}{W} & 0 & 0 & 0 \ 0 & \frac{2}{H} & 0 & 0 \ 0 & 0 & -\frac{2}{far-near} & -\frac{far+near}{far-near} \ 0 & 0 & 0 & 1 \ \end{array}\right) $$
where $W,H$ are the image plane width, height.
For the default NDC space ranging [-1,1]
(aligned with old OpenGL conventions) the viewing volume should be a 2 units wide cuboid, so case (2) should be the correct one.
Hi @Ligo04 !
Off the top of my head (I still need to empirically test how it plays with the rest of the code) I think you're right -
The ortho matrix is:
$$ \left(\begin{array}{cc} \frac{2}{right-left} & 0 & 0 & -\frac{right+left}{right-left} \ 0 & \frac{2}{top-bottom} & 0 & -\frac{top+bottom}{top-bottom} \ 0 & 0 & -\frac{2}{far-near} & -\frac{far+near}{far-near} \ 0 & 0 & 0 & 1 \ \end{array}\right) $$
Subbing the current case (1):
$$ \left(\begin{array}{cc} \frac{H}{W} & 0 & 0 & 0 \ 0 & 1 & 0 & 0 \ 0 & 0 & -\frac{2}{far-near} & -\frac{far+near}{far-near} \ 0 & 0 & 0 & 1 \ \end{array}\right) $$
Subbing the commented out case (2):
$$ \left(\begin{array}{cc} \frac{2}{W} & 0 & 0 & 0 \ 0 & \frac{2}{H} & 0 & 0 \ 0 & 0 & -\frac{2}{far-near} & -\frac{far+near}{far-near} \ 0 & 0 & 0 & 1 \ \end{array}\right) $$
where $W,H$ are the image plane width, height.
For the default NDC space ranging
[-1,1]
(aligned with old OpenGL conventions) the viewing volume should be a 2 units wide cuboid, so case (2) should be the correct one.
Yes. Thanks~. Hope this can be updated
I don't particularly understand why the projection matrix function
projection_matrix
of the orthographic camera uses the following calculation formulas fortop, bottom, right, left
. The ndc coordinates calculated in this way are incorrect.Instead of using the standard form, the function code is commented out and the ndc calculated using the standard form is correct.