2013-05-11 19:09:03 -04:00
|
|
|
uniform vec4 fogColor;
|
|
|
|
uniform float fogFrom;
|
|
|
|
uniform float fogTo;
|
|
|
|
uniform int fog;
|
|
|
|
uniform sampler2D tex;
|
|
|
|
varying vec4 coord;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
vec4 color = texture2D(tex, gl_TexCoord[0].st);
|
|
|
|
vec4 solidColor = vec4(color.r, color.g, color.b, 1);
|
2013-06-18 10:35:29 -04:00
|
|
|
|
2013-05-11 19:09:03 -04:00
|
|
|
if (fog == 1)
|
|
|
|
{
|
|
|
|
if (coord.z > fogTo)
|
|
|
|
{
|
|
|
|
gl_FragColor = fogColor;
|
2013-05-15 20:49:51 -04:00
|
|
|
gl_FragColor.a = color.a;
|
2013-05-11 19:09:03 -04:00
|
|
|
}
|
|
|
|
else if (coord.z > fogFrom)
|
|
|
|
{
|
|
|
|
float fogIntensity = (coord.z - fogFrom) / (fogTo - fogFrom);
|
|
|
|
vec4 color2 = fogIntensity*fogColor + (1.0 - fogIntensity)*solidColor;
|
|
|
|
color2.a = color.a;
|
|
|
|
gl_FragColor = color2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gl_FragColor = color;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gl_FragColor = color;
|
|
|
|
}
|
|
|
|
}
|