c
o
t
(
F
O
V
2
)
=
n
h
2
=
2
n
h
cot(\frac{FOV}{2}) = \frac{n}{\frac{h}{2}} = \frac{2n}{h}
cot(2FOV?)=2h?n?=h2n?
OpenGL
[
2
n
w
0
0
0
0
2
n
h
0
0
0
0
n
+
f
n
?
f
2
n
f
n
?
f
0
0
?
1
0
]
\begin{bmatrix} \frac{2n}{w} & 0 & 0 & 0 \\ 0 & \frac{2n}{h} & 0 &0\\ 0 & 0 & \frac{n+f}{n-f} &\frac{2nf}{n-f}\\ 0 & 0 & -1 & 0\\ \end{bmatrix}
?w2n?000?0h2n?00?00n?fn+f??1?00n?f2nf?0??
DirectX
[
2
n
w
0
0
0
0
2
n
h
0
0
0
0
n
f
?
n
n
f
f
?
n
0
0
?
1
0
]
\begin{bmatrix} \frac{2n}{w} & 0 & 0 & 0 \\ 0 & \frac{2n}{h} & 0 &0\\ 0 & 0 & \frac{n}{f-n} &\frac{nf}{f-n}\\ 0 & 0 & -1 & 0\\ \end{bmatrix}
?w2n?000?0h2n?00?00f?nn??1?00f?nnf?0??
1、我们可以把矩阵中使用到 h(高) 和 w(宽) 的部分使用比值替换掉。
r
=
w
h
r = \frac{w}{h}
r=hw?
r在1920x1080下为1.77
2
n
w
=
2
n
r
h
=
1
r
c
o
t
(
F
O
V
2
)
\frac{2n}{w} = \frac{2n}{rh} = \frac{1}{r}cot(\frac{FOV}{2})
w2n?=rh2n?=r1?cot(2FOV?)
2
n
h
=
c
o
t
(
F
O
V
2
)
\frac{2n}{h}=cot(\frac{FOV}{2})
h2n?=cot(2FOV?)
2、替换后
OpenGL
[
1
r
c
o
t
(
F
O
V
2
)
0
0
0
0
c
o
t
(
F
O
V
2
)
0
0
0
0
n
+
f
n
?
f
2
n
f
n
?
f
0
0
?
1
0
]
\begin{bmatrix} \frac{1}{r}cot(\frac{FOV}{2}) & 0 & 0 & 0 \\ 0 & cot(\frac{FOV}{2}) & 0 &0\\ 0 & 0 & \frac{n+f}{n-f} &\frac{2nf}{n-f}\\ 0 & 0 & -1 & 0\\ \end{bmatrix}
?r1?cot(2FOV?)000?0cot(2FOV?)00?00n?fn+f??1?00n?f2nf?0??
DirectX
[
1
r
c
o
t
(
F
O
V
2
)
0
0
0
0
c
o
t
(
F
O
V
2
)
0
0
0
0
n
f
?
n
n
f
f
?
n
0
0
?
1
0
]
\begin{bmatrix} \frac{1}{r}cot(\frac{FOV}{2}) & 0 & 0 & 0 \\ 0 & cot(\frac{FOV}{2}) & 0 &0\\ 0 & 0 & \frac{n}{f-n} &\frac{nf}{f-n}\\ 0 & 0 & -1 & 0\\ \end{bmatrix}
?r1?cot(2FOV?)000?0cot(2FOV?)00?00f?nn??1?00f?nnf?0??