101 lines
2.0 KiB
GLSL
101 lines
2.0 KiB
GLSL
struct Hex {
|
|
float heights[6];
|
|
uint colors[7];
|
|
};
|
|
|
|
layout(std430, buffer_reference) readonly buffer Region {
|
|
int q;
|
|
int r;
|
|
int y;
|
|
uint map;
|
|
Hex hexes[];
|
|
};
|
|
|
|
layout(std430, buffer_reference) readonly buffer HexContext {
|
|
mat4 proj;
|
|
mat4 view;
|
|
vec4 click_start;
|
|
vec4 click_end;
|
|
vec4 hover_start;
|
|
vec4 hover_end;
|
|
uint current_map;
|
|
uint clicked_region;
|
|
uint clicked_hex;
|
|
uint clicked_vertex;
|
|
uint hovered_region;
|
|
uint hovered_hex;
|
|
uint hovered_vertex;
|
|
Region regions[];
|
|
};
|
|
|
|
layout(std430, push_constant) uniform PushConstant {
|
|
HexContext context;
|
|
float time;
|
|
} pc;
|
|
|
|
#define PI 3.1415926535897932384626433832795
|
|
const float w = 0.5;
|
|
const float x = 0.75;
|
|
const float z = sqrt(3.0)/2.0;
|
|
|
|
const int region_size = 10;
|
|
const float region_diameter = 2*region_size-1;
|
|
const float region_width = x*region_diameter;
|
|
const float region_height = z*region_diameter;
|
|
const int region_hex_count = 3*region_size*(region_size-1)+1;
|
|
|
|
const vec4 vertices[] = {
|
|
vec4(0, 0, 0, 1),
|
|
vec4(w*cos(0*PI/3), 0, w*sin(0*PI/3), 1),
|
|
vec4(w*cos(1*PI/3), 0, w*sin(1*PI/3), 1),
|
|
vec4(w*cos(2*PI/3), 0, w*sin(2*PI/3), 1),
|
|
vec4(w*cos(3*PI/3), 0, w*sin(3*PI/3), 1),
|
|
vec4(w*cos(4*PI/3), 0, w*sin(4*PI/3), 1),
|
|
vec4(w*cos(5*PI/3), 0, w*sin(5*PI/3), 1),
|
|
};
|
|
|
|
const uint indices[] = {
|
|
0, 2, 1,
|
|
0, 3, 2,
|
|
0, 4, 3,
|
|
0, 5, 4,
|
|
0, 6, 5,
|
|
0, 1, 6,
|
|
};
|
|
|
|
const vec4 starts[] = {
|
|
vec4( 0, 0, z, 0), // 0, -1
|
|
vec4(-x, 0, z/2, 0), // -1, 0
|
|
vec4(-x, 0, -z/2, 0), // -1, +1
|
|
vec4( 0, 0, -z, 0), // 0, +1
|
|
vec4( x, 0, -z/2, 0), // +1, 0
|
|
vec4( x, 0, z/2, 0), // +1, -1
|
|
};
|
|
|
|
const vec2 start_coords[] = {
|
|
vec2(0, -1),
|
|
vec2(-1, 0),
|
|
vec2(-1, 1),
|
|
vec2(0, 1),
|
|
vec2(1, 0),
|
|
vec2(1, -1),
|
|
};
|
|
|
|
const vec4 direction[] = {
|
|
vec4(-x, 0, -z/2, 0),
|
|
vec4( 0, 0, -z, 0),
|
|
vec4( x, 0, -z/2, 0),
|
|
vec4( x, 0, z/2, 0),
|
|
vec4( 0, 0, z, 0),
|
|
vec4(-x, 0, z/2, 0),
|
|
};
|
|
|
|
const vec2 direction_coords[] = {
|
|
vec2(-1, 1),
|
|
vec2(0, 1),
|
|
vec2(1, 0),
|
|
vec2(1, -1),
|
|
vec2(0, -1),
|
|
vec2(-1, 0),
|
|
};
|