diff --git a/build.rs b/build.rs index 156b048..6d58d58 100644 --- a/build.rs +++ b/build.rs @@ -61,7 +61,10 @@ fn main() { let result = compiler.compile_into_spirv(&shader.source, shader.kind, &shader.src_path.to_str().unwrap(), "main", Some(&options)); match result { - Err(err) => { panic!("Failed: {}", err); }, + Err(err) => { + eprintln!("{}", err); + panic!("shader compilation"); + }, Ok(data) => { write(shader.spv_path, data.as_binary_u8()).unwrap(); } diff --git a/src/app.rs b/src/app.rs index 84c6df0..2d46a7d 100644 --- a/src/app.rs +++ b/src/app.rs @@ -216,7 +216,7 @@ impl App { // Cam let aspect = swapchain_desc.width as f32 / swapchain_desc.height as f32; - let camera = Camera::new(aspect, 45.0); + let camera = Camera::new(aspect, 60.0); let mut uniforms = Uniforms::new(); uniforms.update(&camera); let camera_controller = CameraController::new(); diff --git a/src/camera.rs b/src/camera.rs index bd95ffd..e00f72c 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -1,13 +1,5 @@ use cgmath::{Point3, Vector3, Matrix4, Deg}; -// #[rustfmt::skip] -// const OPENGL_TO_WGPU_MATRIX: cgmath::Matrix4 = cgmath::Matrix4::new( -// 1.0, 0.0, 0.0, 0.0, -// 0.0, 1.0, 0.0, 0.0, -// 0.0, 0.0, 0.5, 0.0, -// 0.0, 0.0, 0.5, 1.0, -// ); - pub struct Camera { pub position: Point3, pub forward: Vector3, @@ -43,11 +35,4 @@ impl Camera { pub fn view_matrix(&self) -> Matrix4 { return Matrix4::look_to_rh((0.0,0.0,0.0).into(), self.forward, self.up); } - - // pub fn view_projection_matrix(&self) -> Matrix4 { - // let view = Matrix4::look_to_rh(self.position, self.forward, self.up); - // let proj = cgmath::perspective(Deg(self.fovy), self.aspect, self.znear, self.zfar); - // return proj; - // //return proj * view; - // } } diff --git a/src/shaders/shader.frag b/src/shaders/shader.frag index b6b3a4f..51590c0 100644 --- a/src/shaders/shader.frag +++ b/src/shaders/shader.frag @@ -26,10 +26,9 @@ layout(set=1, binding=0) uniform Uniforms void main() { + // Calculate ray direction vec3 view_dir = (proj_matrix_inv * vec4(vert_uv, 0, 1)).xyz; vec3 ray_dir = normalize(view_matrix * vec4(view_dir,0)).xyz; - - - // Render + // Calculate color out_color = vec4(raymarch(cam_pos, ray_dir), 1); } \ No newline at end of file