Different z values for PerspectiveBase
- Dominant language
- Rust
- Stars
- 4.8k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
http://nalgebra.org/rustdoc/nalgebra/geometry/struct.PerspectiveBase.html
I haven't done the math, but this looks like the standard opengl z value range from -1, 1.
For example this is a perspective matrix with a z range from 1 to 0. (Row major) I personally use two matrices, 0 to 1 and 1 to 0 for my Vulkan renderer.
```
pub fn perspective_vk_revz(fov: T, ar: T, near: T, far: T) -> Self {
let half_fov = fov / (T::one() + T::one());
Mat4::from_rows(
Vec4::new(
T::one() / (ar * half_fov.tan()),
T::zero(),
T::zero(),
T::zero(),
),
Vec4::new(
T::zero(),
-T::one() / (half_fov.tan()),
T::zero(),
T::zero(),
),
Vec4::new(
T::zero(),
T::zero(),
-near / (far - near),
(near * far) / (far - near),
),
Vec4::new(T::zero(), T::zero(), T::one(), T::zero()),
)
}
```
It seems like support could be easily added by adding another type parameter to PerspectiveBase. Something like this
```
pub struct PerspectiveBase>
```
Would you like such a feature?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.