From 86135cb2ce48bfd52797223a73d80894e78a4d2a Mon Sep 17 00:00:00 2001 From: zomseffen Date: Fri, 17 Jan 2025 11:10:39 +0100 Subject: [PATCH] diffuse raytracing --- shaders/compiled/frag_rt_quad.spv | Bin 24048 -> 27676 bytes shaders/rt_quad.frag | 69 +++++++++++++++++++++--------- src/app_data.rs | 1 + src/main.rs | 3 +- src/scene/mod.rs | 6 ++- src/scene/oct_tree.rs | 2 +- 6 files changed, 57 insertions(+), 24 deletions(-) diff --git a/shaders/compiled/frag_rt_quad.spv b/shaders/compiled/frag_rt_quad.spv index 32ca9f02830832efa29626333a924d7786d65827..70c2c6ae56ac85eb260c6364ec334c1f470bc6fe 100644 GIT binary patch literal 27676 zcmaK!2bf(|*@Z7KlZ4)T3%&Q=I}rpDdS@6ilVo5r6DBhu2_=LgNNM9-D@hJPyPD_i@#!%ms&he*pjPLL5AJ}kct6h*9?Xkxnt`1ZhFzvH=*CqX+vA@(#+7#yewsW zfA7%bZaUmKFbE}Adt+(pfzGLe-2)v{`lq(qS_W-G)4o_^W$LP}W}p7QhHPgA{O8xs zis)J2{xOVbY=qvNJY$=)rT@sr#_0V6JypJr z)^wqHjW;t_XYW>2O}=%DTQ&I(Ext|ot}VW8i;rxK0dx)wbk6AL>Yh4&VD81Up9f(( z+)I7{SA6fG2@|>pP}`fj@h$`|DN1|e5bAl$Lv3W^2(;EkZMBevq3sxKgZ)!lQ`9lF zXJ&WD5K=Slg!kK~#dZqdl>Wg%R%0u56>82&^R-QD=5!wIm_%c#cf=4{PpJ+x{6^8d0o`#Y*}H}>Y-y)W8%7}dCM{&u_Fv_C}Mn&0;)F#fUs zVQ-ClRO4yvt$Ch*{B!@qp7bwZudg+vrtMAY`g&^FMl{|5)YeS1o%hho{ny>s)y%ah_nG&t6?~oVC9%zK zJ+#^y*;p3)`>%Jak1JxE&$Vo}xhl5#T&JdOP1|(M54#5DY;UZCtvo%vSB*g%s_rFY z!PAFdtiMZI5i+h^@Y!3^eYR`Pm56b{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}N}3E(pCiEy>9 zBJbDW$*VoFCxNw@*ZW2u+bQ5O@7LjKz87b_r^1t0dty%mYcsF+pFFm2fXlq6!z-=G zdj?waYESH$U~T60K96139OI0@i)+`#s3zt_geU^VDFK{-v-u4-T0g7 z)#85#*u5YA1F(BG@ppptQ8)f}dbRl94R$Yv{}AjRO8h-webkM=i(W1M_krCT;XeX< zO%s1VSRZxc@1<9Z|ASz!Rrrs=u5sdj0@g>}_y_3K;{Pyspx}>yegDtd=25uX%CwxZ z9s{fAY?E9+Mf3Wk_Rqljs^`7oaj-SDCGO|ovgQ+THS?$DFW~C+n!iNznx^Kj!1}7E z=96ISYD>+hz-7&+;cDe)wP)b!^_ss%b04JUZ@~Jhr{=R@>uO8Q--64Uzk{oF74!T( zT)kfNIkdZIsrd)6zUry@N3eCZrRJZ&WzFZ|YQ8^YZC`+^*K59r=6*}fm%#d}r{>FG z>uPg zg ze}cU}`TX%OxMNn2&%eRy#=l1|kL^F;GXB4CYpBPEqkKc%`1k4Mu`LYtnx*~_xSs`9 zF5)}T)DtrlY@Y0kVQ_ua<1-xWSo0hi0atU6W#4@OuAY6De2bu&Q+xK=qF~3WEn{5_ z>{yLY-Nn(=!&cc zJmb_Bzm>q+@^`8$gVkbR1#F(I!K!ka>y_NA!IN8iVn>3tCHE+>TI{QX%iL?g)ynhs zN8!n>J+W(owI%mjV72^>-P&O1VohzXrCPa`qnLxQaxF)~UCY(!Q)^w~)UyWb!PUCZ zvIZZAXPnv-yFOT3#`y`bTKTLzqmU^E8tEJx7U^VOI+H3=M-i}4P*GA22^M7eI Bkw^dl diff --git a/shaders/rt_quad.frag b/shaders/rt_quad.frag index b6ce9aa..d075f61 100644 --- a/shaders/rt_quad.frag +++ b/shaders/rt_quad.frag @@ -134,24 +134,19 @@ vec3 get_light_color(uint light_index) { return vec3(float(scene_info.infos[light_index + 3]) / 255.0, float(scene_info.infos[light_index + 4]) / 255.0, float(scene_info.infos[light_index + 5]) / 255.0); } -void main() { - uint max_length = scene_info.infos[0]; - uint last = scene_info.infos[max_length]; - - uvec4 color_roughness = sample_color_from_scene_info(fragVolumeStart, fragRasterPos, facing); - vec4 orig_color_sample = vec4(float(color_roughness.x) / 255.0, float(color_roughness.y) / 255.0, float(color_roughness.z) / 255.0, 1); - +vec3 get_lighting_color(uint volume_start, vec3 starting_pos, vec4 orig_color_sample) { uint max_light_num = scene_info.infos[0]; uint light_num = 0; - uint volume_index = fragVolumeStart; + // setup volume info + uint volume_index = volume_start; uint volume_pos_x = scene_info.infos[volume_index + 0]; uint volume_pos_y = scene_info.infos[volume_index + 1]; uint volume_pos_z = scene_info.infos[volume_index + 2]; // setup light info - uint light_index = scene_info.infos[fragVolumeStart + 6 + light_num]; - vec3 light_direction = get_light_position(light_index) - origPosition; + uint light_index = scene_info.infos[volume_start + 6 + light_num]; + vec3 light_direction = get_light_position(light_index) - starting_pos; vec3 light_color = get_light_color(light_index); bool x_pos = light_direction.x > 0.0; @@ -166,7 +161,7 @@ void main() { // initialize color vec3 color_sum = vec3(0.0, 0.0, 0.0) + (orig_color_sample.xyz * 0.01); - uint max_iterations = max_light_num * 20; + uint max_iterations = max_light_num * scene_info.infos[1]; for (int i = 0; i < max_iterations; i++) { float x_border = float(volume_pos_x + (scene_info.infos[volume_index + 3]) * uint(x_pos)) - 0.5; float y_border = float(volume_pos_y + (scene_info.infos[volume_index + 4]) * uint(y_pos)) - 0.5; @@ -179,18 +174,18 @@ void main() { float y_factor = 2.0; float z_factor = 2.0; if (!x_null) { - x_factor = (x_border - origPosition.x) / light_direction.x; + x_factor = (x_border - starting_pos.x) / light_direction.x; } if (!y_null) { - y_factor = (y_border - origPosition.y) / light_direction.y; + y_factor = (y_border - starting_pos.y) / light_direction.y; } if (!z_null) { - z_factor = (z_border - origPosition.z) / light_direction.z; + z_factor = (z_border - starting_pos.z) / light_direction.z; } if ((x_factor >= 1.0) && (y_factor >= 1.0) && (z_factor >= 1.0)) { // no hit, add light color result - color_sum += (orig_color_sample.xyz * light_color) / ((0.1 * light_direction.length() * light_direction.length()) + 1.0); + color_sum += (orig_color_sample.xyz * light_color) / ((0.01 * length(light_direction) * length(light_direction)) + 1.0); needs_next_light = true; } else { // if there is a border hit before reaching the light @@ -205,7 +200,7 @@ void main() { } else { hit_facing = 2; } - vec3 intersection_pos = origPosition + x_factor * light_direction; + vec3 intersection_pos = starting_pos + x_factor * light_direction; u = uint(round(intersection_pos.y)) - volume_pos_y; v = uint(round(intersection_pos.z)) - volume_pos_z; } @@ -216,7 +211,7 @@ void main() { } else { hit_facing = 4; } - vec3 intersection_pos = origPosition + y_factor * light_direction; + vec3 intersection_pos = starting_pos + y_factor * light_direction; u = uint(round(intersection_pos.x)) - volume_pos_x; v = uint(round(intersection_pos.z)) - volume_pos_z; } @@ -227,7 +222,7 @@ void main() { } else { hit_facing = 1; } - vec3 intersection_pos = origPosition + z_factor * light_direction; + vec3 intersection_pos = starting_pos + z_factor * light_direction; u = uint(round(intersection_pos.x)) - volume_pos_x; v = uint(round(intersection_pos.y)) - volume_pos_y; } @@ -256,12 +251,12 @@ void main() { break; } // set up the new light - light_index = scene_info.infos[fragVolumeStart + 6 + light_num]; + light_index = scene_info.infos[volume_start + 6 + light_num]; if (light_index == 0) { // abort if there is no new light break; } - light_direction = get_light_position(light_index) - origPosition; + light_direction = get_light_position(light_index) - starting_pos; light_color = get_light_color(light_index); x_pos = light_direction.x > 0.0; @@ -273,11 +268,43 @@ void main() { z_pos = light_direction.z > 0.0; z_null = (light_direction.z == 0.0); // reset volume info - volume_index = fragVolumeStart; + volume_index = volume_start; volume_pos_x = scene_info.infos[volume_index + 0]; volume_pos_y = scene_info.infos[volume_index + 1]; volume_pos_z = scene_info.infos[volume_index + 2]; } } + return color_sum; +} + +void main() { + uint max_length = scene_info.infos[0]; + uint last = scene_info.infos[max_length]; + + uvec4 color_roughness = sample_color_from_scene_info(fragVolumeStart, fragRasterPos, facing); + vec4 orig_color_sample = vec4(float(color_roughness.x) / 255.0, float(color_roughness.y) / 255.0, float(color_roughness.z) / 255.0, 1); + + // singular raytracing + //vec3 color_sum = get_lighting_color(fragVolumeStart, origPosition, orig_color_sample); + + // diffuse raytracing using a quadratic raster of rays + int raster_half_steps = 0; + float raster_distance = 0.01; + int raster_points = (2 * raster_half_steps + 1) * (2 * raster_half_steps + 1); + + vec3 color_sum = vec3(0.0, 0.0, 0.0); + for (int u_offset = -raster_half_steps; u_offset <= raster_half_steps; u_offset++) { + for (int v_offset = -raster_half_steps; v_offset <= raster_half_steps; v_offset++) { + float x_offset = raster_distance * float(u_offset) * float(facing == 0 || facing == 1 || facing == 4 || facing == 5); + float y_offset = raster_distance * float(u_offset) * float(facing == 2 || facing == 3); + y_offset += raster_distance * float(v_offset) * float(facing == 0 || facing == 1); + float z_offset = raster_distance * float(v_offset) * float(facing == 4 || facing == 5 || facing == 2 || facing == 3); + + vec3 offset = vec3(x_offset, y_offset, z_offset); + + color_sum += get_lighting_color(fragVolumeStart, origPosition + offset, orig_color_sample) / float(raster_points); + } + } + outColor = vec4(color_sum, 1.0); } \ No newline at end of file diff --git a/src/app_data.rs b/src/app_data.rs index 9a6e5c6..91d507a 100644 --- a/src/app_data.rs +++ b/src/app_data.rs @@ -61,4 +61,5 @@ pub struct AppData { pub scene_rt_memory_size: u64, pub num_lights_per_volume: u32, + pub max_iterations_per_light: u32, } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 5c6dc6b..bda1050 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,7 +58,7 @@ const DEVICE_EXTENSIONS: &[vk::ExtensionName] = &[ vk::KHR_SWAPCHAIN_EXTENSION.name ]; -const MAX_FRAMES_IN_FLIGHT: usize = 2; +const MAX_FRAMES_IN_FLIGHT: usize = 3; fn main() -> Result<()> { pretty_env_logger::init(); @@ -179,6 +179,7 @@ impl App { let mut data = app_data::AppData::default(); data.use_geometry_shader = false; data.num_lights_per_volume = 2; + data.max_iterations_per_light = 20; let mut scene_handler = scene::Scene::default(); //load_model::load_model(&mut data)?; diff --git a/src/scene/mod.rs b/src/scene/mod.rs index 2006ece..160636a 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -138,7 +138,9 @@ impl Scene { let index = self.sized_vertices.len(); cube.draw(&data.topology, index, self); - let mut memory_index = 1; // zero should be the location for the overall length (also will be the invalid memory allocation for pointing to a nonexistant neighbor) + let mut memory_index = 2; + // 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 for light in &mut self.point_lights { light.memory_start = memory_index; memory_index += light.get_buffer_mem_size() as usize; @@ -157,6 +159,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; + for volume in &empty_volumes { volume_vec = volume.borrow().insert_into_memory(volume_vec, data.num_lights_per_volume, &self.point_lights); } diff --git a/src/scene/oct_tree.rs b/src/scene/oct_tree.rs index 006d16d..7f6a3ba 100644 --- a/src/scene/oct_tree.rs +++ b/src/scene/oct_tree.rs @@ -9,7 +9,7 @@ extern crate rand; pub const CHUNK_SIZE_EXPONENT: u32 = 4; pub const CHUNK_SIZE: usize = (2 as usize).pow(CHUNK_SIZE_EXPONENT); -pub const MAX_TREE_DEPTH: usize = 2; +pub const MAX_TREE_DEPTH: usize = CHUNK_SIZE_EXPONENT as usize - 2; pub const MIN_CHUNK_SIZE: usize = CHUNK_SIZE / (2 as usize).pow(MAX_TREE_DEPTH as u32); #[derive(Clone, Debug)]