2016-08-03 07:59:29 +00:00
|
|
|
#version 120
|
|
|
|
|
2011-12-01 21:07:48 +00:00
|
|
|
//#define fog_FuncTION
|
2012-02-14 16:38:18 +00:00
|
|
|
//varying vec3 PointPos;
|
2011-11-27 23:59:33 +00:00
|
|
|
|
|
|
|
vec3 fog_Func(vec3 color, int type)
|
|
|
|
{
|
|
|
|
//if (type == 0){
|
|
|
|
const float LOG2 = 1.442695;
|
2012-02-14 16:38:18 +00:00
|
|
|
//float fogCoord =length(PointPos);
|
2012-03-15 19:06:45 +00:00
|
|
|
float fogCoord = gl_ProjectionMatrix[3].z/(gl_FragCoord.z * -2.0 + 1.0 - gl_ProjectionMatrix[2].z);
|
2011-11-27 23:59:33 +00:00
|
|
|
float fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2);
|
|
|
|
|
|
|
|
if(gl_Fog.density == 1.0)
|
|
|
|
fogFactor=1.0;
|
|
|
|
|
|
|
|
return mix(gl_Fog.color.rgb, color, fogFactor);
|
2016-08-03 07:59:29 +00:00
|
|
|
}
|