#version 410 in vec2 xy; out vec3 xyzV; uniform mat4 cameraMatrix; uniform float eyePos; void main(void) { // screen location is rectangle set at the far Z. vec4 pos = vec4(xy, 0.99999, 1.0); gl_Position = pos; // fragment shader renders the infinite sphere with this xyzV = inverse(mat3(cameraMatrix)) * vec3(xy, -eyePos); }