Skip to content

Commit

Permalink
Move from right-handed to left-handed matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
Snowiiii committed Jan 7, 2024
1 parent 8d7eb4b commit 7c307fb
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 25 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/vent-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
winit = "0.29.7"
winit = "0.29.9"
sysinfo = "0.30"
chrono = "0.4"

Expand Down
2 changes: 1 addition & 1 deletion crates/vent-editor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ash = { version= "0.37.3", default-features = false, features = ["linked", "debu
egui = "0.24.1"
egui_dock = "0.9.1"

winit = "0.29.7"
winit = "0.29.9"
pollster = "0.3.0"

log = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion crates/vent-rendering/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ash = { version= "0.37.3", default-features = false, features = ["linked", "debu

image = "0.24.7"

winit = "0.29.7"
winit = "0.29.9"
raw-window-handle = "0.6"
log = "0.4"

Expand Down
28 changes: 16 additions & 12 deletions crates/vent-rendering/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ impl VulkanInstance {

pub fn recreate_swap_chain(&mut self, new_size: &PhysicalSize<u32>) {
unsafe {

self.device.device_wait_idle().unwrap();

let (swapchain, surface_resolution) = Self::create_swapchain(
Expand All @@ -266,22 +265,26 @@ impl VulkanInstance {
*new_size,
Some(self.swapchain),
);
// We reuse the old Swapchain and then deleting it
// We reuse the old Swapchain and then deleting it
self.clean_swapchain();

self.swapchain = swapchain;
self.surface_resolution = surface_resolution;


(self.swapchain_image_views, self.swapchain_images) = Self::create_image_views(
&self.device,
&self.swapchain_loader,
self.swapchain,
self.surface_format,
);

self.depth_image.destroy(&self.device);
self.depth_image = VulkanImage::new_depth(&self.device, &self.memory_allocator, self.depth_format, surface_resolution);
self.depth_image = VulkanImage::new_depth(
&self.device,
&self.memory_allocator,
self.depth_format,
surface_resolution,
);

self.frame_buffers = Self::create_frame_buffers(
&self.swapchain_image_views,
Expand Down Expand Up @@ -321,7 +324,8 @@ impl VulkanInstance {

unsafe {
self.device
.queue_submit2(self.graphics_queue, &[submit_info], in_flight_fence).unwrap();
.queue_submit2(self.graphics_queue, &[submit_info], in_flight_fence)
.unwrap();
}

let swapchains = &[self.swapchain];
Expand All @@ -335,18 +339,18 @@ impl VulkanInstance {
self.frame = (self.frame + 1) % MAX_FRAMES_IN_FLIGHT as usize;

unsafe {
let result = self.swapchain_loader
let result = self
.swapchain_loader
.queue_present(self.present_queue, &present_info);
return result == Err(vk::Result::ERROR_OUT_OF_DATE_KHR) || result == Err(vk::Result::SUBOPTIMAL_KHR);

result == Err(vk::Result::ERROR_OUT_OF_DATE_KHR)
|| result == Err(vk::Result::SUBOPTIMAL_KHR)
}
}


unsafe fn clean_swapchain(&mut self) {
self.frame_buffers
.drain(..)
.for_each(|f| self.device.destroy_framebuffer(f, None));
.drain(..)
.for_each(|f| self.device.destroy_framebuffer(f, None));

self.swapchain_image_views
.drain(..)
Expand Down
2 changes: 1 addition & 1 deletion crates/vent-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ vent-ecs = { path = "../vent-ecs"}

ash = { version= "0.37.3", default-features = false, features = ["linked", "debug"] }

winit = "0.29.7"
winit = "0.29.9"
pollster = "0.3.0"
log = "0.4"

Expand Down
2 changes: 1 addition & 1 deletion crates/vent-runtime/res/shaders/app/3D/shader.frag
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ layout (location = 0) out vec4 fragColor;
const float ambient_strength = 0.1;

void main() {
vec4 texture = texture(texture_diffuse, tex_coord);
vec4 texture = texture(texture_diffuse, tex_coord) ;

// Calculate the ambient color
// vec3 ambient_color = light.color * ambient_strength;
Expand Down
4 changes: 2 additions & 2 deletions crates/vent-runtime/src/render/camera/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ impl Camera for Camera3D {

fn recreate_projection(&mut self, aspect_ratio: f32) {
self.ubo.projection =
glam::Mat4::perspective_rh(self.fovy.to_radians(), aspect_ratio, self.znear, self.zfar);
glam::Mat4::perspective_lh(self.fovy.to_radians(), aspect_ratio, self.znear, self.zfar);
}
}

impl Camera3D {
pub fn update_set() {}

pub fn recreate_view(&mut self) {
let view = glam::Mat4::look_at_rh(
let view = glam::Mat4::look_at_lh(
self.position,
self.position + self.direction(),
glam::Vec3::Y,
Expand Down
1 change: 1 addition & 0 deletions crates/vent-runtime/src/render/d3/light_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use vent_assets::Mesh3D;

use crate::render::model_renderer::ModelRenderer3D;

#[repr(C)]
pub struct LightUBO {
pub position: Vec3,
pub color: Vec3,
Expand Down
2 changes: 1 addition & 1 deletion crates/vent-runtime/src/render/d3/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::mem::size_of;

use ash::vk;
use bytemuck::{Pod, Zeroable};
use glam::{Mat4, Vec3, Vec4};
use vent_assets::Mesh3D;

Expand All @@ -20,6 +19,7 @@ use super::{

pub mod light_renderer;

#[repr(C)]
pub struct MaterialUBO {
pub base_color: Vec4,
}
Expand Down

0 comments on commit 7c307fb

Please sign in to comment.