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,
15struct ParticleBehavior {
16 @location(0) indicies: vec4<i32>,
17 @location(1) velocity: vec4<f32>,
18 @location(2) acceleration: vec4<f32>,
19 @location(3) jerk: vec4<f32>,
22@group(3) @binding(7) var<storage, read_write> particle_behaviors: array<ParticleBehavior>;
25@compute @workgroup_size(32, 32)
26fn apply_particle_behaviors(
27 @builtin(local_invocation_id) gl_LocalInvocationID: vec3<u32>,
28 @builtin(global_invocation_id) gl_GlobalInvocationID: vec3<u32>,
29) {
30 let behavior_index = gl_GlobalInvocationID.x * 32u + gl_GlobalInvocationID.y;
31 let behavior = particle_behaviors[behavior_index];
33 let point_index = behavior.indicies.x;
34 let point = position_visibility[point_index];
36 // TODO: add gaussian attribute setters for 4d capability
38 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;
39 let delta_velocity = behavior.acceleration * globals.delta_time + 0.5 * behavior.jerk * globals.delta_time * globals.delta_time;
40 let delta_acceleration = behavior.jerk * globals.delta_time;
42 let new_position = point + delta_position;
43 let new_velocity = behavior.velocity + delta_velocity;
44 let new_acceleration = behavior.acceleration + delta_acceleration;
46 workgroupBarrier();
48 if (behavior.indicies.x < 0) {
49 return;
50 }
52 position_visibility[point_index] = new_position;
53 particle_behaviors[behavior_index].velocity = new_velocity;
54 particle_behaviors[behavior_index].acceleration = new_acceleration;
Contents