| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- #version 430 core
- struct particle_t {
- vec2 pos;
- vec2 dir;
- };
- struct cell_t {
- float pheromone;
- float result;
- int population;
- };
- layout(binding = 0, rgba8) writeonly uniform image2D canvas;
- uniform uint map_width;
- uniform uint map_height;
- uniform float display_population_value;
- uniform float display_pheromone_value;
- layout(std430, binding = 1) coherent buffer particles_buffer
- {
- particle_t particles[];
- };
- layout(std430, binding = 2) coherent buffer map_buffer
- {
- cell_t map[];
- };
- layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
- void main(){
- uint x = gl_GlobalInvocationID.x;
- uint y = gl_GlobalInvocationID.y;
- if(x >= map_width || y >= map_height){
- return;
- }
- uint cell_id = y * map_width + x;
- cell_t cell = map[cell_id];
- float pop_value = cell.population / display_population_value / 2.5;
- float phe_value = cell.pheromone / display_pheromone_value;
- imageStore(canvas, ivec2(gl_GlobalInvocationID.xy),
- vec4(phe_value * pop_value,
- pop_value,
- phe_value,
- 1));
- }
|