diff --git a/Cargo.toml b/Cargo.toml index 7b8f7c2a..789bfc5c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,7 @@ default = [ "query_select", # "query_sparse", - # "morph_particles", + "morph_particles", # "sort_radix", # TODO: fix macos radix sort "sort_rayon", diff --git a/src/morph/particle.rs b/src/morph/particle.rs index 944f4e84..89a64231 100644 --- a/src/morph/particle.rs +++ b/src/morph/particle.rs @@ -61,6 +61,7 @@ use bevy::{ NodeRunError, RenderGraphApp, RenderGraphContext, + RenderLabel, }, Render, RenderApp, @@ -88,9 +89,9 @@ use crate::render::{ const PARTICLE_SHADER_HANDLE: Handle = Handle::weak_from_u128(234553453455); -pub mod node { - pub const MORPH: &str = "gaussian_cloud_particle_behavior"; -} + +#[derive(Debug, Hash, PartialEq, Eq, Clone, RenderLabel)] +pub struct MorphLabel; #[derive(Default)] @@ -114,11 +115,11 @@ impl Plugin for ParticleBehaviorPlugin { render_app .add_render_graph_node::( Core3d, - node::MORPH, + MorphLabel, ) .add_render_graph_edge( Core3d, - node::MORPH, + MorphLabel, Node3d::Prepass, ); diff --git a/src/morph/particle.wgsl b/src/morph/particle.wgsl index 6f3182c2..8f22b9de 100644 --- a/src/morph/particle.wgsl +++ b/src/morph/particle.wgsl @@ -3,7 +3,7 @@ #import bevy_gaussian_splatting::bindings::{ gaussian_uniforms, globals, - points, + position_visibility, } #import bevy_gaussian_splatting::spherical_harmonics::spherical_harmonics_lookup #import bevy_gaussian_splatting::transform::{ @@ -31,7 +31,7 @@ fn apply_particle_behaviors( let behavior = particle_behaviors[behavior_index]; let point_index = behavior.indicies.x; - let point = points[point_index]; + let point = position_visibility[point_index]; // TODO: add gaussian attribute setters for 4d capability @@ -39,7 +39,7 @@ fn apply_particle_behaviors( let delta_velocity = behavior.acceleration * globals.delta_time + 0.5 * behavior.jerk * globals.delta_time * globals.delta_time; let delta_acceleration = behavior.jerk * globals.delta_time; - let new_position = point.position_visibility + delta_position; + let new_position = point + delta_position; let new_velocity = behavior.velocity + delta_velocity; let new_acceleration = behavior.acceleration + delta_acceleration; @@ -49,7 +49,7 @@ fn apply_particle_behaviors( return; } - points[point_index].position_visibility = new_position; + position_visibility[point_index] = new_position; particle_behaviors[behavior_index].velocity = new_velocity; particle_behaviors[behavior_index].acceleration = new_acceleration; } diff --git a/src/render/planar.rs b/src/render/planar.rs index 3e87624d..17fd24f6 100644 --- a/src/render/planar.rs +++ b/src/render/planar.rs @@ -163,7 +163,7 @@ pub fn get_bind_group_layout( binding: 1, visibility: ShaderStages::all(), ty: BindingType::Buffer { - ty: BufferBindingType::Storage { read_only }, + ty: BufferBindingType::Storage { read_only: true }, has_dynamic_offset: false, min_binding_size: BufferSize::new(std::mem::size_of::() as u64), }, @@ -173,7 +173,7 @@ pub fn get_bind_group_layout( binding: 2, visibility: ShaderStages::all(), ty: BindingType::Buffer { - ty: BufferBindingType::Storage { read_only }, + ty: BufferBindingType::Storage { read_only: true }, has_dynamic_offset: false, min_binding_size: BufferSize::new(std::mem::size_of::() as u64), }, diff --git a/viewer/viewer.rs b/viewer/viewer.rs index fc366e78..d96ed915 100644 --- a/viewer/viewer.rs +++ b/viewer/viewer.rs @@ -101,11 +101,13 @@ fn setup_particle_behavior( mut commands: Commands, gaussian_splatting_viewer: Res, mut particle_behavior_assets: ResMut>, - gaussian_cloud: Query<( - Entity, - &Handle, + gaussian_cloud: Query< + ( + Entity, + &Handle, + ), Without>, - )>, + >, ) { if gaussian_cloud.is_empty() { return;