#version 150

vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) {
    if (vertexDistance <= fogStart) {
        return inColor;
    }
    float fogValue = smoothstep(fogStart, fogEnd, vertexDistance);
    return vec4(mix(inColor.rgb, fogColor.rgb, fogValue), inColor.a);
}

float linear_fog_fade(float vertexDistance, float fogStart, float fogEnd) {
    if (vertexDistance <= fogStart) return 1.0;
    if (vertexDistance >= fogEnd) return 0.0;
    return smoothstep(fogEnd, fogStart, vertexDistance);
}

float fog_distance(mat4 modelViewMat, vec3 pos, int shape) {
    return length((modelViewMat * vec4(pos, 1.0)).xyz);
}

float fog_distance(vec3 pos, int shape) {
    return length(pos);
}
