#version 330 core

uniform vec3 iResolution;
uniform float iTime;
uniform sampler2D iChannel0;
uniform sampler2D debugBuffer;

out vec4 FragColor;

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    // If debugBuffer is provided, prefer visualizing it
    vec3 col = vec3(0.0);
    vec2 uv = fragCoord.xy / iResolution.xy;
    if (texture(debugBuffer, uv).a > 0.0)
    {
        col = texture(debugBuffer, uv).xyz;
    }
    else
    {
        col = texture(iChannel0, uv).xyz;
    }
    col=smoothstep(0.01,0.9,col);
    col=pow(col, vec3(0.4545));
    fragColor = vec4(col, 1);
}

void main()
{
    mainImage(FragColor, gl_FragCoord.xy);
}
