vec3 vpFog(vec3 vColor){
	vec3 viewDir = GetWorldDirection();

	float rainFactor = rain_time();

	float h = clamp(viewDir.y * 0.5 + 0.5, 0.0, 1.0);

	float depth = texture2D(depthtex0, vTexcoord).r;

	vec3 worldPos = GetWorldPos(vTexcoord, depth);

	float fogDistance = length(worldPos - cameraPosition);
	
	float fog = smoothstep(near, far, fogDistance);

	vec4 phases = GetAtmospherePhases();
	vec3 fogColor = vpRenderSky(viewDir);

	vColor = mix(vColor, fogColor, fog);

	return vColor;
}

vec3 vpNetherFog(vec3 vColor){
	vec3 viewDir = GetWorldDirection();

	float h = clamp(viewDir.y * 0.5 + 0.5, 0.0, 1.0);

	float depth = texture2D(depthtex0, vTexcoord).r;

	vec3 worldPos = GetWorldPos(vTexcoord, depth);

	float fogDistance = length(worldPos - cameraPosition);
	
	float fog = smoothstep(near, far, fogDistance);

	vec4 phases = GetAtmospherePhases();
	vec3 fogColor =mix(vec3(1.0, 0.2, 0.0),vec3(0.6275, 0.3569, 0.0471), viewDir.y * 1.5);

	vColor = mix(vColor, fogColor, fog);

	return vColor;
}

vec3 vpEndFog(vec3 vColor){
	vec3 viewDir = GetWorldDirection();

	float h = clamp(viewDir.y * 0.5 + 0.5, 0.0, 1.0);

	float depth = texture2D(depthtex0, vTexcoord).r;

	vec3 worldPos = GetWorldPos(vTexcoord, depth);

	float fogDistance = length(worldPos - cameraPosition);
	
	float fog = smoothstep(near, far, fogDistance);

	vec4 phases = GetAtmospherePhases();
	vec3 fogColor =mix(vec3(0.549, 0.0, 1.0),vec3(0.2118, 0.0, 0.149), viewDir.y * 1.5);

	vColor = mix(vColor, fogColor, fog);

	return vColor;
}
