ComputeParticlesTest: Update shaders
This commit is contained in:
parent
d94d5415a3
commit
c30b498216
|
|
@ -22,9 +22,9 @@ fn main(input: Input)
|
||||||
|
|
||||||
let outputColor = vec4[f32]
|
let outputColor = vec4[f32]
|
||||||
(
|
(
|
||||||
(pow(1.0 - length(uv), 20.0)).xxx,
|
(pow(1.0 - length(uv), 10.0)).xxx,
|
||||||
1.0
|
1.0
|
||||||
);
|
);
|
||||||
|
|
||||||
output_tex.Write(indices, outputColor);
|
output_tex.Write(indices, outputColor);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,12 @@ fn main(input: Input)
|
||||||
if (index >= data.particle_count)
|
if (index >= data.particle_count)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
let damping = pow(0.5, sceneData.deltaTime);
|
||||||
|
|
||||||
let attract_pos = sceneData.mousePos;
|
let attract_pos = sceneData.mousePos;
|
||||||
let dist = length(attract_pos - data.particles[index].position);
|
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;
|
data.particles[index].position += data.particles[index].velocity * sceneData.deltaTime;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue