WIP shadowmapping
This commit is contained in:
parent
2fdae1a23a
commit
ac67a3d4de
9 changed files with 270 additions and 122 deletions
|
@ -7,17 +7,17 @@ pub struct Camera {
|
|||
pub position: cgmath::Point3<f32>,
|
||||
pub pitch: f32,
|
||||
pub yaw: f32,
|
||||
pub projection: Projection,
|
||||
pub projection: PerspectiveProjection,
|
||||
}
|
||||
|
||||
pub struct Projection {
|
||||
pub struct PerspectiveProjection {
|
||||
pub aspect: f32,
|
||||
pub fovy: f32,
|
||||
pub znear: f32,
|
||||
pub zfar: f32,
|
||||
}
|
||||
|
||||
impl Projection {
|
||||
impl PerspectiveProjection {
|
||||
pub fn resize(&mut self, width: u32, height: u32) {
|
||||
self.aspect = width as f32 / height as f32;
|
||||
}
|
||||
|
@ -27,6 +27,35 @@ impl Projection {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct OrthoProjection {
|
||||
pub left: f32,
|
||||
pub right: f32,
|
||||
pub bottom: f32,
|
||||
pub top: f32,
|
||||
pub znear: f32,
|
||||
pub zfar: f32,
|
||||
}
|
||||
|
||||
impl OrthoProjection {
|
||||
pub fn resize(&mut self, width: u32, height: u32) {
|
||||
self.left = width as f32 * -0.5;
|
||||
self.right = width as f32 * 0.5;
|
||||
self.bottom = height as f32 * -0.5;
|
||||
self.top = height as f32 * 0.5;
|
||||
}
|
||||
|
||||
pub fn get_matrix(&self) -> cgmath::Matrix4<f32> {
|
||||
cgmath::ortho(
|
||||
self.left,
|
||||
self.right,
|
||||
self.bottom,
|
||||
self.top,
|
||||
self.znear,
|
||||
self.zfar,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Camera {
|
||||
pub fn new(
|
||||
position: cgmath::Point3<f32>,
|
||||
|
@ -39,7 +68,7 @@ impl Camera {
|
|||
position,
|
||||
pitch,
|
||||
yaw,
|
||||
projection: Projection {
|
||||
projection: PerspectiveProjection {
|
||||
aspect,
|
||||
fovy,
|
||||
znear: 0.1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue