#version 450
#include "common.glsl"

vec2 screenVertices[] = {
    vec2(-1.0, -1.0),
    vec2(1.0, -1.0),
    vec2(-1.0, 1.0),

    vec2(1.0, -1.0),
    vec2(-1.0, 1.0),
    vec2(1.0, 1.0),
};

layout(
    set = 0,
    binding = GLSL_SKYBOX_DATA_INDEX
) uniform CombineData {
    mat4 proj;
    mat4 view;
    mat4 model;
    vec3 color;
    vec2 screenSize;
    float playerZ;
    float farZ;
    float verticalViewDistance;
    int debugMode;
    int fxaaEnabled;
    int godRaySamples;
} uCombineData;

layout(location = 0) out vec2 passFar;
layout(location = 1) out vec2 passScreenSize;
layout(location = 2) out int passDebugMode;
layout(location = 3) out int passFxaaEnabled;
layout(location = 4) out vec2 passSunPos;
layout(location = 5) out int passGodRaySamples;
layout(location = 6) out vec3 passSkyColor;

void main()
{
    gl_Position = vec4(screenVertices[gl_VertexIndex], 0.0, 1.0);

    passFar = vec2(uCombineData.farZ, uCombineData.verticalViewDistance);
    passScreenSize = uCombineData.screenSize;
    passDebugMode = uCombineData.debugMode;
    passFxaaEnabled = uCombineData.fxaaEnabled;
    passSunPos = (uCombineData.proj * uCombineData.view * uCombineData.model * vec4(0.0, 1.0, 0.0, 0.0)).xy;
    passSunPos = (passSunPos + 1.0) * 0.5;
    passGodRaySamples = uCombineData.godRaySamples;
    passSkyColor = uCombineData.color;
}