ft: 13: optional defocus blur

This commit is contained in:
2026-04-29 01:17:00 +02:00
parent 076bcc7155
commit 2358f8e093
6 changed files with 111 additions and 14 deletions

View File

@@ -5,8 +5,7 @@ use crate::{camera::Camera, vec3::Vec3};
#[derive(Deserialize)]
pub struct RawCamera {
// output
image_width: u32, // TODO: test these are now explicitly required (and that default impl does
// not make these optional)
image_width: u32,
image_height: u32,
// raytracing
@@ -24,6 +23,10 @@ pub struct RawCamera {
look_at: Vec3,
#[serde(default)]
vup: Vec3,
#[serde(default)]
defocus_angle: f32,
#[serde(default)]
focus_dist: f32,
}
impl Default for RawCamera {
@@ -37,6 +40,8 @@ impl Default for RawCamera {
look_from: Vec3::new(0., 0., 0.),
look_at: Vec3::new(0., 0., -1.),
vup: Vec3::new(0., 1., 0.),
defocus_angle: 0.,
focus_dist: 10.,
}
}
}
@@ -52,6 +57,8 @@ impl From<RawCamera> for Camera {
raw.look_from,
raw.look_at,
raw.vup,
raw.defocus_angle,
raw.focus_dist,
)
}
}