uniform sampler2D terrainY;
uniform vec2 playerPosition[512];

varying mat4 transformationMatrix;

varying out float result;

void main()
{
   vec2 pos = playerPosition[int(gl_FragCoord.x)];
   vec4 coord = transformationMatrix * vec4(pos.x, 0, pos.y, 1.0);
   vec2 fetchCoord = (coord / coord.w * 0.5 + vec4(0.5)).xy;
   result = texture2D(terrainY, fetchCoord).r;
}

