This commit is contained in:
Piotrek
2021-04-15 10:05:28 +02:00
parent a95c8f4bf2
commit 9cd599743d
4 changed files with 7 additions and 20 deletions
+1 -1
View File
@@ -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();
-15
View File
@@ -1,13 +1,5 @@
use cgmath::{Point3, Vector3, Matrix4, Deg};
// #[rustfmt::skip]
// const OPENGL_TO_WGPU_MATRIX: cgmath::Matrix4<f32> = 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<f32>,
pub forward: Vector3<f32>,
@@ -43,11 +35,4 @@ impl Camera {
pub fn view_matrix(&self) -> Matrix4<f32> {
return Matrix4::look_to_rh((0.0,0.0,0.0).into(), self.forward, self.up);
}
// pub fn view_projection_matrix(&self) -> Matrix4<f32> {
// 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;
// }
}
+2 -3
View File
@@ -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);
}