Mix frame ID into the RNG
This commit is contained in:
parent
211c0b921e
commit
91fa161db9
|
|
@ -52,14 +52,6 @@ fn main() {
|
||||||
|
|
||||||
let format = wgpu::TextureFormat::Bgra8UnormSrgb;
|
let format = wgpu::TextureFormat::Bgra8UnormSrgb;
|
||||||
let mut tracer = Tracer::new(&device, format);
|
let mut tracer = Tracer::new(&device, format);
|
||||||
tracer.set_params(
|
|
||||||
&queue,
|
|
||||||
trace::Params {
|
|
||||||
max_reflections: 3,
|
|
||||||
min_strength: 0.1,
|
|
||||||
sphere_count: N_SPHERES,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
let sphere_params: Vec<_> = {
|
let sphere_params: Vec<_> = {
|
||||||
let mut rng = rand_pcg::Pcg32::new(42, 0);
|
let mut rng = rand_pcg::Pcg32::new(42, 0);
|
||||||
let distr = anim::SphereParamsDistribution::default();
|
let distr = anim::SphereParamsDistribution::default();
|
||||||
|
|
@ -69,6 +61,7 @@ fn main() {
|
||||||
|
|
||||||
let presenter = Presenter::new(&device, format);
|
let presenter = Presenter::new(&device, format);
|
||||||
|
|
||||||
|
let mut frame = 0;
|
||||||
let mut time = 0.0;
|
let mut time = 0.0;
|
||||||
|
|
||||||
let mut surface_configured = false;
|
let mut surface_configured = false;
|
||||||
|
|
@ -100,8 +93,18 @@ fn main() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
time += 1. / 60.;
|
time += 1. / 60.;
|
||||||
|
frame += 1;
|
||||||
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();
|
||||||
let data = TracerData::new(&device, &tracer, &spheres);
|
let data = TracerData::new(&device, &tracer, &spheres);
|
||||||
|
tracer.set_params(
|
||||||
|
&queue,
|
||||||
|
trace::Params {
|
||||||
|
max_reflections: 3,
|
||||||
|
min_strength: 0.1,
|
||||||
|
sphere_count: N_SPHERES,
|
||||||
|
seed: frame,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
let output = surface.get_current_texture().unwrap();
|
let output = surface.get_current_texture().unwrap();
|
||||||
let view = output.texture.create_view(&wgpu::TextureViewDescriptor::default());
|
let view = output.texture.create_view(&wgpu::TextureViewDescriptor::default());
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ pub struct Params {
|
||||||
pub max_reflections: u32,
|
pub max_reflections: u32,
|
||||||
pub min_strength: f32,
|
pub min_strength: f32,
|
||||||
pub sphere_count: u32,
|
pub sphere_count: u32,
|
||||||
|
pub seed: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ struct Params {
|
||||||
max_reflections: i32,
|
max_reflections: i32,
|
||||||
min_strength: f32,
|
min_strength: f32,
|
||||||
sphere_count: i32,
|
sphere_count: i32,
|
||||||
|
seed: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Sphere {
|
struct Sphere {
|
||||||
|
|
@ -113,7 +114,7 @@ var<private> rand_state: u32;
|
||||||
fn seed(key: vec4f) {
|
fn seed(key: vec4f) {
|
||||||
let x = bitcast<u32>(key.x);
|
let x = bitcast<u32>(key.x);
|
||||||
let y = bitcast<u32>(key.y);
|
let y = bitcast<u32>(key.y);
|
||||||
rand_state = hash(hash(x) ^ y);
|
rand_state = hash(hash(hash(params.seed) ^ x) ^ y);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rand_next() -> u32 {
|
fn rand_next() -> u32 {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user