#version 450

// Inputs from vertex shader
layout(location = 0) in vec2 in_texCoord;
layout(location = 1) in vec4 in_color;
layout(location = 2) in float in_life;

// Output color
layout(location = 0) out vec4 out_color;


void main() {
    if (in_life <= 0.0) {
        discard;
    }
    
    // Create circular particle shape using distance from center
    vec2 center = vec2(0.5, 0.5);
    float dist = distance(in_texCoord, center);
    
    // Create soft circular falloff
    float radius = 0.5;
    float softness = 0.1;
    float alpha = 1.0 - smoothstep(radius - softness, radius, dist);
    
    // Apply particle color and computed alpha
    vec4 particleColor = in_color;
    particleColor.a *= alpha;
    
    // Add some variation based on texture coordinates for more realistic smoke
    float noise = sin(in_texCoord.x * 10.0) * sin(in_texCoord.y * 10.0) * 0.1 + 0.9;
    particleColor.rgb *= noise;
    
    out_color = particleColor;
    
    if (out_color.a < 0.01) {
        discard;
    }
} 