Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1#define_import_path bevy_gaussian_splatting::morph::particle
3#import bevy_gaussian_splatting::bindings::{
4 gaussian_uniforms,
5 globals,
6 position_visibility,
7}
8#import bevy_gaussian_splatting::spherical_harmonics::spherical_harmonics_lookup
9#import bevy_gaussian_splatting::transform::{
10 world_to_clip,
11 in_frustum,
14struct ParticleBehavior {
15 @location(0) indicies: vec4<i32>,
16 @location(1) velocity: vec4<f32>,
17 @location(2) acceleration: vec4<f32>,
18 @location(3) jerk: vec4<f32>,
21@group(3) @binding(7) var<storage, read_write> particle_behaviors: array<ParticleBehavior>;
23@compute @workgroup_size(32, 32)
24fn apply_particle_behaviors(
25 @builtin(local_invocation_id) gl_LocalInvocationID: vec3<u32>,
26 @builtin(global_invocation_id) gl_GlobalInvocationID: vec3<u32>,
27) {
28 let behavior_index = gl_GlobalInvocationID.x * 32u + gl_GlobalInvocationID.y;
29 let behavior = particle_behaviors[behavior_index];
31 let point_index = behavior.indicies.x;
32 let point = position_visibility[point_index];
34 // TODO: add gaussian attribute setters for 4d capability
36 let delta_position = behavior.velocity * globals.delta_time + 0.5 * behavior.acceleration * globals.delta_time * globals.delta_time + 1.0 / 6.0 * behavior.jerk * globals.delta_time * globals.delta_time * globals.delta_time;
37 let delta_velocity = behavior.acceleration * globals.delta_time + 0.5 * behavior.jerk * globals.delta_time * globals.delta_time;
38 let delta_acceleration = behavior.jerk * globals.delta_time;
40 let new_position = point + delta_position;
41 let new_velocity = behavior.velocity + delta_velocity;
42 let new_acceleration = behavior.acceleration + delta_acceleration;
44 workgroupBarrier();
46 if (behavior.indicies.x < 0) {
47 return;
48 }
50 position_visibility[point_index] = new_position;
51 particle_behaviors[behavior_index].velocity = new_velocity;
52 particle_behaviors[behavior_index].acceleration = new_acceleration;
Contents