Compare commits
No commits in common. "de7fb421568bd376a7a51e7e61563ae891fc0387" and "fe998585b4c5fd8749773cf99c818df15c1b1a7c" have entirely different histories.
de7fb42156
...
fe998585b4
|
|
@ -143,10 +143,9 @@ fn main() {
|
||||||
for _ in 0..RAYS_PER_PIXEL {
|
for _ in 0..RAYS_PER_PIXEL {
|
||||||
frame += 1;
|
frame += 1;
|
||||||
let time = frame as f32 / (60. * RAYS_PER_PIXEL as f32);
|
let time = frame as f32 / (60. * RAYS_PER_PIXEL as f32);
|
||||||
let target = sphere_params[0].to_sphere(time - 0.2).center;
|
|
||||||
let eye = camera_params.to_sphere(time).center;
|
let eye = camera_params.to_sphere(time).center;
|
||||||
let right = camera_params.deriv(time);
|
let right = camera_params.deriv(time);
|
||||||
let forward = target - eye;
|
let forward = target_params.to_sphere(time).center - eye;
|
||||||
let viewport = make_viewport(size.width, size.height);
|
let viewport = make_viewport(size.width, size.height);
|
||||||
let location = convert_location(CamLoc { eye, forward, right });
|
let location = convert_location(CamLoc { eye, forward, right });
|
||||||
let spheres: Vec<_> = sphere_params.iter().map(|p| p.to_sphere(time)).collect();
|
let spheres: Vec<_> = sphere_params.iter().map(|p| p.to_sphere(time)).collect();
|
||||||
|
|
@ -164,9 +163,7 @@ fn main() {
|
||||||
viewport,
|
viewport,
|
||||||
trace::Aperture {
|
trace::Aperture {
|
||||||
radius: 0.001,
|
radius: 0.001,
|
||||||
focal_distance: forward.length(),
|
focal_distance: std::f32::INFINITY,
|
||||||
glare_strength: 0.1,
|
|
||||||
glare_radius: 0.1,
|
|
||||||
},
|
},
|
||||||
location,
|
location,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,9 @@ pub struct Viewport {
|
||||||
pub corner: Vec3,
|
pub corner: Vec3,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
|
||||||
pub struct Aperture {
|
pub struct Aperture {
|
||||||
pub radius: f32,
|
pub radius: f32,
|
||||||
pub focal_distance: f32, // from 0 (exclusive) to +∞ (inclusive)
|
pub focal_distance: f32, // from 0 (exclusive) to +∞ (inclusive)
|
||||||
pub glare_strength: f32,
|
|
||||||
pub glare_radius: f32, // at distance 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
|
@ -50,8 +47,6 @@ struct CameraData {
|
||||||
aperture: f32,
|
aperture: f32,
|
||||||
eye: Vec3,
|
eye: Vec3,
|
||||||
antifocal: f32,
|
antifocal: f32,
|
||||||
glare_strength: f32,
|
|
||||||
glare_radius: f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<(Viewport, CameraLocation, Aperture)> for CameraData {
|
impl From<(Viewport, CameraLocation, Aperture)> for CameraData {
|
||||||
|
|
@ -65,8 +60,6 @@ impl From<(Viewport, CameraLocation, Aperture)> for CameraData {
|
||||||
height: value.0.corner.y / value.0.corner.z,
|
height: value.0.corner.y / value.0.corner.z,
|
||||||
aperture: value.2.radius,
|
aperture: value.2.radius,
|
||||||
antifocal: 1. / value.2.focal_distance,
|
antifocal: 1. / value.2.focal_distance,
|
||||||
glare_strength: value.2.glare_strength,
|
|
||||||
glare_radius: value.2.glare_radius,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,6 @@ struct Params {
|
||||||
aperture: f32,
|
aperture: f32,
|
||||||
eye: vec3f,
|
eye: vec3f,
|
||||||
antifocal: f32,
|
antifocal: f32,
|
||||||
|
|
||||||
glare_strength: f32,
|
|
||||||
glare_radius: f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Sphere {
|
struct Sphere {
|
||||||
|
|
@ -84,13 +81,7 @@ fn trace_fragment(in: Varying) -> vec3f {
|
||||||
pos = params.eye + aperture_offset_abs;
|
pos = params.eye + aperture_offset_abs;
|
||||||
let off_px = vec2(rand_float(), rand_float()) - .5;
|
let off_px = vec2(rand_float(), rand_float()) - .5;
|
||||||
let off_w = mat2x3(dpdx(in.dir), dpdy(in.dir));
|
let off_w = mat2x3(dpdx(in.dir), dpdy(in.dir));
|
||||||
var dir = in.dir + off_w * off_px;
|
let dir = in.dir + off_w * off_px;
|
||||||
if (rand_float() < params.glare_strength) {
|
|
||||||
let p = rand_float();
|
|
||||||
let d = params.glare_radius * pow(p, 3.);
|
|
||||||
let glare_off = d * rand_disc();
|
|
||||||
dir += view_mtx * vec3(glare_off, 0.);
|
|
||||||
}
|
|
||||||
ray = normalize(dir - params.antifocal * aperture_offset_abs);
|
ray = normalize(dir - params.antifocal * aperture_offset_abs);
|
||||||
|
|
||||||
for (var k = 0; k < params.max_reflections; k++) {
|
for (var k = 0; k < params.max_reflections; k++) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user