From 4c4b8288d5f64fb939532b3c0b1c1a52bffec7d7 Mon Sep 17 00:00:00 2001 From: zomseffen Date: Tue, 14 Jan 2025 16:01:18 +0100 Subject: [PATCH] void tracing for spot lights --- shaders/compiled/frag_rt_quad.spv | Bin 23196 -> 22728 bytes shaders/rt_quad.frag | 65 +++++++++-------------------- src/main.rs | 2 +- src/scene/empty_volume.rs | 67 +++++++++++++++--------------- src/scene/mod.rs | 2 +- 5 files changed, 55 insertions(+), 81 deletions(-) diff --git a/shaders/compiled/frag_rt_quad.spv b/shaders/compiled/frag_rt_quad.spv index 16608e1a0c74a7c99e5cd0ccce2329ec41aaa49d..eafd9b98c8190e4dd8473bd0b06d3c639a892a0b 100644 GIT binary patch literal 22728 zcmaKz2bf(|)rK!&CW-Wpg%XMsL8KQE2p|Nc6G0Gl9Fj>gkj#XcNk}46Lg*SminJ)8 z^nmmxpdg@t1shmUQBgrrL9w8s|NEYMzucXZ;h%^7?60h~b~*c;d+uaddc+2!8jYnI z%Qlv8Jg{`5`dPU#0;PdAvg*g}KYsr$28SkYvF&zS8n8m68EDLkjb$1g^tNf;y?u0z z{YEqz2ha|rok6>s@Ri6hhQUBfGeV>B2n9OGAGd$kxPuNFxBp&U6Q)n^8XTHEwWn)p zZ(mQ>#NL6P2}8XzdyE@h#P#+~m^x!(8PG{YIfqV0T9z?p^iA)caBSCv{;B-~o6Oj1 zXQW0a<1a%$vwJFd`Npc?!R~3(8Md#dck+~@`vEPDGU^_x0##@0Jm z6*}3MmCWy-I%8T76Yd@uf>Nuqu`>NY_ux>^K-cvC!RA=2piQd$HizZ zan>MyxN+7*uaEOqwB|UY8|#86_YAR*lcx+hmENJ={=Vi8IL~$Pn_h3<#GY9wqZ;ck zmebxcA#;$EVLkU{bmK~EHutlhTKU($nP1I!bYmfYwXaKLyAPuqw-4_-?aIHGzPX1>7BK&z zH}RY69^H5pzq!xD=Rf%-e)6Bjul9S%^lE<34DYw*KeF*0{^IAjdHtU^uYOL^ysuuM zuboBoQH>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=nmc;12ACh;S| zUY~rP8U=UE>S;3?tZuyLSb4m$;4=PQaQjeCo5jHD#(VCS$6EsIHB0|X!u@PB4lQk# zLQ@Z48f>2Ii)FyJQBRv?!HzZ0k>$W@?y>B<<>BhtcgeQ`nmP5e&sGFGR=tdMC9q>P zKK-tYrXIcu*s*3DtAf?aal9L@ULVJM(9EZwajXV*EP6Q)jsxd?Pd|OH4%Tzs{d^&h zwR>;Eu1TFf)*((k<9shX=)?mGia~rT){@>MhV6|;2iTMz?>~DLxTKPF-2YC9^Pwb9hz4SK$td{ 0.0; bool x_null = (light_direction.x == 0.0); + bool y_pos = light_direction.y > 0.0; bool y_null = (light_direction.y == 0.0); + bool z_pos = light_direction.z > 0.0; bool z_null = (light_direction.z == 0.0); - vec3 color_sum = vec3(0.0, 0.0, 0.0) + (color_sample.xyz * 0.01); + vec3 color_sum = vec3(0.0, 0.0, 0.0) + (orig_color_sample.xyz * 0.01); - uint max_iterations = 2; //max_light_num * 20; + uint max_iterations = max_light_num * 20; 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; @@ -185,9 +186,9 @@ void main() { z_factor = (z_border - origPosition.z) / light_direction.z; } - if ((x_factor >= 0.999 && y_factor >= 0.999 && z_factor >= 0.999)) { + if ((x_factor >= 1.0) && (y_factor >= 1.0) && (z_factor >= 1.0)) { // no hit, add light color result - color_sum += (color_sample.xyz * light_color) / (0.01 * light_direction.length() * light_direction.length() + 1.0); + color_sum += (orig_color_sample.xyz * light_color) / ((0.01 * light_direction.length() * light_direction.length()) + 1.0); needs_next_light = true; } else { // if there is a border hit before reaching the light @@ -203,8 +204,8 @@ void main() { hit_facing = 2; } vec3 intersection_pos = origPosition + x_factor * light_direction; - u = uint(ceil(intersection_pos.y)) - volume_pos_y; - v = uint(ceil(intersection_pos.z)) - volume_pos_z; + u = uint(round(intersection_pos.y)) - volume_pos_y; + v = uint(round(intersection_pos.z)) - volume_pos_z; } if (y_factor <= x_factor && y_factor <= z_factor) { @@ -214,19 +215,19 @@ void main() { hit_facing = 4; } vec3 intersection_pos = origPosition + y_factor * light_direction; - u = uint(ceil(intersection_pos.x)) - volume_pos_x; - v = uint(ceil(intersection_pos.z)) - volume_pos_z; + u = uint(round(intersection_pos.x)) - volume_pos_x; + v = uint(round(intersection_pos.z)) - volume_pos_z; } if (z_factor <= x_factor && z_factor <= y_factor) { - if (y_pos) { + if (z_pos) { hit_facing = 0; } else { hit_facing = 1; } vec3 intersection_pos = origPosition + z_factor * light_direction; - u = uint(ceil(intersection_pos.x)) - volume_pos_x; - v = uint(ceil(intersection_pos.y)) - volume_pos_y; + u = uint(round(intersection_pos.x)) - volume_pos_x; + v = uint(round(intersection_pos.y)) - volume_pos_y; } uint next_neighbor = sample_neighbor_from_scene_info(volume_index, uvec2(u, v), hit_facing); uvec4 color_sample = sample_color_from_scene_info(volume_index, uvec2(u, v), hit_facing); @@ -234,18 +235,15 @@ void main() { if (color_sample == uvec4(0, 0, 0, 0)) { // not a color hit, so check neighbor if (next_neighbor != 0) { - color_sum = vec3(1.0, 0.0, 0.0); volume_index = next_neighbor; - 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]; + 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]; } else { - color_sum = vec3(0.0, 0.0, 1.0); // neightbor miss, shouldn't happen with a light inside of a volume. Might happen with ambient light. For now move on to next light. needs_next_light = true; } } else { - color_sum = vec3(1.0, 0.0, 1.0); // color hit, move on to next light (may change once transparents are implemnted) needs_next_light = true; } @@ -254,30 +252,5 @@ void main() { break; } } - - // todo light color memory index does not contain the expected values -> check outColor = vec4(color_sum, 1.0); - - /*if (scene_info.infos[1] == 16) { - outColor = vec4(0, 1, 0, 1); - }*/ - - /*if (fragVolumeStart == 1 && scene_info.infos[fragVolumeStart] == 16) { - outColor = vec4(0, 1, 0, 1); - }*/ - - /*if (facing == 0) { - outColor = vec4(1, 0, 0, 1); - } else if (facing == 1) { - outColor = vec4(0, 1, 1, 1); - } else if (facing == 2) { - outColor = vec4(0, 1, 0, 1); - } else if (facing == 3) { - outColor = vec4(1, 0, 1, 1); - } else if (facing == 4) { - outColor = vec4(0, 0, 1, 1); - } else if (facing == 5) { - outColor = vec4(1, 1, 0, 1); - }*/ - } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index b10bddb..9674aea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -457,7 +457,7 @@ impl App { vk::MemoryMapFlags::empty(), )?; - memcpy(self.scene_handler.rt_memory.as_ptr(), memory.cast(), 2103); + memcpy(self.scene_handler.rt_memory.as_ptr(), memory.cast(), self.scene_handler.rt_memory.len()); self.device.unmap_memory(self.data.storage_buffers_memory[image_index]); diff --git a/src/scene/empty_volume.rs b/src/scene/empty_volume.rs index d6407f6..6176f33 100644 --- a/src/scene/empty_volume.rs +++ b/src/scene/empty_volume.rs @@ -168,10 +168,11 @@ impl EmptyVolume { for x in 0..x_size+1 { for y in 0..y_size+1 { for z in 0..z_size+1 { + neighbors.set_element(reference.clone(), reference.borrow().position.x + x, reference.borrow().position.y + y, reference.borrow().position.z + z); // fill only the edges - if x == 0 || x == x_size || y == 0 || y == y_size || z==0 || z == z_size { + /*if x == 0 || x == x_size || y == 0 || y == y_size || z==0 || z == z_size { neighbors.set_element(reference.clone(), reference.borrow().position.x + x, reference.borrow().position.y + y, reference.borrow().position.z + z) - } + }*/ } } } @@ -724,7 +725,7 @@ impl EmptyVolume { mem_index += 1; v[mem_index] = self.position.y as u32; mem_index += 1; - v[mem_index] = self.position.y as u32; + v[mem_index] = self.position.z as u32; mem_index += 1; //max sizes v[mem_index] = self.size_x as u32; @@ -740,7 +741,7 @@ impl EmptyVolume { mem_index += 1; } //color/roughness buffer sizes, 2 values each - if self.color_top.len() > 0 { + if self.color_top.len() > 1 { v[mem_index] = self.size_x as u32; v[mem_index + 1] = self.size_y as u32; } else { @@ -749,7 +750,7 @@ impl EmptyVolume { } mem_index += 2; - if self.color_bottom.len() > 0 { + if self.color_bottom.len() > 1 { v[mem_index] = self.size_x as u32; v[mem_index + 1] = self.size_y as u32; } else { @@ -758,7 +759,7 @@ impl EmptyVolume { } mem_index += 2; - if self.color_left.len() > 0 { + if self.color_left.len() > 1 { v[mem_index] = self.size_y as u32; v[mem_index + 1] = self.size_z as u32; } else { @@ -767,7 +768,7 @@ impl EmptyVolume { } mem_index += 2; - if self.color_right.len() > 0 { + if self.color_right.len() > 1 { v[mem_index] = self.size_y as u32; v[mem_index + 1] = self.size_z as u32; } else { @@ -776,7 +777,7 @@ impl EmptyVolume { } mem_index += 2; - if self.color_front.len() > 0 { + if self.color_front.len() > 1 { v[mem_index] = self.size_x as u32; v[mem_index + 1] = self.size_z as u32; } else { @@ -785,7 +786,7 @@ impl EmptyVolume { } mem_index += 2; - if self.color_back.len() > 0 { + if self.color_back.len() > 1 { v[mem_index] = self.size_x as u32; v[mem_index + 1] = self.size_z as u32; } else { @@ -794,7 +795,7 @@ impl EmptyVolume { } mem_index += 2; //neighbor buffer sizes, 2 values each - if self.neighbor_top.len() > 0 { + if self.neighbor_top.len() > 1 { v[mem_index] = self.size_x as u32; v[mem_index + 1] = self.size_y as u32; } else { @@ -803,7 +804,7 @@ impl EmptyVolume { } mem_index += 2; - if self.neighbor_bottom.len() > 0 { + if self.neighbor_bottom.len() > 1 { v[mem_index] = self.size_x as u32; v[mem_index + 1] = self.size_y as u32; } else { @@ -812,7 +813,7 @@ impl EmptyVolume { } mem_index += 2; - if self.neighbor_left.len() > 0 { + if self.neighbor_left.len() > 1 { v[mem_index] = self.size_y as u32; v[mem_index + 1] = self.size_z as u32; } else { @@ -821,7 +822,7 @@ impl EmptyVolume { } mem_index += 2; - if self.neighbor_right.len() > 0 { + if self.neighbor_right.len() > 1 { v[mem_index] = self.size_y as u32; v[mem_index + 1] = self.size_z as u32; } else { @@ -830,7 +831,7 @@ impl EmptyVolume { } mem_index += 2; - if self.neighbor_front.len() > 0 { + if self.neighbor_front.len() > 1 { v[mem_index] = self.size_x as u32; v[mem_index + 1] = self.size_z as u32; } else { @@ -839,7 +840,7 @@ impl EmptyVolume { } mem_index += 2; - if self.neighbor_back.len() > 0 { + if self.neighbor_back.len() > 1 { v[mem_index] = self.size_x as u32; v[mem_index + 1] = self.size_z as u32; } else { @@ -860,7 +861,7 @@ impl EmptyVolume { } } else { - v[mem_index] = u32::from_ne_bytes([255, 255, 255, 255]); + v[mem_index] = u32::from_ne_bytes([0, 0, 0, 0]); mem_index += 1; } @@ -874,7 +875,7 @@ impl EmptyVolume { } } else { - v[mem_index] = u32::from_ne_bytes([255, 255, 255, 255]); + v[mem_index] = u32::from_ne_bytes([0, 0, 0, 0]); mem_index += 1; } @@ -888,7 +889,7 @@ impl EmptyVolume { } } else { - v[mem_index] = u32::from_ne_bytes([255, 255, 255, 255]); + v[mem_index] = u32::from_ne_bytes([0, 0, 0, 0]); mem_index += 1; } @@ -902,7 +903,7 @@ impl EmptyVolume { } } else { - v[mem_index] = u32::from_ne_bytes([255, 255, 255, 255]); + v[mem_index] = u32::from_ne_bytes([0, 0, 0, 0]); mem_index += 1; } @@ -916,7 +917,7 @@ impl EmptyVolume { } } else { - v[mem_index] = u32::from_ne_bytes([255, 255, 255, 255]); + v[mem_index] = u32::from_ne_bytes([0, 0, 0, 0]); mem_index += 1; } @@ -930,14 +931,14 @@ impl EmptyVolume { } } else { - v[mem_index] = u32::from_ne_bytes([255, 255, 255, 255]); + v[mem_index] = u32::from_ne_bytes([0, 0, 0, 0]); mem_index += 1; } // neighbors if self.neighbor_top.len() > 0 { - for value in &self.neighbor_top { - if let Some(reference) = value { + for nvalue in &self.neighbor_top { + if let Some(reference) = nvalue { v[mem_index] = reference.borrow().memory_start as u32; } else { @@ -952,8 +953,8 @@ impl EmptyVolume { } if self.neighbor_bottom.len() > 0 { - for value in &self.neighbor_bottom { - if let Some(reference) = value { + for nvalue in &self.neighbor_bottom { + if let Some(reference) = nvalue { v[mem_index] = reference.borrow().memory_start as u32; } else { @@ -968,8 +969,8 @@ impl EmptyVolume { } if self.neighbor_left.len() > 0 { - for value in &self.neighbor_left { - if let Some(reference) = value { + for nvalue in &self.neighbor_left { + if let Some(reference) = nvalue { v[mem_index] = reference.borrow().memory_start as u32; } else { @@ -984,8 +985,8 @@ impl EmptyVolume { } if self.neighbor_right.len() > 0 { - for value in &self.neighbor_right { - if let Some(reference) = value { + for nvalue in &self.neighbor_right { + if let Some(reference) = nvalue { v[mem_index] = reference.borrow().memory_start as u32; } else { @@ -1000,8 +1001,8 @@ impl EmptyVolume { } if self.neighbor_front.len() > 0 { - for value in &self.neighbor_front { - if let Some(reference) = value { + for nvalue in &self.neighbor_front { + if let Some(reference) = nvalue { v[mem_index] = reference.borrow().memory_start as u32; } else { @@ -1016,8 +1017,8 @@ impl EmptyVolume { } if self.neighbor_back.len() > 0 { - for value in &self.neighbor_back { - if let Some(reference) = value { + for nvalue in &self.neighbor_back { + if let Some(reference) = nvalue { v[mem_index] = reference.borrow().memory_start as u32; } else { diff --git a/src/scene/mod.rs b/src/scene/mod.rs index e241b51..61609bd 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -82,7 +82,7 @@ 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(shade, 1.0, shade), + color: vec3(1.0, 1.0, 0.0), tex_coord: vec2(0.0, 0.0) };