#version 330 core

in vec2 positions;
in vec2 texCoords;

out vec4 color;

uniform vec2 lightPosition;
uniform float torchStrength;
uniform sampler2D sampler;

void main() {
    float xDist = positions.x - lightPosition.x;
    float yDist = positions.y - lightPosition.y;
    float alpha = texture(sampler, texCoords).w;
    float brightness = alpha * (torchStrength * 1.2 - ((xDist * xDist + yDist * yDist) / 4000));
    color = vec4(1, 0.8, 0.5, max(brightness, 0) + 0.15 * alpha);
}