24 lines
879 B
HLSL
24 lines
879 B
HLSL
#ifndef SKY_BOX_FOG
|
|
#define SKY_BOX_FOG
|
|
#if defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2)
|
|
#define APPLY_SKY_BOX_FOG(coord, col) col.rgb = ApplyFogColor(coord, col, unity_FogColor);
|
|
#else
|
|
#define APPLY_SKY_BOX_FOG(coord, col)
|
|
#endif
|
|
|
|
#if defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2)
|
|
uniform fixed _FogRatio;
|
|
fixed3 ApplyFogColor(fixed4 coord, fixed4 col, fixed4 fogCol)
|
|
{
|
|
#if (SHADER_TARGET < 30) || defined(SHADER_API_MOBILE)
|
|
// mobile or SM2.0: fog factor was already calculated per-vertex, so just lerp the color
|
|
fixed3 fog = lerp(fogCol.rgb, col.rgb, saturate(coord.x));
|
|
#else
|
|
// SM3.0 and PC/console: calculate fog factor and lerp fog color
|
|
UNITY_CALC_FOG_FACTOR(coord.x);
|
|
fixed3 fog = lerp(fogCol.rgb, col.rgb, saturate(unityFogFactor));
|
|
#endif
|
|
return lerp(col.rgb, fog, _FogRatio);
|
|
}
|
|
#endif
|
|
#endif |