#version 450

layout(location = 0) out vec3 oFragTexCoord;

layout(push_constant) uniform constants {
    mat4 inverseViewProjection;
};

vec4 quad[4] = vec4[](
    vec4(-1.0f,  1.0f, 1.0f, 1.0f),
    vec4( 1.0f,  1.0f, 1.0f, 1.0f),
    vec4(-1.0f, -1.0f, 1.0f, 1.0f),
    vec4( 1.0f, -1.0f, 1.0f, 1.0f)
);

int indices[6] = int[](
    0, 1, 2, 1, 2, 3
);

void main() {
    vec4 vertex = quad[indices[gl_VertexIndex]]; // in NDC
    oFragTexCoord = (inverseViewProjection * vertex).xyz; // convert to World Space
    gl_Position = vertex;
}