#version 420 in layout(location=0) vec3 position; /* vertex position in model coordinates */ in layout(location=1) vec2 offset; /* xy coordinates offset for atlases */ in layout(location=2) mat4 M_MVP; out vec2 Fragment_UV; /* UV coordinates for the fragment */ uniform float number_of_rows; /* For texture atlases */ void main() { gl_Position = M_MVP * vec4(position, 1.0); Fragment_UV = position.xy + vec2(0.5, 0.5); Fragment_UV.y = 1.0 - Fragment_UV.y; Fragment_UV = (Fragment_UV / number_of_rows ) + offset; }