#version 450
layout(location=0) in vec2 v_uv;
layout(location=0) out vec4 out_color;
layout(set=2, binding=0) uniform sampler2D scene;
layout(set=3, binding=0) uniform PostFXUniforms {
    float vignette_strength;
    float chroma_strength;
    float scanline_strength;
    float screen_height;
} u;
void main() {
    float ca = u.chroma_strength * 0.005;
    vec4 color;
    color.r = texture(scene, v_uv + vec2( ca, 0.0)).r;
    color.g = texture(scene, v_uv).g;
    color.b = texture(scene, v_uv - vec2( ca, 0.0)).b;
    color.a = texture(scene, v_uv).a;
    float scan = 0.85 + 0.15 * sin(v_uv.y * 3.14159265 * u.screen_height);
    color.rgb *= mix(1.0, scan, u.scanline_strength);
    vec2 d = v_uv - vec2(0.5, 0.5);
    float vignette = 1.0 - dot(d, d) * u.vignette_strength;
    color.rgb *= clamp(vignette, 0.0, 1.0);
    out_color = color;
}
