|
|
@ -1,6 +1,7 @@
|
|
|
|
use bytemuck::__core::ops::Range;
|
|
|
|
use bytemuck::__core::ops::Range;
|
|
|
|
use bytemuck::{Zeroable, Pod};
|
|
|
|
use bytemuck::{Zeroable, Pod};
|
|
|
|
use crate::{OPENGL_TO_WGPU_MATRIX, DirectionalLight, Position};
|
|
|
|
use crate::{OPENGL_TO_WGPU_MATRIX, DirectionalLight, Position};
|
|
|
|
|
|
|
|
use cgmath::Point3;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[repr(C)]
|
|
|
|
#[repr(C)]
|
|
|
@ -16,10 +17,10 @@ unsafe impl Pod for LightRaw {}
|
|
|
|
unsafe impl Zeroable for LightRaw {}
|
|
|
|
unsafe impl Zeroable for LightRaw {}
|
|
|
|
|
|
|
|
|
|
|
|
impl DirectionalLight {
|
|
|
|
impl DirectionalLight {
|
|
|
|
pub fn to_raw(&self, pos: Position) -> LightRaw {
|
|
|
|
pub fn to_raw(&self, pos: Point3<f32>) -> LightRaw {
|
|
|
|
use cgmath::{Deg, EuclideanSpace, Matrix4, PerspectiveFov, Point3, Vector3};
|
|
|
|
use cgmath::{Deg, EuclideanSpace, Matrix4, PerspectiveFov, Point3, Vector3};
|
|
|
|
|
|
|
|
|
|
|
|
let pos = cgmath::Point3::new(pos.x, pos.y, pos.z);
|
|
|
|
//let pos = cgmath::Point3::new(pos.x, pos.y, pos.z);
|
|
|
|
let mx_view = Matrix4::look_at(pos, Point3::origin(), Vector3::unit_z());
|
|
|
|
let mx_view = Matrix4::look_at(pos, Point3::origin(), Vector3::unit_z());
|
|
|
|
let projection = PerspectiveFov {
|
|
|
|
let projection = PerspectiveFov {
|
|
|
|
fovy: Deg(self.fov).into(),
|
|
|
|
fovy: Deg(self.fov).into(),
|
|
|
|