recursive reflection for nontransparnt elements

This commit is contained in:
zomseffen 2025-02-05 16:50:57 +01:00
parent ffbba3be19
commit dc66ae4b3d
5 changed files with 162 additions and 101 deletions

View file

@ -180,7 +180,7 @@ impl App {
data.use_geometry_shader = false;
data.num_lights_per_volume = 2;
data.max_iterations_per_light = 20;
data.diffuse_raster_steps = 2;
data.diffuse_raster_steps = 0;
data.diffuse_raster_size = 0.01;
data.max_recursive_rays = 10;
data.diffuse_rays_per_hit = 1;

View file

@ -66,9 +66,12 @@ impl EmptyVolume {
let start_time = Instant::now();
// iterate over all block positions in the oct tree
let mut check_its = 0;
for x_index in 0..tree.size {
for y_index in 0..tree.size {
for z_index in 0..tree.size {
let mut x_index = 0;
while x_index < tree.size {
let mut y_index = 0;
while y_index < tree.size {
let mut z_index = 0;
while z_index < tree.size {
// check if there is a block at that position
let query_result = tree.test_element(x_index, y_index, z_index);
let mut transparent = false;
@ -86,6 +89,7 @@ impl EmptyVolume {
for volume in &volumes {
if volume.borrow().contains(&Vector3{x: x_index, y: y_index, z: z_index}) {
contained = true;
z_index = volume.borrow().size_z + volume.borrow().position.z;
break;
}
}
@ -479,9 +483,12 @@ impl EmptyVolume {
println!("new volume done");
//push to the list
volumes.push(reference);
}
}
z_index += 1
}
y_index += 1;
}
x_index += 1;
}
println!("Did {} oct tree checks!", check_its);
println!("add the neighbor linkage for all the volumes of the oct tree");

View file

@ -73,7 +73,7 @@ impl Scene {
color: vec3(shade, 1.0, shade),
tex_coord: vec2(0.0, 0.0),
transparent: false,
roughness: 128,
roughness: 0,
};
oct_tree.set_cube(cube.clone());
@ -83,19 +83,19 @@ impl Scene {
let shade = (rng.gen_range(0..25) as f32) / 100.0;
let cube = Cube {
pos: vec3(10.0, 10.0, 10.0),
color: vec3(1.0, 0.0, 0.0),
color: vec3(1.0, 1.0, 1.0),
tex_coord: vec2(0.0, 0.0),
transparent: true,
roughness: 32,
transparent: false,
roughness: 0,
};
oct_tree.set_cube(cube.clone());
let cube = Cube {
pos: vec3(10.0, 10.0, 9.0),
color: vec3(1.0, 0.0, 0.0),
color: vec3(1.0, 1.0, 1.0),
tex_coord: vec2(0.0, 0.0),
transparent: true,
roughness: 32,
transparent: false,
roughness: 0,
};
oct_tree.set_cube(cube.clone());