#import bevy_core_pipeline::fullscreen_vertex_shader::FullscreenVertexOutput

struct ChromaticSettings {
    intensity: f32,
    radius: f32,
}

@group(0) @binding(2) var<uniform> settings: ChromaticSettings;
@group(0) @binding(0) var screen_texture: texture_2d<f32>;
@group(0) @binding(1) var texture_sampler: sampler;

@fragment
fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4<f32> {
    let offset = settings.intensity * 0.004;
    let r = textureSample(screen_texture, texture_sampler, in.uv + vec2<f32>(offset, 0.0)).r;
    let g = textureSample(screen_texture, texture_sampler, in.uv).g;
    let b = textureSample(screen_texture, texture_sampler, in.uv - vec2<f32>(offset, 0.0)).b;
    let a = textureSample(screen_texture, texture_sampler, in.uv).a;
    return vec4<f32>(r, g, b, a);
}
