cleanup
This commit is contained in:
@@ -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));
|
let result = compiler.compile_into_spirv(&shader.source, shader.kind, &shader.src_path.to_str().unwrap(), "main", Some(&options));
|
||||||
match result {
|
match result {
|
||||||
Err(err) => { panic!("Failed: {}", err); },
|
Err(err) => {
|
||||||
|
eprintln!("{}", err);
|
||||||
|
panic!("shader compilation");
|
||||||
|
},
|
||||||
Ok(data) => {
|
Ok(data) => {
|
||||||
write(shader.spv_path, data.as_binary_u8()).unwrap();
|
write(shader.spv_path, data.as_binary_u8()).unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -216,7 +216,7 @@ impl App {
|
|||||||
|
|
||||||
// Cam
|
// Cam
|
||||||
let aspect = swapchain_desc.width as f32 / swapchain_desc.height as f32;
|
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();
|
let mut uniforms = Uniforms::new();
|
||||||
uniforms.update(&camera);
|
uniforms.update(&camera);
|
||||||
let camera_controller = CameraController::new();
|
let camera_controller = CameraController::new();
|
||||||
|
|||||||
@@ -1,13 +1,5 @@
|
|||||||
use cgmath::{Point3, Vector3, Matrix4, Deg};
|
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 struct Camera {
|
||||||
pub position: Point3<f32>,
|
pub position: Point3<f32>,
|
||||||
pub forward: Vector3<f32>,
|
pub forward: Vector3<f32>,
|
||||||
@@ -43,11 +35,4 @@ impl Camera {
|
|||||||
pub fn view_matrix(&self) -> Matrix4<f32> {
|
pub fn view_matrix(&self) -> Matrix4<f32> {
|
||||||
return Matrix4::look_to_rh((0.0,0.0,0.0).into(), self.forward, self.up);
|
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;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,10 +26,9 @@ layout(set=1, binding=0) uniform Uniforms
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
// Calculate ray direction
|
||||||
vec3 view_dir = (proj_matrix_inv * vec4(vert_uv, 0, 1)).xyz;
|
vec3 view_dir = (proj_matrix_inv * vec4(vert_uv, 0, 1)).xyz;
|
||||||
vec3 ray_dir = normalize(view_matrix * vec4(view_dir,0)).xyz;
|
vec3 ray_dir = normalize(view_matrix * vec4(view_dir,0)).xyz;
|
||||||
|
// Calculate color
|
||||||
|
|
||||||
// Render
|
|
||||||
out_color = vec4(raymarch(cam_pos, ray_dir), 1);
|
out_color = vec4(raymarch(cam_pos, ray_dir), 1);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user