map_reset.glsl 676 B

12345678910111213141516171819202122232425262728293031323334
  1. #version 430 core
  2. struct cell_t {
  3. float pheromone;
  4. float result;
  5. int population;
  6. };
  7. uniform uint map_width;
  8. uniform uint map_height;
  9. layout(std430, binding = 2) coherent buffer map_buffer
  10. {
  11. cell_t map[];
  12. };
  13. uint cell_id(uint x, uint y){
  14. return uint(mod(y, map_height) * map_width + mod(x, map_width));
  15. }
  16. layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
  17. void main(){
  18. uint x = gl_GlobalInvocationID.x;
  19. uint y = gl_GlobalInvocationID.y;
  20. if(x >= map_width || y >= map_height){
  21. return;
  22. }
  23. uint id = cell_id(x, y);
  24. map[id].pheromone = map[id].result;
  25. map[id].result = 0;
  26. map[id].population = 0;
  27. }