2021-01-04 23:37:44 +01:00
|
|
|
#version 330 core
|
|
|
|
#define PI 3.1415926538
|
|
|
|
layout (location = 0) in vec3 aPos;
|
|
|
|
layout (location = 1) in vec3 aNormal;
|
|
|
|
layout (location = 2) in vec2 aTexCoords;
|
|
|
|
|
|
|
|
layout (location = 3) in vec3 instancePos;
|
|
|
|
layout (location = 4) in vec2 light;
|
|
|
|
layout (location = 5) in float speed;
|
|
|
|
layout (location = 6) in float rotationOffset;
|
|
|
|
layout (location = 7) in vec3 rotationAxis;
|
|
|
|
|
|
|
|
out vec2 TexCoords;
|
|
|
|
out vec2 Light;
|
|
|
|
|
|
|
|
uniform float time;
|
|
|
|
uniform int ticks;
|
|
|
|
uniform mat4 projection;
|
|
|
|
uniform mat4 view;
|
|
|
|
|
2021-01-05 05:10:38 +01:00
|
|
|
mat4 kineticRotation()
|
2021-01-04 23:37:44 +01:00
|
|
|
{
|
2021-01-05 05:10:38 +01:00
|
|
|
float degrees = rotationOffset + time * speed * -3./10.;
|
|
|
|
float angle = fract(degrees / 360.) * PI * 2.;
|
|
|
|
|
|
|
|
vec3 axis = normalize(rotationAxis);
|
2021-01-04 23:37:44 +01:00
|
|
|
float s = sin(angle);
|
|
|
|
float c = cos(angle);
|
|
|
|
float oc = 1.0 - c;
|
|
|
|
|
|
|
|
return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.,
|
|
|
|
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.,
|
|
|
|
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.,
|
|
|
|
0., 0., 0., 1.);
|
|
|
|
}
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2021-01-05 05:10:38 +01:00
|
|
|
vec4 renderPos = kineticRotation() * vec4(aPos - vec3(0.5), 1);
|
2021-01-04 23:37:44 +01:00
|
|
|
|
2021-01-05 05:10:38 +01:00
|
|
|
renderPos += vec4(instancePos + vec3(0.5), 0);
|
2021-01-04 23:37:44 +01:00
|
|
|
|
2021-01-05 05:10:38 +01:00
|
|
|
TexCoords = aTexCoords;
|
2021-01-04 23:37:44 +01:00
|
|
|
|
|
|
|
gl_Position = projection * view * renderPos;
|
|
|
|
Light = light;
|
|
|
|
}
|