diff --git a/Cargo.toml b/Cargo.toml index 4e4e77af..e016531f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_gaussian_splatting" description = "bevy gaussian splatting render pipeline plugin" -version = "2.0.0" +version = "2.0.1" edition = "2021" authors = ["mosure "] license = "MIT" @@ -88,6 +88,8 @@ sort_std = [] tooling = ["byte-unit"] +perftest = [] + viewer = [ "bevy-inspector-egui", "bevy_panorbit_camera", diff --git a/src/render/planar.wgsl b/src/render/planar.wgsl index b1e85d11..a65f8751 100644 --- a/src/render/planar.wgsl +++ b/src/render/planar.wgsl @@ -13,6 +13,8 @@ } +#ifdef PLANAR_F16 + fn get_color( index: u32, ray_direction: vec3, @@ -22,9 +24,6 @@ fn get_color( return srgb_to_linear(color); } - -#ifdef PLANAR_F16 - fn get_position(index: u32) -> vec3 { return position_visibility[index].xyz; } @@ -73,6 +72,15 @@ fn get_visibility(index: u32) -> f32 { #ifdef PLANAR_F32 +fn get_color( + index: u32, + ray_direction: vec3, +) -> vec3 { + let sh = get_spherical_harmonics(index); + let color = spherical_harmonics_lookup(ray_direction, sh); + return srgb_to_linear(color); +} + fn get_position(index: u32) -> vec3 { return position_visibility[index].xyz; } diff --git a/src/render/texture.wgsl b/src/render/texture.wgsl index 1950b77d..b6148a94 100644 --- a/src/render/texture.wgsl +++ b/src/render/texture.wgsl @@ -10,6 +10,7 @@ }; #import bevy_gaussian_splatting::spherical_harmonics::{ shc, + spherical_harmonics_lookup, srgb_to_linear, } diff --git a/viewer/viewer.rs b/viewer/viewer.rs index 4ebb1e2b..f6bb3730 100644 --- a/viewer/viewer.rs +++ b/viewer/viewer.rs @@ -228,9 +228,14 @@ fn example_app() { let primary_window = Some(Window { fit_canvas_to_parent: true, mode: bevy::window::WindowMode::Windowed, - present_mode: bevy::window::PresentMode::AutoVsync, prevent_default_event_handling: true, title: config.name.clone(), + + #[cfg(feature = "perftest")] + present_mode: bevy::window::PresentMode::AutoNoVsync, + #[cfg(not(feature = "perftest"))] + present_mode: bevy::window::PresentMode::AutoVsync, + ..default() }); @@ -238,10 +243,15 @@ fn example_app() { let primary_window = Some(Window { fit_canvas_to_parent: true, mode: bevy::window::WindowMode::Windowed, - present_mode: bevy::window::PresentMode::AutoVsync, prevent_default_event_handling: false, resolution: (config.width, config.height).into(), title: config.name.clone(), + + #[cfg(feature = "perftest")] + present_mode: bevy::window::PresentMode::AutoNoVsync, + #[cfg(not(feature = "perftest"))] + present_mode: bevy::window::PresentMode::AutoVsync, + ..default() });