mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-28 09:09:19 +01:00
Add all standard library functions to the IR
This commit is contained in:
1 parent
66d994566c
commit
b35e901249
12 files changed
+744
-462
No files matched your search
@@ -23,10 +23,10 @@ import "GLSL.std.450" as std;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main() -> void {
|
||||
var angle : f32 = -std::atan2(a_particleVel.x, a_particleVel.y);
|
||||
var angle : f32 = -atan2(a_particleVel.x, a_particleVel.y);
|
||||
var pos : vec2<f32> = vec2<f32>(
|
||||
(a_pos.x * std::cos(angle)) - (a_pos.y * std::sin(angle)),
|
||||
(a_pos.x * std::sin(angle)) + (a_pos.y * std::cos(angle)));
|
||||
(a_pos.x * cos(angle)) - (a_pos.y * sin(angle)),
|
||||
(a_pos.x * sin(angle)) + (a_pos.y * cos(angle)));
|
||||
gl_Position = vec4<f32>(pos + a_particlePos, 0.0, 1.0);
|
||||
return;
|
||||
}
|
||||
@@ -97,14 +97,14 @@ fn main() -> void {
|
||||
pos = particlesA.particles[i].pos.xy;
|
||||
vel = particlesA.particles[i].vel.xy;
|
||||
|
||||
if (std::distance(pos, vPos) < params.rule1Distance) {
|
||||
if (distance(pos, vPos) < params.rule1Distance) {
|
||||
cMass = cMass + pos;
|
||||
cMassCount = cMassCount + 1;
|
||||
}
|
||||
if (std::distance(pos, vPos) < params.rule2Distance) {
|
||||
if (distance(pos, vPos) < params.rule2Distance) {
|
||||
colVel = colVel - (pos - vPos);
|
||||
}
|
||||
if (std::distance(pos, vPos) < params.rule3Distance) {
|
||||
if (distance(pos, vPos) < params.rule3Distance) {
|
||||
cVel = cVel + vel;
|
||||
cVelCount = cVelCount + 1;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ fn main() -> void {
|
||||
(cVel * params.rule3Scale);
|
||||
|
||||
# clamp velocity for a more pleasing simulation
|
||||
vVel = std::normalize(vVel) * std::fclamp(std::length(vVel), 0.0, 0.1);
|
||||
vVel = normalize(vVel) * clamp(length(vVel), 0.0, 0.1);
|
||||
|
||||
# kinematic update
|
||||
vPos = vPos + (vVel * params.deltaT);
|
||||
|
||||
Reference in new issue
Block a user