Skip to content

Commit

Permalink
feat: gaussian camera filter
Browse files Browse the repository at this point in the history
  • Loading branch information
mosure committed Oct 2, 2024
1 parent 0ea5c3d commit da70d8f
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bevy_gaussian_splatting"
description = "bevy gaussian splatting render pipeline plugin"
version = "2.3.0"
version = "2.4.0"
edition = "2021"
authors = ["mosure <[email protected]>"]
license = "MIT"
Expand Down Expand Up @@ -134,9 +134,9 @@ webgpu = ["bevy/webgpu"]

[dependencies]
bevy_args = "1.6"
bevy-inspector-egui = { version = "0.25", optional = true }
bevy-inspector-egui = { version = "0.26", optional = true }
bevy_mod_picking = { version = "0.20", optional = true }
bevy_panorbit_camera = { version = "0.19", optional = true }
bevy_panorbit_camera = { version = "0.19", optional = true, features = ["bevy_egui"] }
bevy_transform_gizmo = { version = "0.12", optional = true }
bincode2 = { version = "2.0", optional = true }
byte-unit = { version = "5.0", optional = true }
Expand Down
2 changes: 2 additions & 0 deletions examples/headless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use bevy::{
use bevy_args::BevyArgsPlugin;

use bevy_gaussian_splatting::{
GaussianCamera,
GaussianCloud,
GaussianSplattingBundle,
GaussianSplattingPlugin,
Expand Down Expand Up @@ -407,6 +408,7 @@ fn setup_gaussian_cloud(
},
..default()
},
GaussianCamera,
));
}

Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub use material::spherical_harmonics::SphericalHarmonicCoefficients;

use io::loader::GaussianCloudLoader;

pub use render::GaussianCamera;
use render::RenderPipelinePlugin;

pub mod gaussian;
Expand Down
3 changes: 3 additions & 0 deletions src/morph/particle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ use serde::{
};

