#version 150

#moj_import <fog.glsl>
#moj_import <utils.glsl>

uniform sampler2D Sampler0;

uniform vec4 ColorModulator;
uniform float FogStart;
uniform float FogEnd;

in float vertexDistance;
in vec4 vertexColor;
in vec4 overlayColor;
in vec2 texCoord0;
in vec4 normal;
in vec4 glpos;

out vec4 fragColor;

void main() {
  discardControlGLPos(gl_FragCoord.xy, glpos);
  vec4 color = texture(Sampler0, texCoord0);
  if (color.a < 0.1) {
    discard;
  }
  color *= vertexColor * ColorModulator;
  color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a);
  fragColor = color * linear_fog_fade(vertexDistance, FogStart, FogEnd);
}
