Skip to content

Commit

Permalink
Extend DebugEntry, fix debug draw and GLB loading
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Nov 4, 2023
1 parent 36109ea commit a92ef95
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
3 changes: 3 additions & 0 deletions blade-render/code/debug.inc.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ struct DebugEntry {
tex_coords: vec2<f32>,
base_color_texture: u32,
normal_texture: u32,
pad: vec2<u32>,
position: vec3<f32>,
flat_normal: vec3<f32>,
}
struct DebugBuffer {
vertex_count: u32,
Expand Down
9 changes: 9 additions & 0 deletions blade-render/code/fill-gbuf.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
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;
debug_buf.entry.position = hit_position;
debug_buf.entry.flat_normal = flat_normal;
}
if (enable_debug && (debug.draw_flags & DebugDrawFlags_SPACE) != 0u) {
let normal_len = 0.15 * intersection.t;
let side = 0.05 * intersection.t;
debug_line(hit_position, hit_position + normal_len * normal_geo, 0xFFFFFFu);
debug_line(hit_position - side * tangent_geo, hit_position + side * tangent_geo, 0x808080u);
debug_line(hit_position - side * bitangent_geo, hit_position + side * bitangent_geo, 0x808080u);
}
if (enable_debug && (debug.draw_flags & DebugDrawFlags_GEOMETRY) != 0u) {
let debug_len = intersection.t * 0.2;
Expand Down
2 changes: 1 addition & 1 deletion blade-render/src/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ impl blade_asset::Baker for Baker {
) {
match extension {
#[cfg(feature = "asset")]
"gltf" => {
"gltf" | "glb" => {
use base64::engine::{general_purpose::URL_SAFE as ENCODING_ENGINE, Engine as _};

let gltf::Gltf { document, mut blob } = gltf::Gltf::from_slice(source).unwrap();
Expand Down
12 changes: 9 additions & 3 deletions blade-render/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ impl Default for DebugMode {
bitflags::bitflags! {
#[derive(Copy, Clone, Debug, Default, Hash, Eq, PartialEq, PartialOrd)]
pub struct DebugDrawFlags: u32 {
const GEOMETRY = 1;
const RESTIR = 2;
const SPACE = 1;
const GEOMETRY = 2;
const RESTIR = 4;
}
}

Expand Down Expand Up @@ -144,6 +145,11 @@ struct DebugEntry {
tex_coords: [f32; 2],
base_color_texture: u32,
normal_texture: u32,
pad: [u32; 2],
position: [f32; 3],
position_w: f32,
normal: [f32; 3],
normal_w: f32,
}

struct DebugRender {
Expand Down Expand Up @@ -799,7 +805,7 @@ impl Renderer {
buffer_size: sp.debug_buffer_size,
};

let debug_init_data = [2u32, 0, 0, config.max_debug_lines];
let debug_init_data = [2u32, 0, 0, 0, config.max_debug_lines];
let debug_init_size = debug_init_data.len() * mem::size_of::<u32>();
assert!(debug_init_size <= mem::size_of::<DebugEntry>());
unsafe {
Expand Down

0 comments on commit a92ef95

Please sign in to comment.