diff --git a/kubi/src/camera/matrices.rs b/kubi/src/camera/matrices.rs index 44c359f..2309724 100644 --- a/kubi/src/camera/matrices.rs +++ b/kubi/src/camera/matrices.rs @@ -21,7 +21,7 @@ fn update_perspective_matrix( size: UniqueView, ) { for mut camera in (&mut vm_camera).iter() { - camera.perspective_matrix = Mat4::perspective_rh_gl( + camera.perspective_matrix = Mat4::perspective_rh( camera.fov, size.0.x as f32 / size.0.y as f32, camera.z_near, diff --git a/kubi/src/rendering.rs b/kubi/src/rendering.rs index 8a7b89f..e42a91b 100644 --- a/kubi/src/rendering.rs +++ b/kubi/src/rendering.rs @@ -15,12 +15,12 @@ pub mod camera; //pub mod entities; //pub mod sumberge; -pub const WGPU_COORDINATE_SYSTEM: Mat4 = mat4( - vec4(1.0, 0.0, 0.0, 0.0), - vec4(0.0, 1.0, 0.0, 0.0), - vec4(0.0, 0.0, 0.5, 0.5), - vec4(0.0, 0.0, 0.0, 1.0), -); +// pub const WGPU_COORDINATE_SYSTEM: Mat4 = mat4( +// vec4(1.0, 0.0, 0.0, 0.0), +// vec4(0.0, 1.0, 0.0, 0.0), +// vec4(0.0, 0.0, 0.5, 0.5), +// vec4(0.0, 0.0, 0.0, 1.0), +// ); // #[repr(C)] // #[derive(Debug, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)] diff --git a/kubi/src/rendering/camera.rs b/kubi/src/rendering/camera.rs index 0fb47b9..918f224 100644 --- a/kubi/src/rendering/camera.rs +++ b/kubi/src/rendering/camera.rs @@ -3,13 +3,12 @@ use kubi_shared::transform::Transform; use shipyard::{AllStoragesView, IntoIter, Unique, UniqueView, View}; use wgpu::util::DeviceExt; use crate::camera::{self, Camera}; - -use super::{Renderer, WGPU_COORDINATE_SYSTEM}; +use super::Renderer; #[derive(Debug, Clone, Copy, Default, Pod, Zeroable)] #[repr(C, packed)] pub struct CameraUniformData { - pub view_proj: [[f32; 4]; 4], + pub view_proj: [f32; 4 * 4], } @@ -79,6 +78,6 @@ pub fn update_camera_unform_buffer( camera: View, ) { let Some(camera) = camera.iter().next() else { return }; - let proj = camera.view_matrix * camera.perspective_matrix * WGPU_COORDINATE_SYSTEM; - camera_uniform_buffer.update(&renderer, CameraUniformData { view_proj: proj.to_cols_array_2d() }); + let proj = camera.perspective_matrix * camera.view_matrix; + camera_uniform_buffer.update(&renderer, CameraUniformData { view_proj: proj.to_cols_array() }); } diff --git a/kubi/src/rendering/world.rs b/kubi/src/rendering/world.rs index 33ea5fe..b2a78d7 100644 --- a/kubi/src/rendering/world.rs +++ b/kubi/src/rendering/world.rs @@ -7,7 +7,7 @@ use crate::{ settings::GameSettings, world::{ChunkMeshStorage, ChunkStorage}, }; -use super::{camera::CameraUniformBuffer, RenderCtx, WGPU_COORDINATE_SYSTEM}; +use super::{camera::CameraUniformBuffer, RenderCtx}; mod pipeline; mod vertex; @@ -32,14 +32,9 @@ pub fn draw_world( textures: UniqueView, chunks: UniqueView, meshes: NonSendSync>, - //transform: View, - camera: View, camera_ubo: UniqueView, settings: UniqueView, ) { - let camera = camera.iter().next().expect("No cameras in the scene"); - let matrix = WGPU_COORDINATE_SYSTEM * camera.view_matrix * camera.perspective_matrix; - let mut render_pass = ctx.encoder.begin_render_pass(&wgpu::RenderPassDescriptor { label: Some("draw_world"), color_attachments: &[Some(wgpu::RenderPassColorAttachment { @@ -68,11 +63,11 @@ pub fn draw_world( } //Frustum culling - let minp = world_position; - let maxp = world_position + Vec3::splat(CHUNK_SIZE as f32); - if !camera.frustum.is_box_visible(minp, maxp) { - continue - } + // let minp = world_position; + // let maxp = world_position + Vec3::splat(CHUNK_SIZE as f32); + // if !camera.frustum.is_box_visible(minp, maxp) { + // continue + // } //Draw chunk mesh if mesh.main.index.size() > 0 {