diff --git a/blade-render/code/debug.inc.wgsl b/blade-render/code/debug.inc.wgsl index 5a2e4382..00ec256f 100644 --- a/blade-render/code/debug.inc.wgsl +++ b/blade-render/code/debug.inc.wgsl @@ -12,6 +12,8 @@ struct DebugVariance { count: u32, } struct DebugEntry { + custom_index: u32, + depth: f32, tex_coords: vec2, base_color_texture: u32, normal_texture: u32, diff --git a/blade-render/code/fill-gbuf.wgsl b/blade-render/code/fill-gbuf.wgsl index 4f777903..0c53e56b 100644 --- a/blade-render/code/fill-gbuf.wgsl +++ b/blade-render/code/fill-gbuf.wgsl @@ -124,6 +124,8 @@ fn main(@builtin(global_invocation_id) global_id: vec3) { let hit_position = camera.position + intersection.t * ray_dir; if (enable_debug) { + debug_buf.entry.custom_index = intersection.instance_custom_index; + debug_buf.entry.depth = intersection.t; debug_buf.entry.tex_coords = tex_coords; debug_buf.entry.base_color_texture = entry.base_color_texture; debug_buf.entry.normal_texture = entry.normal_texture; diff --git a/blade-render/src/render/mod.rs b/blade-render/src/render/mod.rs index 34b06759..c9b13671 100644 --- a/blade-render/src/render/mod.rs +++ b/blade-render/src/render/mod.rs @@ -105,6 +105,8 @@ impl Default for PostProcConfig { pub struct SelectionInfo { pub std_deviation: mint::Vector3, pub std_deviation_history: u32, + pub custom_index: u32, + pub depth: f32, pub tex_coords: mint::Vector2, pub base_color_texture: Option>, pub normal_texture: Option>, @@ -114,6 +116,8 @@ impl Default for SelectionInfo { Self { std_deviation: [0.0; 3].into(), std_deviation_history: 0, + custom_index: 0, + depth: 0.0, tex_coords: [0.0; 2].into(), base_color_texture: None, normal_texture: None, @@ -135,6 +139,8 @@ struct DebugVariance { #[repr(C)] #[derive(Debug)] struct DebugEntry { + custom_index: u32, + depth: f32, tex_coords: [f32; 2], base_color_texture: u32, normal_texture: u32, @@ -1537,6 +1543,8 @@ impl Renderer { } }, std_deviation_history: db_v.count, + custom_index: db_e.custom_index, + depth: db_e.depth, tex_coords: db_e.tex_coords.into(), base_color_texture: self .texture_resource_lookup diff --git a/examples/scene/main.rs b/examples/scene/main.rs index 4df0c2dc..daf83d7a 100644 --- a/examples/scene/main.rs +++ b/examples/scene/main.rs @@ -497,6 +497,13 @@ impl Example { ui.colored_label(egui::Color32::WHITE, format!("2^{}", power)); self.need_accumulation_reset |= ui.button("Reset").clicked(); }); + ui.horizontal(|ui| { + ui.label("Depth:"); + ui.colored_label( + egui::Color32::WHITE, + format!("{:.2}", selection.depth), + ); + }); ui.horizontal(|ui| { ui.label("Texture coords:"); ui.colored_label(