	vec3 getWaterDepthFog(vec3 color, vec3 fragpos, vec3 fragpos2, float iswater){

        float DepthFogDensity = 10.0;

		float depth = distance(fragpos, fragpos2); // Depth of the water volume
			  depth *= mix(iswater, 1, isEyeInWater);
			  depth = clamp(depth, 0.0, 20.0); //Fix sky clipping

		/*
		float sunAngleCosine = 1.0 - clamp(dot(normalize(fragpos.rgb), normalize(shadowLightPosition)), 0.0, 1.0);
			  sunAngleCosine = sunAngleCosine*sunAngleCosine*(3.0 - 2.0 * sunAngleCosine);
			  sunAngleCosine = 1.0 / sunAngleCosine - 1.0;
			  sunAngleCosine /= sunAngleCosine * 0.02 + 1.0;
		*/

		float depthFog = 1.0 - clamp(exp2(-depth * DepthFogDensity * 0.04), 0.0, 1.0); // Beer's Law
		float depthFog2 = 1.0 - clamp(exp2(-depth * DepthFogDensity * 0.05), 0.0, 1.0); // Beer's Law

        vec3 waterColor = vec3(0.01, 0.36, 0.51)*0.3;
 			 waterColor = pow(waterColor, vec3(2.2));
        vec3 shallowwaterColor = vec3(0.0, 0.51, 0.51)*0.5;
 			 shallowwaterColor = pow(shallowwaterColor, vec3(2.2));
			 waterColor = mix(shallowwaterColor, waterColor, depthFog2);

	    float fogStr = 0.5 * (time[0]) +  
					   1.0 * (time[1]) +
					   1.0 * (time[2]) + 
					   1.0 * (time[3]) + 
					   0.5 * (time[4]) + 
					   0.16 * (time[5]);

		float undergroundFix = clamp(mix(max(lmcoord.t-2.0/16.0,0.0)*1.14285714286,1.0,clamp((eyeBrightnessSmooth.y/255.0-2.0/16.)*4.0,0.0,1.0)), 0.0, 1.0);		   
		fogStr *= undergroundFix;
				   
		return mix(color, waterColor*fogStr, depthFog);
	}
