adds scene info for recursive rays
This commit is contained in:
parent
709c2f0569
commit
ffbba3be19
4 changed files with 12 additions and 2 deletions
|
@ -20,6 +20,8 @@ layout(binding = 0) uniform UniformBufferObject {
|
||||||
// 1 - location for the max iterations per light
|
// 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
|
// 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 (float, needs to be decoded)
|
// 3 - diffuse raster size (float, needs to be decoded)
|
||||||
|
// 4 - max recursive rays
|
||||||
|
// 5 - diffuse rays per hit
|
||||||
layout(binding = 2) buffer SceneInfoBuffer{
|
layout(binding = 2) buffer SceneInfoBuffer{
|
||||||
uint infos[];
|
uint infos[];
|
||||||
} scene_info;
|
} scene_info;
|
||||||
|
|
|
@ -65,4 +65,6 @@ pub struct AppData {
|
||||||
pub max_iterations_per_light: u32,
|
pub max_iterations_per_light: u32,
|
||||||
pub diffuse_raster_steps: u32,
|
pub diffuse_raster_steps: u32,
|
||||||
pub diffuse_raster_size: f32,
|
pub diffuse_raster_size: f32,
|
||||||
|
pub max_recursive_rays: u32,
|
||||||
|
pub diffuse_rays_per_hit: u32,
|
||||||
}
|
}
|
|
@ -58,7 +58,7 @@ const DEVICE_EXTENSIONS: &[vk::ExtensionName] = &[
|
||||||
vk::KHR_SWAPCHAIN_EXTENSION.name
|
vk::KHR_SWAPCHAIN_EXTENSION.name
|
||||||
];
|
];
|
||||||
|
|
||||||
const MAX_FRAMES_IN_FLIGHT: usize = 3;
|
const MAX_FRAMES_IN_FLIGHT: usize = 30;
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
|
@ -182,6 +182,8 @@ impl App {
|
||||||
data.max_iterations_per_light = 20;
|
data.max_iterations_per_light = 20;
|
||||||
data.diffuse_raster_steps = 2;
|
data.diffuse_raster_steps = 2;
|
||||||
data.diffuse_raster_size = 0.01;
|
data.diffuse_raster_size = 0.01;
|
||||||
|
data.max_recursive_rays = 10;
|
||||||
|
data.diffuse_rays_per_hit = 1;
|
||||||
let mut scene_handler = scene::Scene::default();
|
let mut scene_handler = scene::Scene::default();
|
||||||
|
|
||||||
//load_model::load_model(&mut data)?;
|
//load_model::load_model(&mut data)?;
|
||||||
|
|
|
@ -149,11 +149,13 @@ impl Scene {
|
||||||
let index = self.sized_vertices.len();
|
let index = self.sized_vertices.len();
|
||||||
cube.draw(&data.topology, index, self);
|
cube.draw(&data.topology, index, self);
|
||||||
|
|
||||||
let mut memory_index = 4;
|
let mut memory_index = 6;
|
||||||
// 0 - location for the maximum number of lights referenced per chunk (also will be the invalid memory allocation for pointing to a nonexistant neighbor)
|
// 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
|
// 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
|
// 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
|
// 3 - diffuse raster size
|
||||||
|
// 4 - max recursive rays
|
||||||
|
// 5 - diffuse rays per hit
|
||||||
for light in &mut self.point_lights {
|
for light in &mut self.point_lights {
|
||||||
light.memory_start = memory_index;
|
light.memory_start = memory_index;
|
||||||
memory_index += light.get_buffer_mem_size() as usize;
|
memory_index += light.get_buffer_mem_size() as usize;
|
||||||
|
@ -175,6 +177,8 @@ impl Scene {
|
||||||
volume_vec[1] = data.max_iterations_per_light;
|
volume_vec[1] = data.max_iterations_per_light;
|
||||||
volume_vec[2] = data.diffuse_raster_steps;
|
volume_vec[2] = data.diffuse_raster_steps;
|
||||||
volume_vec[3] = u32::from_ne_bytes(data.diffuse_raster_size.to_ne_bytes());
|
volume_vec[3] = u32::from_ne_bytes(data.diffuse_raster_size.to_ne_bytes());
|
||||||
|
volume_vec[4] = data.max_recursive_rays;
|
||||||
|
volume_vec[5] = data.diffuse_rays_per_hit;
|
||||||
|
|
||||||
for volume in &empty_volumes {
|
for volume in &empty_volumes {
|
||||||
volume_vec = volume.borrow().insert_into_memory(volume_vec, data.num_lights_per_volume, &self.point_lights);
|
volume_vec = volume.borrow().insert_into_memory(volume_vec, data.num_lights_per_volume, &self.point_lights);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue