This commit is contained in:
Piotrek
2021-04-24 20:47:04 +02:00
parent 00fd077642
commit 61ec3e5a21
8 changed files with 54 additions and 18 deletions
+8 -2
View File
@@ -1,5 +1,5 @@
use crate::renderer::camera::Camera;
use cgmath::SquareMatrix;
use cgmath::{SquareMatrix, Vector3, InnerSpace};
use wgpu::util::DeviceExt;
#[repr(C)]
@@ -8,13 +8,19 @@ pub struct UniformValues {
view_inv: [[f32; 4]; 4],
proj_inv: [[f32; 4]; 4],
cam_pos: [f32; 3],
padding: f32,
sun_dir: [f32; 3],
padding2: f32,
time: f32
}
impl UniformValues {
pub fn new() -> Self {
Self::default()
let sun_vec: Vector3<f32> = (1.0, 1.0, 1.0).into();
let sun_dir: [f32; 3] = sun_vec.normalize().into();
Self { sun_dir, .. Default::default() }
}
pub fn update(&mut self, camera: &Camera, time: f32) {