Ray-caster: pass spheres in through uniforms

Keep the hard-coded spheres for comparison.
This commit is contained in:
Aaron Fenyes 2024-08-25 21:40:46 -07:00
parent 206a2df480
commit 5bf23fa789
4 changed files with 103 additions and 29 deletions

View file

@ -0,0 +1,12 @@
use nalgebra::DVector;
pub fn sphere(center_x: f64, center_y: f64, center_z: f64, radius: f64) -> DVector<f64> {
let center_norm_sq = center_x * center_x + center_y * center_y + center_z * center_z;
DVector::from_column_slice(&[
center_x / radius,
center_y / radius,
center_z / radius,
0.5 / radius,
0.5 * (center_norm_sq / radius - radius)
])
}