ComputeParticlesTest: Update shaders

This commit is contained in:
SirLynix 2023-07-21 08:58:50 +02:00 committed by Jérôme Leclercq
parent d94d5415a3
commit c30b498216
2 changed files with 7 additions and 4 deletions

View File

@ -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);
}
}

View File

@ -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;
}
}