PSF/Blurring. Turned out to be tough
This commit is contained in:
1 parent
4d070db85e
commit
d0cec6572e
22 files changed
+1250
-92
No files matched your search
@@ -56,10 +56,14 @@ struct RenderArgs {
|
||||
/// needs Blue Marble data).
|
||||
#[arg(long, default_value = "L0")]
|
||||
lighting: LightingTier,
|
||||
/// Camera fidelity tier: C0, or C1 (adds pixels that collect light over their area:
|
||||
/// graded edges and continuous thin parts).
|
||||
/// Camera fidelity tier: C0, or C1 (adds pixels that collect light over their area,
|
||||
/// for graded edges and continuous thin parts, and lens blur).
|
||||
#[arg(long, default_value = "C0")]
|
||||
camera: CameraTier,
|
||||
/// From camera C1: render each pixel as N x N finer ones (1 to 4; default 2), which
|
||||
/// the lens blur then acts on before they are averaged into the pixel.
|
||||
#[arg(long, value_name = "N")]
|
||||
supersampling: Option<u32>,
|
||||
/// Device: auto, gpu, cpu, or part of an adapter's name.
|
||||
#[arg(long, default_value = "auto")]
|
||||
adapter: String,
|
||||
@@ -193,6 +197,7 @@ fn render(args: &RenderArgs) -> Result<(), String> {
|
||||
profile: timings.is_some(),
|
||||
shadow_map_size: None,
|
||||
dn_in_place: None,
|
||||
supersampling: args.supersampling,
|
||||
};
|
||||
let start = Instant::now();
|
||||
let mut renderer = Renderer::new(camera, options).map_err(|e| e.to_string())?;
|
||||
@@ -254,11 +259,12 @@ fn render(args: &RenderArgs) -> Result<(), String> {
|
||||
v[v.len() / 2]
|
||||
};
|
||||
println!(
|
||||
"gpu shadow {:.3} ms, earthshine {:.3} ms, bodies {:.3} ms, mesh {:.3} ms, sensor {:.3} ms, first to last {:.3} ms (medians)",
|
||||
"gpu shadow {:.3} ms, earthshine {:.3} ms, mesh {:.3} ms, bodies {:.3} ms, blur {:.3} ms, sensor {:.3} ms, first to last {:.3} ms (medians)",
|
||||
median(|t| t.shadow),
|
||||
median(|t| t.earthshine),
|
||||
median(|t| t.bodies),
|
||||
median(|t| t.mesh),
|
||||
median(|t| t.bodies),
|
||||
median(|t| t.blur),
|
||||
median(|t| t.sensor),
|
||||
median(|t| t.total)
|
||||
);
|
||||
|
||||
@@ -10,7 +10,8 @@ use std::path::{Path, PathBuf};
|
||||
use resolved::bodies::Appearance;
|
||||
use resolved::nalgebra::{Quaternion, UnitQuaternion, Vector2, Vector3};
|
||||
use resolved::{
|
||||
CameraConfig, LoadOptions, Material, Mesh, ModelId, Pose, Renderer, Scene, Spectrum, Target,
|
||||
CameraConfig, LoadOptions, Material, Mesh, ModelId, Pose, Psf, Renderer, Scene, Spectrum,
|
||||
Target,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
@@ -60,6 +61,17 @@ pub struct CameraFile {
|
||||
pub bias: Option<f64>,
|
||||
pub full_well: Option<f64>,
|
||||
pub adc_bits: Option<u32>,
|
||||
/// The Gaussian blur's sigma in pixels, from camera C1: one for every channel, one
|
||||
/// per channel, or 0 for none.
|
||||
pub psf_sigma: Option<Sigma>,
|
||||
}
|
||||
|
||||
/// One sigma, or one per channel.
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum Sigma {
|
||||
All(f64),
|
||||
PerChannel(Vec<f64>),
|
||||
}
|
||||
|
||||
/// The observer's pose: `position`, plus either `attitude` or `look_at` (and `up`).
|
||||
@@ -145,6 +157,16 @@ impl SceneFile {
|
||||
if let Some(t) = c.transmission {
|
||||
camera.transmission = Spectrum::constant(t);
|
||||
}
|
||||
camera.psf = match &c.psf_sigma {
|
||||
None => camera.psf,
|
||||
Some(Sigma::All(s)) if *s == 0.0 => Psf::None,
|
||||
Some(Sigma::All(s)) => Psf::Gaussian {
|
||||
sigma: vec![*s; camera.channels.len()],
|
||||
},
|
||||
Some(Sigma::PerChannel(sigma)) => Psf::Gaussian {
|
||||
sigma: sigma.clone(),
|
||||
},
|
||||
};
|
||||
camera
|
||||
}
|
||||
|
||||
@@ -368,6 +390,26 @@ mod tests {
|
||||
assert_eq!((camera.width, camera.height), (640, 1080));
|
||||
assert_eq!(camera.exposure, 2e-3);
|
||||
assert_eq!(camera.detector.adc_bits, 10);
|
||||
|
||||
for (line, psf) in [
|
||||
(
|
||||
"psf_sigma = 1.5",
|
||||
Psf::Gaussian {
|
||||
sigma: vec![1.5; 3],
|
||||
},
|
||||
),
|
||||
(
|
||||
"psf_sigma = [0.8, 0.7, 0.6]",
|
||||
Psf::Gaussian {
|
||||
sigma: vec![0.8, 0.7, 0.6],
|
||||
},
|
||||
),
|
||||
("psf_sigma = 0", Psf::None),
|
||||
] {
|
||||
let file: SceneFile =
|
||||
toml::from_str(&format!("{MINIMAL}\n[camera]\n{line}\n")).unwrap();
|
||||
assert_eq!(file.camera().psf, psf, "{line}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user