transparent roughness and diffuse settings from app

This commit is contained in:
zomseffen 2025-02-03 12:42:56 +01:00
parent fbc21ba523
commit 1ecd1c7403
7 changed files with 39 additions and 17 deletions
src/scene

View file

@ -73,6 +73,7 @@ impl Scene {
color: vec3(shade, 1.0, shade),
tex_coord: vec2(0.0, 0.0),
transparent: false,
roughness: 128,
};
oct_tree.set_cube(cube.clone());
@ -85,6 +86,7 @@ impl Scene {
color: vec3(1.0, 0.0, 0.0),
tex_coord: vec2(0.0, 0.0),
transparent: true,
roughness: 32,
};
oct_tree.set_cube(cube.clone());
@ -93,10 +95,11 @@ impl Scene {
color: vec3(1.0, 0.0, 0.0),
tex_coord: vec2(0.0, 0.0),
transparent: true,
roughness: 32,
};
oct_tree.set_cube(cube.clone());
self.point_lights.push(PointLight { pos: vec3(11.0, 11.0, 11.0), color: vec3(0.5, 0.5, 0.5), memory_start: 0 });
self.point_lights.push(PointLight { pos: vec3(11.0, 11.0, 11.0), color: vec3(1.0, 1.0, 1.0), memory_start: 0 });
self.point_lights.push(PointLight { pos: vec3(9.0, 9.0, 11.0), color: vec3(0.5, 0.5, 0.5), memory_start: 0 });
let empty_volumes: Vec<Rc<RefCell<EmptyVolume>>>;
@ -146,9 +149,11 @@ impl Scene {
let index = self.sized_vertices.len();
cube.draw(&data.topology, index, self);
let mut memory_index = 2;
let mut memory_index = 4;
// 0 - location for the maximum number of lights referenced per chunk (also will be the invalid memory allocation for pointing to a nonexistant neighbor)
// 1 - location for the max iterations per light
// 2 - diffuse raster samples (2*n + 1) * (2*n + 1) so as to always have at least the central fragment covered
// 3 - diffuse raster size
for light in &mut self.point_lights {
light.memory_start = memory_index;
memory_index += light.get_buffer_mem_size() as usize;
@ -168,6 +173,8 @@ impl Scene {
println!("Memory size is {} kB, max indes is {}", memory_index * 32 / 8 /1024 + 1, memory_index);
let mut volume_vec = vec![data.num_lights_per_volume; memory_index];
volume_vec[1] = data.max_iterations_per_light;
volume_vec[2] = data.diffuse_raster_steps;
volume_vec[3] = u32::from_ne_bytes(data.diffuse_raster_size.to_ne_bytes());
for volume in &empty_volumes {
volume_vec = volume.borrow().insert_into_memory(volume_vec, data.num_lights_per_volume, &self.point_lights);