#ifndef fogHelper
#define fogHelper

// get the fog value to be passed to the pixel shader - xyz is the fog color, and w is the blend amount
float4 getFogValue(float3 vFogColor, float2 vFogParams, 
				   float3 vPos)
{
	// get the color
	//

	float4 vRet;
	vRet.xyz = vFogColor;

	vRet.w = (vPos.z - vFogParams.x) / (vFogParams.y);
	//vRet.w = (length(vPos.xyz) - vFogParams.x) / (vFogParams.y);
	vRet.w = saturate(vRet.w);

	return vRet;
}

float4 getFogValueWorldSpace(float3 vFogColor, float2 vFogParams,
							float3 vScreenPos, float3 vPosWorld
#ifdef OCEANDEPTH
							,
							float3 oceanDepthRange,
 							float4 oceanDepthColor
#endif
							)
{
	// get the color
	//

	float4 vRet;
	vRet.xyz = vFogColor;

	vRet.w = (vScreenPos.z - vFogParams.x) / (vFogParams.y);
	vRet.w = saturate(vRet.w);
	
#ifdef OCEANDEPTH
	if ( vPosWorld.y < -oceanDepthRange.x )
	{
		float oceanDepth = vPosWorld.y;
		oceanDepth = -(oceanDepth + oceanDepthRange.x);
		oceanDepth /= oceanDepthRange.y;
		vRet.xyz = oceanDepthColor;
		vRet.w = saturate(oceanDepth);
	}
#endif 

	return vRet;

}

float4 getFogColor(float4 vLitColor, float4 vFogValue)
{
	float4 vRet = vLitColor;
	vRet.xyz = lerp(vLitColor.xyz, vFogValue.xyz, vFogValue.w);

	return vRet;
}

#endif
