2024-07-06 21:32:06 +00:00
|
|
|
#version 140
|
2023-06-23 13:01:25 +00:00
|
|
|
|
|
|
|
uniform vec2 textureSize0;
|
|
|
|
uniform vec2 textureSize1;
|
|
|
|
uniform vec2 textureSize2;
|
|
|
|
uniform vec2 textureSize3;
|
|
|
|
uniform vec2 screenSize;
|
|
|
|
uniform mat3 vertexTransform;
|
|
|
|
|
2024-04-08 04:22:22 +00:00
|
|
|
in vec2 vertexPosition;
|
|
|
|
in vec4 vertexColor;
|
|
|
|
in vec2 vertexTextureCoordinate;
|
|
|
|
in int vertexData;
|
2023-06-23 13:01:25 +00:00
|
|
|
|
2024-04-08 04:22:22 +00:00
|
|
|
out vec2 fragmentTextureCoordinate;
|
|
|
|
flat out int fragmentTextureIndex;
|
|
|
|
out vec4 fragmentColor;
|
2023-06-23 13:01:25 +00:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
vec2 screenPosition = (vertexTransform * vec3(vertexPosition, 1.0)).xy;
|
2024-04-08 04:22:22 +00:00
|
|
|
gl_Position = vec4(screenPosition / screenSize * 2.0 - 1.0, 0.0, 1.0);
|
2024-04-15 07:46:44 +00:00
|
|
|
|
2024-04-08 04:22:22 +00:00
|
|
|
int vertexTextureIndex = vertexData & 0x3;
|
|
|
|
if (vertexTextureIndex == 3)
|
2023-06-23 13:01:25 +00:00
|
|
|
fragmentTextureCoordinate = vertexTextureCoordinate / textureSize3;
|
2024-04-08 04:22:22 +00:00
|
|
|
else if (vertexTextureIndex == 2)
|
2023-06-23 13:01:25 +00:00
|
|
|
fragmentTextureCoordinate = vertexTextureCoordinate / textureSize2;
|
2024-04-08 04:22:22 +00:00
|
|
|
else if (vertexTextureIndex == 1)
|
2023-06-23 13:01:25 +00:00
|
|
|
fragmentTextureCoordinate = vertexTextureCoordinate / textureSize1;
|
2024-04-08 04:22:22 +00:00
|
|
|
else
|
2023-06-23 13:01:25 +00:00
|
|
|
fragmentTextureCoordinate = vertexTextureCoordinate / textureSize0;
|
2024-04-08 04:22:22 +00:00
|
|
|
|
2023-06-23 13:01:25 +00:00
|
|
|
fragmentTextureIndex = vertexTextureIndex;
|
|
|
|
fragmentColor = vertexColor;
|
|
|
|
}
|