2024-04-08 04:22:22 +00:00
|
|
|
#version 130
|
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;
|
|
|
|
uniform vec2 lightMapSize;
|
|
|
|
uniform vec2 lightMapScale;
|
|
|
|
uniform vec2 lightMapOffset;
|
|
|
|
|
2024-04-08 04:22:22 +00:00
|
|
|
in vec2 vertexPosition;
|
|
|
|
in vec2 vertexTextureCoordinate;
|
|
|
|
in vec4 vertexColor;
|
|
|
|
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;
|
|
|
|
out float fragmentLightMapMultiplier;
|
|
|
|
out vec2 fragmentLightMapCoordinate;
|
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
|
|
|
|
|
|
|
if (((vertexData >> 3) & 0x1) == 1)
|
|
|
|
screenPosition.x = round(screenPosition.x);
|
|
|
|
if (((vertexData >> 4) & 0x1) == 1)
|
|
|
|
screenPosition.y = round(screenPosition.y);
|
|
|
|
|
|
|
|
fragmentLightMapMultiplier = float((vertexData >> 2) & 0x1);
|
|
|
|
int vertexTextureIndex = vertexData & 0x3;
|
2023-06-23 13:01:25 +00:00
|
|
|
fragmentLightMapCoordinate = (screenPosition / lightMapScale) - lightMapOffset * lightMapSize / screenSize;
|
2024-04-08 04:22:22 +00:00
|
|
|
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;
|
|
|
|
gl_Position = vec4(screenPosition / screenSize * 2.0 - 1.0, 0.0, 1.0);
|
|
|
|
}
|