Skip to content

Commit

Permalink
sync shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
schell committed Oct 15, 2024
1 parent 26fa023 commit b7b9800
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 46 deletions.
2 changes: 1 addition & 1 deletion crates/renderling/src/bvol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn intersect_planes(p0: &Vec4, p1: &Vec4, p2: &Vec4) -> Vec3 {

/// Calculates distance between plane and point
pub fn dist_bpp(plane: &Vec4, point: Vec3) -> f32 {
(plane.x * point.x + plane.y * point.y + plane.z * point.z + plane.w).abs()
plane.x * point.x + plane.y * point.y + plane.z * point.z + plane.w
}

/// Calculates the most inside vertex of an AABB.
Expand Down
23 changes: 1 addition & 22 deletions crates/renderling/src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ impl Camera {
self.projection * self.view
}

/// Returns **roughly** the location of the znear plane.
pub fn z_near(&self) -> f32 {
dist_bpp(&self.frustum.planes[0], self.position)
}
Expand Down Expand Up @@ -156,25 +157,3 @@ pub fn default_ortho2d(width: f32, height: f32) -> (Mat4, Mat4) {
let view = Mat4::IDENTITY;
(projection, view)
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn camera_znear_zfar() {
let znear = 0.01;
let zfar = 100.0;
let projection = Mat4::perspective_rh(core::f32::consts::PI / 4.0, 1.0, znear, zfar);
let view = Mat4::look_at_rh(Vec3::new(5.0, 5.0, 10.0), Vec3::ZERO, Vec3::Y);
let camera = Camera::new(projection, view);

log::info!("near_plane: {}", camera.frustum.planes[0]);
log::info!("znear: {}", camera.z_near());
log::info!("far_plane: {}", camera.frustum.planes[5]);
log::info!("zfar: {}", camera.z_far());

assert_eq!(znear, camera.z_near(), "znear");
assert_eq!(zfar, camera.z_far(), "zfar");
}
}
2 changes: 1 addition & 1 deletion crates/renderling/src/cull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use spirv_std::num_traits::Float;
use spirv_std::{
arch::IndexUnchecked,
image::{sample_with, Image, ImageWithMethods},
spirv, Sampler,
spirv,
};

use crate::draw::DrawIndirectArgs;
Expand Down
22 changes: 0 additions & 22 deletions crates/renderling/src/linkage/compute_occlusion_culling.rs

This file was deleted.

Binary file modified crates/renderling/src/linkage/cull-compute_culling.spv
Binary file not shown.
Binary file not shown.

0 comments on commit b7b9800

Please sign in to comment.