Generate agents with compute shader

This commit is contained in:
Andras Schmelczer 2023-05-20 13:28:15 +01:00
commit 6b17a8e023
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
15 changed files with 206 additions and 154 deletions

View file

@ -0,0 +1,26 @@
@compute @workgroup_size(64)
fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
let id = global_id.x;
if (id >= arrayLength(&agents)) {
return;
}
let position = vec2(
hash(id) * state.size.x,
hash(id * id) * state.size.y,
);
let center = state.size / 2.0;
let direction = position - center;
let angle = atan2(direction.y, direction.x);
agents[id] = Agent(
position,
angle,
0,
1000000,
0
);
}