From c30b49821667976f1c56b8cddc931ec020c79cd6 Mon Sep 17 00:00:00 2001 From: SirLynix Date: Fri, 21 Jul 2023 08:58:50 +0200 Subject: [PATCH] ComputeParticlesTest: Update shaders --- assets/shaders/compute/compute_particle_texture.nzsl | 4 ++-- assets/shaders/compute/compute_particles.nzsl | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/assets/shaders/compute/compute_particle_texture.nzsl b/assets/shaders/compute/compute_particle_texture.nzsl index 19a388873..fc9b97410 100644 --- a/assets/shaders/compute/compute_particle_texture.nzsl +++ b/assets/shaders/compute/compute_particle_texture.nzsl @@ -22,9 +22,9 @@ fn main(input: Input) let outputColor = vec4[f32] ( - (pow(1.0 - length(uv), 20.0)).xxx, + (pow(1.0 - length(uv), 10.0)).xxx, 1.0 ); output_tex.Write(indices, outputColor); -} \ No newline at end of file +} diff --git a/assets/shaders/compute/compute_particles.nzsl b/assets/shaders/compute/compute_particles.nzsl index 4cf25318e..769f02f4b 100644 --- a/assets/shaders/compute/compute_particles.nzsl +++ b/assets/shaders/compute/compute_particles.nzsl @@ -42,9 +42,12 @@ fn main(input: Input) if (index >= data.particle_count) return; + let damping = pow(0.5, sceneData.deltaTime); + let attract_pos = sceneData.mousePos; let dist = length(attract_pos - data.particles[index].position); - data.particles[index].velocity += 10000.0 * (attract_pos - data.particles[index].position) * sceneData.deltaTime / (dist * dist); + data.particles[index].velocity += 10000.0 * (attract_pos - data.particles[index].position) * sceneData.deltaTime / (dist * dist); + data.particles[index].velocity *= damping; data.particles[index].position += data.particles[index].velocity * sceneData.deltaTime; -} \ No newline at end of file +}