sort out units

This commit is contained in:
numzero 2025-11-18 19:46:08 +03:00
parent 2e6589e01b
commit cbe0839cd6

View File

@ -244,26 +244,27 @@ impl Core {
}
let mut camera_ray_display: Vec<Vertex> = Vec::with_capacity(camera_rays.len());
let sigma2 = args.accum_sigma.powi(2);
let weight = (2. * PI * sigma2).sqrt().recip() * args.accum_scale;
let accum_normalizator = (2. * PI * sigma2).sqrt().recip();
for ray in camera_rays {
let Some(hit) = scene.trace_ray(ray) else {
continue;
};
let mut value = 0.0f32;
let mut total_cd = 0.0f32;
for light_hit in &hits {
let d2 = hit.incident.base.distance_squared(light_hit.incident.base);
if d2 > 9. * sigma2 {
continue;
}
assert!(hit.incident.dir.is_normalized());
let radiance = hit.normal.dot(-hit.incident.dir);
let w = (-0.5 * d2 / sigma2).exp();
value += w * radiance;
let in_lm = 1.0;
let out_cd = in_lm * hit.normal.dot(-hit.incident.dir) / PI;
let weight = accum_normalizator * (-0.5 * d2 / sigma2).exp();
total_cd += weight * out_cd;
}
value *= weight;
value = 3. * (1. - (1. + value).recip());
let brightness = 3. * (1. - (1. + total_cd * args.accum_scale).recip());
let r = args.accum_sigma;
let color = vec3(value, value - 1., value - 2.).clamp(Vec3::splat(0.), Vec3::splat(1.));
let color = vec3(brightness, brightness - 1., brightness - 2.)
.clamp(Vec3::splat(0.), Vec3::splat(1.));
let vertex = |off: Vec3| Vertex {
pos: hit.incident.base + r * off,
color,