2024-10-30 21:24:03 -06:00
|
|
|
#version 450
|
|
|
|
#extension GL_EXT_buffer_reference : require
|
|
|
|
|
|
|
|
#include "hex_common.glsl"
|
|
|
|
|
|
|
|
#define PI 3.1415926535897932384626433832795
|
2024-11-01 15:46:27 -06:00
|
|
|
const float w = 0.5;
|
|
|
|
const float x = 0.75;
|
|
|
|
const float z = sqrt(3.0)/4.0;
|
2024-10-30 21:24:03 -06:00
|
|
|
|
2024-11-01 15:46:27 -06:00
|
|
|
const vec4 vertices[] = {
|
2024-11-01 12:55:56 -06:00
|
|
|
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),
|
2024-10-30 21:24:03 -06:00
|
|
|
};
|
|
|
|
|
2024-11-01 15:46:27 -06:00
|
|
|
const uint indices[] = {
|
2024-11-01 12:55:56 -06:00
|
|
|
0, 2, 1,
|
|
|
|
0, 3, 2,
|
|
|
|
0, 4, 3,
|
|
|
|
0, 5, 4,
|
|
|
|
0, 6, 5,
|
|
|
|
0, 1, 6,
|
2024-10-30 21:24:03 -06:00
|
|
|
};
|
|
|
|
|
2024-11-01 15:46:27 -06:00
|
|
|
const vec4 starts[] = {
|
|
|
|
vec4( 0, 0, 2*z, 0),
|
|
|
|
vec4(-x, 0, z, 0),
|
|
|
|
vec4(-x, 0, -z, 0),
|
|
|
|
vec4( 0, 0, -2*z, 0),
|
|
|
|
vec4( x, 0, -z, 0),
|
|
|
|
vec4( x, 0, z, 0),
|
|
|
|
};
|
|
|
|
|
|
|
|
const vec4 direction[] = {
|
|
|
|
vec4(-x, 0, -z, 0),
|
|
|
|
vec4( 0, 0, -2*z, 0),
|
|
|
|
vec4( x, 0, -z, 0),
|
|
|
|
vec4( x, 0, z, 0),
|
|
|
|
vec4( 0, 0, 2*z, 0),
|
|
|
|
vec4(-x, 0, z, 0),
|
|
|
|
};
|
|
|
|
|
2024-10-30 21:24:03 -06:00
|
|
|
void main() {
|
2024-11-01 15:46:27 -06:00
|
|
|
uint radius = 0;
|
|
|
|
uint ring = 0;
|
|
|
|
uint side = 0;
|
|
|
|
uint hex = 0;
|
|
|
|
if(gl_InstanceIndex != 0) {
|
|
|
|
radius = uint(floor(0.5 + sqrt(12*gl_InstanceIndex-3)/6));
|
|
|
|
ring = gl_InstanceIndex - (3*radius*radius - 3*radius + 1);
|
|
|
|
side = uint(floor(ring/(radius)));
|
|
|
|
hex = ring - (radius*side);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate position based on radius/ring/side/hex
|
|
|
|
vec4 position = vertices[indices[gl_VertexIndex]] + (starts[side]*radius) + (direction[side]*hex);
|
|
|
|
|
|
|
|
gl_Position = pc.context.proj * pc.context.view * position;
|
2024-10-30 21:24:03 -06:00
|
|
|
}
|