#version 450 core

// Spline Glow Fragment Shader
// Teal glow effect with sub-pixel crispness

in vec3 vGlow;
in float vIntensity;

// Screen-space position (for width attenuation)
layout(location = 0) out vec4 FragColor;

void main() {
    // Calculate attenuation based on line length (distance from center)
    float dist = abs(gl_FragCoord.x - gl_FragCoord.y) * 0.5;  // Approximate distance
    float attenuation = exp(-dist * 0.3);  // -0.3 is the decay factor

    // Base teal color (0.0, 0.9, 1.0)
    vec3 teal = vec3(0.0, 0.9, 1.0);

    // Apply glow intensity and attenuation
    vec3 finalColor = teal * vIntensity * attenuation;

    // Add slight transparency (0.3-0.8)
    float alpha = clamp(vIntensity * 0.8 + 0.2, 0.3, 1.0);

    // Add soft edge (Gaussian-like)
    float softEdge = 1.0 - smoothstep(0.3, 0.7, attenuation);
    alpha *= (0.5 + softEdge * 0.5);

    FragColor = vec4(finalColor, alpha);
}