vec3 get_lava_fog(float dist, vec3 color) {

    // Improved cinematic fog colors
    const vec3 LAVA_FOG_COLOR = to_linear(vec3(0.95, 0.42, 0.12));
    const vec3 PSNOW_FOG_COLOR = to_linear(vec3(0.72, 0.82, 0.95));

    if (isEyeInWater == 1) {

        vec3 UnderwaterCol = to_linear(vec3(
            f_WATER_RED,
            f_WATER_GREEN,
            f_WATER_BLUE
        )) * (SKY_GROUND + SKY_TOP);

        UnderwaterCol = mix_preserve_c1lum(
            UnderwaterCol,
            fogColor,
            f_BIOME_WATER_CONTRIBUTION
        );

        // Softer underwater blending
        dist = clamp(dist / 72.0, 0.0, 1.0);

        // Slight blue cinematic tint
        UnderwaterCol += vec3(0.03, 0.06, 0.12);

        return mix(color, UnderwaterCol, dist);
    }

    else if (isEyeInWater == 2) {

        // Better lava atmosphere
        dist = clamp(dist / 2.5, 0.0, 1.0);

        vec3 LavaGlow = LAVA_FOG_COLOR * 1.25;

        return mix(color, LavaGlow, dist);
    }

    else if (isEyeInWater == 3) {

        // Powder snow atmosphere
        dist = clamp(dist / 2.5, 0.0, 1.0);

        return mix(color, PSNOW_FOG_COLOR, dist);
    }

    return color;
}

vec3 get_border_fog(float strength, vec3 color, vec3 SkyColor) {

    strength *= strength;

    #ifndef DIMENSION_NETHER
    strength *= strength;
    strength *= strength;
    #endif

    // Softer cinematic horizon fog
    strength = exp(-2.4 * strength);

    return mix(SkyColor, color, strength);
}

vec3 get_blindness_fog(float Dist, vec3 Color) {

    Dist = clamp(
        1.0 - exp(-2.6 * Dist / 10.0),
        0.0,
        1.0
    ) * max(darknessFactor, blindness);

    return Color * (1.0 - Dist);
}

vec3 get_atm_fog(float Dist, vec3 Color, vec3 WorldPos, vec3 FogColor) {

    // Smoother atmospheric fog curve
    Dist = min(Dist / 220.0, 1.0);
    Dist = 1.0 - exp(-2.2 * Dist);

    // Day/night visibility
    float Visibility =
        sunriseStrength * 0.9 +
        sunsetStrength * 0.45 +
        nightStrength * 0.55;

    Visibility = max(Visibility, rainStrength);
    
    // Cinematic rainy atmosphere
FogColor *= mix(
    vec3(1.0),
    vec3(0.72, 0.78, 0.9),
    rainStrength * 0.45
);

Visibility += rainStrength * 0.25;

    Visibility *= isOutdoorsSmooth;

    // Slightly stronger cinematic fog
    Visibility *= ATM_FOG_STRENGTH * 1.15;

    // Softer noise breakup
    Visibility *= 1.0 - fbm_fast(WorldPos.xz * 0.45, 1);

    // Better vertical fog layering
    float HeightFalloff =
        WorldPos.y >= 