wip: parallelization

This commit is contained in:
2026-05-03 14:58:56 +02:00
parent eb90c36ae8
commit 10f9c0984d
23 changed files with 294 additions and 211 deletions

View File

@@ -16,9 +16,7 @@ pub struct Dielectric {
impl Dielectric {
pub fn new(refraction_index: f32) -> Self {
Self {
refraction_index,
}
Self { refraction_index }
}
fn reflectance(cos: f32, refraction_index: f32) -> f32 {
@@ -46,7 +44,8 @@ impl Material for Dielectric {
let cannot_refract = ri * sin_theta > 1.;
let mut rng = rand::rng();
let dir = if cannot_refract || Dielectric::reflectance(cos_theta, ri) > rng.random::<f32>() {
let dir = if cannot_refract || Dielectric::reflectance(cos_theta, ri) > rng.random::<f32>()
{
unit.reflect(hit.n())
} else {
unit.refract(hit.n(), ri)