#version 330 core

// Soft additive particle: colour interpolates over life, faded by the sprite texture and life.
in vec2 ex_Uv;
in float ex_LifeFrac;

out vec4 fragColor;

uniform sampler2D uTexture;
uniform vec4 uColorStart; // colour when just born (lifeFrac ~ 1)
uniform vec4 uColorEnd;   // colour when about to die (lifeFrac ~ 0)

void main() {
	vec4 tex = texture(uTexture, ex_Uv);
	vec4 col = mix(uColorEnd, uColorStart, ex_LifeFrac);
	float a = col.a * tex.a * ex_LifeFrac;
	fragColor = vec4(col.rgb, a);
}
