#version 330 core layout (location = 0) in vec3 aPos; layout (location = 1) in vec2 aTexCoord; layout (location = 2) in int tileIndex; layout (location = 3) in mat4 aModel; uniform int tilesPerRow; uniform mat4 proj; uniform mat4 view; out vec2 texCoord; void main() { float tileSize = 1.0 / float(tilesPerRow); gl_Position = proj * view * aModel * vec4(aPos, 1.0); int row = tileIndex / tilesPerRow; int col = tileIndex % tilesPerRow; float offsetX = float(col) * tileSize; float offsetY = float(row) * tileSize; texCoord.x = (aTexCoord.x + col) * tileSize; texCoord.y = (aTexCoord.y + row) * tileSize; }