camera: Fix Y inverted
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Has been cancelled

This commit is contained in:
Florian RICHER 2025-05-29 16:38:45 +02:00
parent 8b16def890
commit 3a562fb6eb
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
2 changed files with 10 additions and 2 deletions

View file

@ -11,6 +11,14 @@ use crate::core::{input::InputManager, timer::Timer};
use super::mvp::MVP;
// See docs/OPENGL_VULKAN_DIFF.md
const OPENGL_TO_VULKAN_Y_AXIS_FLIP: Mat4 = Mat4 {
x_axis: Vec4::new(1.0, 0.0, 0.0, 0.0),
y_axis: Vec4::new(0.0, -1.0, 0.0, 0.0),
z_axis: Vec4::new(0.0, 0.0, 1.0, 0.0),
w_axis: Vec4::new(0.0, 0.0, 0.0, 1.0),
};
#[derive(Default)]
pub struct Camera {
projection: Mat4,
@ -90,7 +98,7 @@ impl Camera {
);
MVP {
model: Mat4::IDENTITY.to_cols_array_2d(),
model: OPENGL_TO_VULKAN_Y_AXIS_FLIP.to_cols_array_2d(),
view: view_matrix.to_cols_array_2d(),
projection: self.projection.to_cols_array_2d(),
}

View file

@ -43,7 +43,7 @@ impl Scene for MainScene {
scene_context.swapchain_format,
)?;
let camera = Camera::new(Mat4::perspective_rh_gl(
let camera = Camera::new(Mat4::perspective_rh(
std::f32::consts::FRAC_PI_2,
scene_context.aspect_ratio,
0.01,