s_perspectiveDepthFactor
global · gxumath
- Address
0x8038dc· 4 bytes, up to0x8038df- Type
float- Meaning
- Holds -2.0, the factor of near·far in the perspective depth term
- Confidence
- verified, proof one
- Finding
- gxumath#perspective-matrix
Finding: Perspective matrix in gxumath
0x5c3cc0 (ecx the output; fov, aspect, near, far on the stack; ret 0x10) writes the
perspective matrix. With t = tan(0.5·fov/√(aspect² + 1)) and d = far − near: m0 = near/(aspect·(t·near)), m5 = near/(t·near), m10 = (near + far)/d, m14 = near·far·(−2)/d,
m11 = 1. The other floats, m15 included, are 0. It needs 0 < fov < π, aspect > 0 and
near < far, NaN failing each; a failed test raises error 0x57 and writes nothing.
The derivation is in the doc.