2022-04-05 17:10:08 +00:00
|
|
|
#version 330 core
|
|
|
|
|
|
|
|
in vec2 position;
|
|
|
|
in vec2 uvCoords;
|
2022-04-11 23:08:57 +00:00
|
|
|
in int page;
|
2022-04-14 18:31:47 +00:00
|
|
|
in vec2 paintUVCoords;
|
2022-04-05 17:10:08 +00:00
|
|
|
|
2022-04-29 21:57:19 +00:00
|
|
|
uniform int paintType;
|
|
|
|
|
|
|
|
flat out float paintGradientAngleCos;
|
|
|
|
flat out float paintGradientAngleSin;
|
|
|
|
flat out float[2] paintGradientEndsUnrotated;
|
|
|
|
uniform vec2[2] paintGradientEnds;
|
|
|
|
|
2022-04-05 17:10:08 +00:00
|
|
|
out vec2 uvCoordinates;
|
2022-04-14 18:31:47 +00:00
|
|
|
out vec2 paintUVCoordinates;
|
2022-04-11 23:08:57 +00:00
|
|
|
flat out int atlasPage;
|
2022-04-05 17:10:08 +00:00
|
|
|
|
|
|
|
uniform mat4 projection;
|
2022-04-11 23:08:57 +00:00
|
|
|
uniform mat3 transformation;
|
2022-04-05 17:10:08 +00:00
|
|
|
|
|
|
|
void main(void)
|
|
|
|
{
|
2022-04-11 23:08:57 +00:00
|
|
|
atlasPage = page;
|
|
|
|
uvCoordinates = uvCoords;
|
2022-04-14 18:31:47 +00:00
|
|
|
paintUVCoordinates = paintUVCoords;
|
|
|
|
vec3 transformed = vec3((transformation * vec3(position, 1.0)).xy, 0.0);
|
2022-04-29 21:57:19 +00:00
|
|
|
|
|
|
|
if (paintType == 1)
|
|
|
|
{
|
|
|
|
float dy = paintGradientEnds[1].y - paintGradientEnds[0].y;
|
|
|
|
float dx = paintGradientEnds[1].x - paintGradientEnds[0].x;
|
|
|
|
float paintGradientAngle = atan(-dy, dx);
|
|
|
|
paintGradientAngleCos = cos(paintGradientAngle);
|
|
|
|
paintGradientAngleSin = sin(paintGradientAngle);
|
|
|
|
|
|
|
|
paintGradientEndsUnrotated[0] = paintGradientEnds[0].x * paintGradientAngleCos - paintGradientEnds[0].y * paintGradientAngleSin;
|
|
|
|
paintGradientEndsUnrotated[1] = paintGradientEnds[1].x * paintGradientAngleCos - paintGradientEnds[1].y * paintGradientAngleSin;
|
|
|
|
}
|
|
|
|
|
2022-04-11 23:08:57 +00:00
|
|
|
gl_Position = projection * vec4(transformed, 1.0);
|
2022-04-05 17:10:08 +00:00
|
|
|
}
|