This works as kinda glare but... not really
This commit is contained in:
parent
973c505f0c
commit
60f648cfb9
|
|
@ -21,7 +21,7 @@ fn on_vertex(in: Vertex) -> Varying {
|
||||||
return Varying(uv, vec4(xy, 0., 1.));
|
return Varying(uv, vec4(xy, 0., 1.));
|
||||||
}
|
}
|
||||||
|
|
||||||
const CUTOFF: i32 = 10000;
|
const CUTOFF: i32 = 200;
|
||||||
|
|
||||||
@fragment
|
@fragment
|
||||||
fn pass_h(in: Varying) -> @location(0) vec4f {
|
fn pass_h(in: Varying) -> @location(0) vec4f {
|
||||||
|
|
@ -60,10 +60,16 @@ fn pass_v(in: Varying) -> @location(0) vec4f {
|
||||||
// return .1 * w;
|
// return .1 * w;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
fn weight(dist: i32) -> f32 {
|
||||||
|
let σ = params.sigma / 1e5;
|
||||||
|
let d = f32(dist) / σ;
|
||||||
|
return 3. / (1. + d*d);
|
||||||
|
}
|
||||||
|
|
||||||
// fn weight(dist: i32) -> f32 {
|
// fn weight(dist: i32) -> f32 {
|
||||||
// let σ = params.sigma / 3000.;
|
// let σ = params.sigma / 1e8;
|
||||||
// let d = f32(dist) / σ;
|
// let d = f32(dist) / σ;
|
||||||
// return .1 / (1. + d*d) / σ;
|
// return 3. / (1. + abs(d));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// fn weight(dist: i32) -> f32 {
|
// fn weight(dist: i32) -> f32 {
|
||||||
|
|
@ -72,10 +78,15 @@ fn pass_v(in: Varying) -> @location(0) vec4f {
|
||||||
// return 1. / (1. + d*d*d) / σ;
|
// return 1. / (1. + d*d*d) / σ;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
fn weight(dist: i32) -> f32 {
|
// fn weight(dist: i32) -> f32 {
|
||||||
let d = f32(abs(dist));
|
// let d = f32(abs(dist));
|
||||||
let c = mix(.01, 1., exp(-d*d));
|
// let c = mix(.01, 1., exp(-d*d));
|
||||||
// return c * pow(1.2, -d);
|
// // return c * pow(1.2, -d);
|
||||||
return c / (1. + pow(d, 2.0));
|
// return c / (1. + pow(d, 2.0));
|
||||||
// return .25 * c / (1. + pow(.1 * d, 4.0));
|
// // return .25 * c / (1. + pow(.1 * d, 4.0));
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// fn weight(dist: i32) -> f32 {
|
||||||
|
// let d = 2. * f32(dist);
|
||||||
|
// return exp(-d*d);
|
||||||
|
// }
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ fn on_vertex(in: Vertex) -> Varying {
|
||||||
|
|
||||||
@fragment
|
@fragment
|
||||||
fn on_fragment(in: Varying) -> @location(0) vec4f {
|
fn on_fragment(in: Varying) -> @location(0) vec4f {
|
||||||
let pixel = textureSample(tex, smp, in.tex) / params.divisor;
|
let pixel = .1 * textureSample(tex, smp, in.tex) / params.divisor;
|
||||||
return vec4(rational_tone_map(pixel.xyz), 1.0);
|
return vec4(rational_tone_map(pixel.xyz), 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
11
src/scene.rs
11
src/scene.rs
|
|
@ -109,7 +109,14 @@ impl Renderer {
|
||||||
let forward = target - eye;
|
let forward = target - eye;
|
||||||
let viewport = make_viewport(size.x, size.y);
|
let viewport = make_viewport(size.x, size.y);
|
||||||
let location = convert_location(CamLoc { eye, forward, right });
|
let location = convert_location(CamLoc { eye, forward, right });
|
||||||
let spheres: Vec<_> = scene.spheres.iter().map(|p| p.to_sphere(time)).collect();
|
let mut spheres: Vec<_> = scene.spheres.iter().map(|p| p.to_sphere(time)).collect();
|
||||||
|
spheres.push(crate::Sphere {
|
||||||
|
center: vec3(0., 215e3, 0.),
|
||||||
|
radius: 1e3,
|
||||||
|
emit_color: Vec3::splat(1.0e6),
|
||||||
|
reflect_color: Vec3::splat(0.),
|
||||||
|
glossiness: 0.,
|
||||||
|
});
|
||||||
let data = TracerData::new(&device, &self.tracer, &spheres);
|
let data = TracerData::new(&device, &self.tracer, &spheres);
|
||||||
self.tracer.render(
|
self.tracer.render(
|
||||||
&mut render_pass.0,
|
&mut render_pass.0,
|
||||||
|
|
@ -118,7 +125,7 @@ impl Renderer {
|
||||||
trace::Params {
|
trace::Params {
|
||||||
max_reflections: 3,
|
max_reflections: 3,
|
||||||
min_strength: 0.1,
|
min_strength: 0.1,
|
||||||
sphere_count: N_SPHERES,
|
sphere_count: spheres.len() as u32,
|
||||||
seed,
|
seed,
|
||||||
},
|
},
|
||||||
viewport,
|
viewport,
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,8 @@ fn trace_fragment(in: Varying) -> vec3f {
|
||||||
}
|
}
|
||||||
if (sphere == -1) {
|
if (sphere == -1) {
|
||||||
let env = textureSampleLevel(env_texture, env_sampler, ray, 0.0);
|
let env = textureSampleLevel(env_texture, env_sampler, ray, 0.0);
|
||||||
result += 3.0 * color * env.xyz;
|
// result += (vec3(5.0) + 0.001 * env.xyz) * color;
|
||||||
|
result += 5.0 * env.xyz * color;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let s = spheres[sphere];
|
let s = spheres[sphere];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user