Generate agents with compute shader
This commit is contained in:
parent
6351a67703
commit
6b17a8e023
15 changed files with 206 additions and 154 deletions
26
src/pipelines/agents/agent-generation/agent-generation.wgsl
Normal file
26
src/pipelines/agents/agent-generation/agent-generation.wgsl
Normal 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
|
||||
);
|
||||
}
|
||||
Loading…
Reference in a new issue