use crate::render::{
GaussianCamera,
GaussianCloudBindGroup,
GaussianCloudPipeline,
GaussianCloudPipelineKey,
Expand Down Expand Up @@ -313,6 +314,7 @@ pub struct ParticleBehaviorNode {
)>,
initialized: bool,
view_bind_group: QueryState<(
&'static GaussianCamera,
&'static GaussianViewBindGroup,
&'static ViewUniformOffset,
)>,
Expand Down Expand Up @@ -367,6 +369,7 @@ impl Node for ParticleBehaviorNode {
let command_encoder = render_context.command_encoder();

for (
_gaussian_camera,
view_bind_group,
view_uniform_offset,
) in self.view_bind_group.iter_manual(world) {
Expand Down
43 changes: 35 additions & 8 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::hash::Hash;

use bevy::{
prelude::*,
asset::{
load_internal_asset,
LoadState,
Expand All @@ -13,12 +14,13 @@ use bevy::{
SystemParamItem,
}
},
prelude::*,
render::{
Extract,
extract_component::{
ComponentUniforms,
DynamicUniformIndex,
ExtractComponent,
ExtractComponentPlugin,
UniformComponentPlugin,
},
globals::{
Expand Down Expand Up @@ -144,6 +146,7 @@ impl Plugin for RenderPipelinePlugin {
Shader::from_wgsl
);

app.add_plugins(ExtractComponentPlugin::<GaussianCamera>::default());
app.add_plugins(RenderAssetPlugin::<GpuGaussianCloud>::default());
app.add_plugins(UniformComponentPlugin::<GaussianCloudUniform>::default());

Expand Down Expand Up @@ -273,7 +276,13 @@ fn queue_gaussians(
gaussian_clouds: Res<RenderAssets<GpuGaussianCloud>>,
sorted_entries: Res<RenderAssets<GpuSortedEntry>>,
mut transparent_render_phases: ResMut<ViewSortedRenderPhases<Transparent3d>>,
mut views: Query<(Entity, &ExtractedView)>,
mut views: Query<
(
Entity,
&ExtractedView
),
With<GaussianCamera>,
>,
msaa: Res<Msaa>,
gaussian_splatting_bundles: Query<GpuGaussianBundleQuery>,
) {
Expand Down Expand Up @@ -845,6 +854,16 @@ fn queue_gaussian_bind_group(
}
}

#[derive(
Clone,
Component,
Debug,
Default,
ExtractComponent,
Reflect,
)]
pub struct GaussianCamera;

#[derive(Component)]
pub struct GaussianViewBindGroup {
pub value: BindGroup,
Expand All @@ -855,10 +874,13 @@ pub fn queue_gaussian_view_bind_groups(
render_device: Res<RenderDevice>,
gaussian_cloud_pipeline: Res<GaussianCloudPipeline>,
view_uniforms: Res<ViewUniforms>,
views: Query<(
Entity,
&ExtractedView,
)>,
views: Query<
(
Entity,
&ExtractedView,
),
With<GaussianCamera>,
>,
globals_buffer: Res<GlobalsBuffer>,
) {
if let (
Expand Down Expand Up @@ -902,15 +924,20 @@ pub struct SetGaussianViewBindGroup<const I: usize>;
impl<P: PhaseItem, const I: usize> RenderCommand<P> for SetGaussianViewBindGroup<I> {
type Param = ();
type ViewQuery = (
Read<ViewUniformOffset>,
Read<GaussianCamera>,
Read<GaussianViewBindGroup>,
Read<ViewUniformOffset>,
);
type ItemQuery = ();

#[inline]
fn render<'w>(
_item: &P,
(view_uniform, gaussian_view_bind_group): ROQueryItem<
(
_gaussian_camera,
gaussian_view_bind_group,
view_uniform,
): ROQueryItem<
'w,
Self::ViewQuery,
>,
Expand Down
1 change: 1 addition & 0 deletions src/sort/radix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ pub struct RadixSortNode {
)>,
initialized: bool,
view_bind_group: QueryState<(
&'static GaussianCamera,
&'static GaussianViewBindGroup,
&'static ViewUniformOffset,
)>,
Expand Down
2 changes: 2 additions & 0 deletions tests/gpu/gaussian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use bevy::{
};

use bevy_gaussian_splatting::{
GaussianCamera,
GaussianCloud,
GaussianSplattingBundle,
random_gaussians,
Expand Down Expand Up @@ -59,6 +60,7 @@ fn setup(
tonemapping: Tonemapping::None,
..default()
},
GaussianCamera,
));
}

Expand Down
2 changes: 2 additions & 0 deletions tests/gpu/radix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use bevy::{
};

use bevy_gaussian_splatting::{
GaussianCamera,
GaussianCloud,
GaussianSplattingBundle,
random_gaussians,
Expand Down Expand Up @@ -105,6 +106,7 @@ fn setup(
tonemapping: Tonemapping::None,
..default()
},
GaussianCamera,
));
}

Expand Down
2 changes: 2 additions & 0 deletions tools/compare_aabb_obb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use bevy_panorbit_camera::{

use bevy_gaussian_splatting::{
Gaussian,
GaussianCamera,
GaussianCloud,
GaussianCloudSettings,
GaussianSplattingBundle,
Expand Down Expand Up @@ -97,6 +98,7 @@ pub fn setup_aabb_obb_compare(
allow_upside_down: true,
..default()
},
GaussianCamera,
));
}

Expand Down
2 changes: 2 additions & 0 deletions viewer/viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use bevy_panorbit_camera::{
};

use bevy_gaussian_splatting::{
GaussianCamera,
GaussianCloud,
GaussianSplattingBundle,
GaussianSplattingPlugin,
Expand Down Expand Up @@ -93,6 +94,7 @@ fn setup_gaussian_cloud(
zoom_smoothness: 0.0,
..default()
},
GaussianCamera,
));
}

Expand Down

0 comments on commit da70d8f

Please sign in to comment.