
/*
====================================================================================================

    Copyright (C) 2025 Pyvtron Shaders - Pyvtron

    All Rights Reserved unless otherwise explicitly stated.

====================================================================================================
*/


#define UNDERWATER_FOG_STRENGTH 0.1 // [0.1 0.2 0.3 0.4 0.5]
#define UNDERWATER_FOG 1 // [0 1]

vec3 underwaterFog(vec3 fragpos, vec3 color, vec3 waterColor, vec3 lavaColor) {
    float distance = length(fragpos);
    
#if UNDERWATER_FOG
    float fogFactor = exp(-pow(distance * UNDERWATER_FOG_STRENGTH, 1.0));
#else
    float fogFactor = 1.0;
#endif

    float volumetricFog = 1.0 - exp(-distance * UNDERWATER_FOG_STRENGTH * 0.5); 

    if (isEyeInWater == 1) {
        return mix(color, waterColor, (1.0 - fogFactor) * volumetricFog);
    } else if (isEyeInWater == 2) {
        return mix(color, lavaColor, (1.0 - exp(-pow(distance, 1.0))) * volumetricFog);
    } else {
        return color;
    }
}
