-
-
Save tomaka/eea3143804e7f11b8c67b762de41ff34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#version 450 | |
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; | |
struct Neighbour { | |
int id; | |
float dist; | |
}; | |
struct TileDynamic { | |
float tax_money_in_delivery; | |
float population; | |
float resources_stock[32]; | |
float resources_flux[32]; | |
}; | |
struct TileRead { | |
vec2 position; | |
Neighbour neighbours[8]; | |
int dropout_direction; | |
int controller_id; | |
float local_science_production; | |
int agriculture_request; | |
uint climate; | |
float terrain_penalty; | |
float infrastructure_level; | |
float resources_availability[32]; | |
}; | |
struct Nation { | |
vec3 rgb_color; | |
}; | |
layout(set = 0, binding = 0) readonly buffer TilesRead { | |
TileRead tiles[]; | |
}; | |
layout(set = 0, binding = 1) readonly buffer TilesIn { | |
TileDynamic tiles_in[]; | |
}; | |
layout(set = 0, binding = 2) buffer TilesOut { | |
TileDynamic tiles_out[]; | |
}; | |
layout(set = 0, binding = 3) buffer NationsRead { | |
Nation nations[]; | |
}; | |
void calculate_tax_money(uint tile_id) { | |
float sum = 0.0; | |
sum += tiles_in[tile_id].population * 0.003425; | |
for (int i = 0; i < 8; ++i) { | |
int neighbour = tiles[tile_id].neighbours[i].id; | |
if (neighbour == -1) continue; | |
int dropout_direction = tiles[neighbour].dropout_direction; | |
if ((i == 0 && dropout_direction == 2) || (i == 1 && dropout_direction == 3) || | |
(i == 2 && dropout_direction == 0) || (i == 3 && dropout_direction == 1) || | |
(i == 4 && dropout_direction == 6) || (i == 5 && dropout_direction == 7) || | |
(i == 6 && dropout_direction == 4) || (i == 7 && dropout_direction == 5)) | |
{ | |
sum += tiles_in[neighbour].tax_money_in_delivery; | |
} | |
} | |
tiles_out[tile_id].tax_money_in_delivery = sum; | |
} | |
void main() { | |
uint tile_id = gl_NumWorkGroups.x * gl_WorkGroupID.y + gl_WorkGroupID.x; | |
if (tile_id >= tiles_out.length()) { return; } | |
calculate_tax_money(tile_id); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment