From dd568a75e33f7f425a227cdd431f4b529f9a6aa1 Mon Sep 17 00:00:00 2001 From: zomseffen <steffen@tom.bi> Date: Mon, 13 Jan 2025 16:18:05 +0100 Subject: [PATCH] pre facing switch --- shaders/compiled/frag_rt_quad.spv | Bin 11068 -> 23196 bytes shaders/rt_quad.frag | 106 +++++++++++++++++++++++++----- src/scene/empty_volume.rs | 24 +++---- src/scene/light.rs | 8 +-- src/scene/mod.rs | 12 +++- 5 files changed, 117 insertions(+), 33 deletions(-) diff --git a/shaders/compiled/frag_rt_quad.spv b/shaders/compiled/frag_rt_quad.spv index 15b4f814b512aeb94222088c611fa16f462fe90c..16608e1a0c74a7c99e5cd0ccce2329ec41aaa49d 100644 GIT binary patch literal 23196 zcmaKz2b^40*@p*GrT3x)2q0Y)q$3bO2ucS*5OLWgo3N7XhAkmPqz0uI2`yAX>Cy$H zOI1)oQEaHFs3<5Xhy}~{Ja^`wIeW8y^UL|2e>v}a%02hanc2yRMb{qFXe`oLys>2C znGucZwQOTilm^=9s-C##0ef!JKQLvJ&A0e~4VG#&8`@^+#$t_;)Rq~Y-91!|0~c*H zK2AB9avtRgnlD3)ZRiX%f*u-;M@cY}_=$UVOx$OmiF@waF?r_9j{bpTrgwEr@9yd9 zn9|+XHF=<WR+sI@7VWxwCQl!nQZ^Vxi*gL3=xK5K80?wZIr+$r$-UEi`_>=abUUQR zDEeQFdRFIj@RE(?!Tp^xX3}j>SNF6dCiV7pOzrEP(a}G-i&1p<Ozkyv*5GE_RT)OH zF3T9-JAH6Q7X$9>8-S8)RAX7{zRv!EuD*_$z5UI;mP4Cb`AalbrEc|Ajp_gE$bMF$ z{c!!Pj9%|&6|`nQV;gILr*#dmj?<19a46ja-Mu}{6>yxZ<2SwTo+(|kQN}dZ8WPi9 zGTV<|sQt*sI%urnrc|^T+1Q}THw)jS$v+q_p#A1eKBln)ptG;9^O%k)UHy~$7A&Om z-UaUfm;WQI{?3C_r*`$Bj;eIyy(la%%BaS!)a^^9Hm0!$T62M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SRZxcZ=hC7{7vBH1^*P-GnV*IgKwg!8-F9UTH<d3dv?Na1-s`He;ZgI zb>nZQR*V1bVE1zP9borh;y(k{N8R}K)N1j+3+&zszZ>kHNc?BP`luU!C$(Dq?*-2* z_~*boQtslr;{DVQP}J_D<hSSNYkg6zC)XF?u20(jB3NJbyk!r9ZBtv~z637Yd<d>) z{<QgJuzIu2ub{c6Y4fXKebv+E*TA-`Ep2`sT(<czTx|&@ZGHp%Fs0e%BWUh}wE0c2 zzUpc7QLyc5OPk*Umu-F<u68aZZGH!=-fZ)`Xzrb~`8}|{>S^=)VB6J}Hh%yv+x#J1 z?L11_d<?AKZ1YEG?zgo0W3ayJY4dTg?P_y>-9xRG_J0DNU+_NzFE03>gUj>x7x0yZ z{V&1g`S>Z^{l1uASx->^jA9$+HJ9<m=x2YPqShz<`77|kg8wymS;2n}UQzI0fJX}c zOYoY4{|(slmj3)L*fz{-F5`bm(a-)oO|4J*^LJp^$KS#;ssEm0pVi~@54CRmGhlga z{|GMQ{|Rmz>hbw!u)6WjQp;oe7qDxV_Wu<;n{po|KK}+*5C3<td9pA51FVmFeEt(` zUvrQA7g)_bmVNi%VD;>~<oh2qb862%`(Lnq)t0{g3T$7EPrJVctB3yvY+uul--6Z3 ze*6xu-t5Q!p_xy6`tko@`=TxH-tWQ3Q%<00PuqV0YjfV8qn5|UpA9Na+w<sh|G#9G z5WF?Dy1z~3`E9xj+U^uTyHfJobT_cSL0?RrHadt?Pd_{1>8G~%%>Zl5-v(!b)ncCo zHc#f@g>W_JE4jCVC%5**ZVlF!+}nWFV&4{A=H3pjwxr0tJv_O!Cw2$0w&b1-R$I(p TMVzM{!H&f?wK<n+&gCBgivN?{ diff --git a/shaders/rt_quad.frag b/shaders/rt_quad.frag index 495d707..307b9aa 100644 --- a/shaders/rt_quad.frag +++ b/shaders/rt_quad.frag @@ -133,8 +133,8 @@ vec3 get_light_position(uint light_index) { return vec3(float(scene_info.infos[light_index]), float(scene_info.infos[light_index + 1]), float(scene_info.infos[light_index + 2])); } -vec4 get_light_color(uint light_index) { - return vec4(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, 1.0); +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() { @@ -147,22 +147,29 @@ void main() { uint max_light_num = scene_info.infos[0]; uint light_num = 0; uint volume_index = fragVolumeStart; - uint light_index = scene_info.infos[fragVolumeStart + 3]; + 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]; + uint light_index = scene_info.infos[volume_index + 6]; vec3 light_direction = get_light_position(light_index) - origPosition; - vec4 light_color = get_light_color(light_index); + vec3 light_color = get_light_color(light_index); bool x_pos = light_direction.x > 0.0; - bool x_null = light_direction.x == 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 y_null = (light_direction.y == 0.0); bool z_pos = light_direction.z > 0.0; - bool z_null = light_direction.z == 0.0; + bool z_null = (light_direction.z == 0.0); - uint max_iterations = max_light_num * 20; + vec3 color_sum = vec3(0.0, 0.0, 0.0) + (color_sample.xyz * 0.01); + + uint max_iterations = 2; //max_light_num * 20; for (int i = 0; i < max_iterations; i++) { - float x_border = float(scene_info.infos[volume_index + 0] + scene_info.infos[volume_index + 3] * uint(x_pos)); - float y_border = float(scene_info.infos[volume_index + 1] + scene_info.infos[volume_index + 4] * uint(y_pos)); - float z_border = float(scene_info.infos[volume_index + 2] + scene_info.infos[volume_index + 5] * uint(z_pos)); + 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; + float z_border = float(volume_pos_z + (scene_info.infos[volume_index + 5]) * uint(z_pos)) - 0.5; + + bool needs_next_light = false; // 2 is way behind the light position and should result in no collision being detected float x_factor = 2.0; @@ -172,17 +179,84 @@ void main() { x_factor = (x_border - origPosition.x) / light_direction.x; } if (!y_null) { - float y_factor = (y_border - origPosition.y) / light_direction.y; + y_factor = (y_border - origPosition.y) / light_direction.y; } if (!z_null) { - float z_factor = (z_border - origPosition.z) / light_direction.z; + z_factor = (z_border - origPosition.z) / light_direction.z; } - + if ((x_factor >= 0.999 && y_factor >= 0.999 && z_factor >= 0.999)) { + // no hit, add light color result + color_sum += (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 + // change to the relevant next volume + // Todo: look into removing ifs from this + uint hit_facing = 0; + uint u = 0; + uint v = 0; + if (x_factor <= y_factor && x_factor <= z_factor) { + if (x_pos) { + hit_facing = 3; + } else { + 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; + } + + if (y_factor <= x_factor && y_factor <= z_factor) { + if (y_pos) { + hit_facing = 5; + } else { + 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; + } + + if (z_factor <= x_factor && z_factor <= y_factor) { + if (y_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; + } + 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); + + 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]; + } 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; + } + } + if (needs_next_light) { + break; + } } - - outColor = color_sample; + // 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); diff --git a/src/scene/empty_volume.rs b/src/scene/empty_volume.rs index cbe73bb..d6407f6 100644 --- a/src/scene/empty_volume.rs +++ b/src/scene/empty_volume.rs @@ -216,8 +216,8 @@ impl EmptyVolume { bottom_roughness.push(128); } else { - bottom_colors.push(Vector3 { x: 255, y: 255, z: 255 }); - bottom_roughness.push(255); + bottom_colors.push(Vector3 { x: 0, y: 0, z: 0 }); + bottom_roughness.push(0); } } } @@ -242,8 +242,8 @@ impl EmptyVolume { top_roughness.push(128); } else { - top_colors.push(Vector3 { x: 255, y: 255, z: 255 }); - top_roughness.push(255); + top_colors.push(Vector3 { x: 0, y: 0, z: 0 }); + top_roughness.push(0); } } } @@ -269,8 +269,8 @@ impl EmptyVolume { back_roughness.push(128); } else { - back_colors.push(Vector3 { x: 255, y: 255, z: 255 }); - back_roughness.push(255); + back_colors.push(Vector3 { x: 0, y: 0, z: 0 }); + back_roughness.push(0); } } } @@ -296,8 +296,8 @@ impl EmptyVolume { front_roughness.push(128); } else { - front_colors.push(Vector3 { x: 255, y: 255, z: 255 }); - front_roughness.push(255); + front_colors.push(Vector3 { x: 0, y: 0, z: 0 }); + front_roughness.push(0); } } } @@ -323,8 +323,8 @@ impl EmptyVolume { left_roughness.push(128); } else { - left_colors.push(Vector3 { x: 255, y: 255, z: 255 }); - left_roughness.push(255); + left_colors.push(Vector3 { x: 0, y: 0, z: 0 }); + left_roughness.push(0); } } } @@ -350,8 +350,8 @@ impl EmptyVolume { right_roughness.push(128); } else { - right_colors.push(Vector3 { x: 255, y: 255, z: 255 }); - right_roughness.push(255); + right_colors.push(Vector3 { x: 0, y: 0, z: 0 }); + right_roughness.push(0); } } } diff --git a/src/scene/light.rs b/src/scene/light.rs index a83b754..4893dd3 100644 --- a/src/scene/light.rs +++ b/src/scene/light.rs @@ -11,7 +11,7 @@ pub struct PointLight{ impl PointLight { pub fn get_buffer_mem_size(&self) -> u32 { - 4 * 3 + 4 * 3 + 3 + 3 } pub fn insert_into_memory(&self, mut v: Vec<u32>) -> Vec<u32> { @@ -19,9 +19,9 @@ impl PointLight { v[self.memory_start + 1] = self.pos.y as u32; v[self.memory_start + 2] = self.pos.z as u32; - v[self.memory_start + 3] = self.color.x as u32; - v[self.memory_start + 4] = self.color.y as u32; - v[self.memory_start + 5] = self.color.z as u32; + v[self.memory_start + 3] = (self.color.x * 255.0) as u32; + v[self.memory_start + 4] = (self.color.y * 255.0) as u32; + v[self.memory_start + 5] = (self.color.z * 255.0) as u32; v } diff --git a/src/scene/mod.rs b/src/scene/mod.rs index 7d710ff..e241b51 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -6,7 +6,7 @@ use anyhow::Ok; use vulkanalia::prelude::v1_0::*; use anyhow::Result; -use cgmath::{vec2, vec3}; +use cgmath::{vec2, vec3, Vector3}; use std::cell::RefCell; use std::rc::Rc; @@ -14,6 +14,7 @@ use std::rc::Rc; use crate::app_data; use crate::app_data::AppData; use crate::buffer; +use crate::primitives::rec_cuboid::Cuboid; use crate::vertex; use crate::primitives::cube::Cube; use crate::primitives::drawable::Drawable; @@ -117,6 +118,15 @@ impl Scene { None => {} } } + + let cube = Cuboid { + pos: vec3(11.0, 11.0, 11.0), + color: vec3(shade, 1.0, shade), + tex_coord: vec2(0.0, 0.0), + size: Vector3 {x: 0.5, y: 0.5, z: 0.5} + }; + 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) for light in &mut self.point_lights {