Skip to content

Commit

Permalink
Read custom index and depth from the selection
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Oct 31, 2023
1 parent 06e956c commit d8525a6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions blade-render/code/debug.inc.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ struct DebugVariance {
count: u32,
}
struct DebugEntry {
custom_index: u32,
depth: f32,
tex_coords: vec2<f32>,
base_color_texture: u32,
normal_texture: u32,
Expand Down
2 changes: 2 additions & 0 deletions blade-render/code/fill-gbuf.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {

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;
Expand Down
8 changes: 8 additions & 0 deletions blade-render/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ impl Default for PostProcConfig {
pub struct SelectionInfo {
pub std_deviation: mint::Vector3<f32>,
pub std_deviation_history: u32,
pub custom_index: u32,
pub depth: f32,
pub tex_coords: mint::Vector2<f32>,
pub base_color_texture: Option<blade_asset::Handle<crate::Texture>>,
pub normal_texture: Option<blade_asset::Handle<crate::Texture>>,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions examples/scene/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit d8525a6

Please sign in to comment.