2013-04-23 18:39:10 -04:00
|
|
|
|
|
|
|
uniform sampler2D myTexture;
|
|
|
|
uniform float fogDistance;
|
|
|
|
|
|
|
|
varying vec3 vPosition;
|
|
|
|
|
|
|
|
void main (void)
|
|
|
|
{
|
|
|
|
vec4 col = texture2D(myTexture, vec2(gl_TexCoord[0]));
|
|
|
|
col *= gl_Color;
|
2013-04-27 23:04:52 -04:00
|
|
|
float a = col.a;
|
2013-04-23 18:39:10 -04:00
|
|
|
col = col * col; // SRGB -> Linear
|
2013-04-27 23:04:52 -04:00
|
|
|
col *= 1.8;
|
2013-04-23 18:39:10 -04:00
|
|
|
col.r = 1.0 - exp(1.0 - col.r) / exp(1.0);
|
|
|
|
col.g = 1.0 - exp(1.0 - col.g) / exp(1.0);
|
2013-04-27 23:04:52 -04:00
|
|
|
col.b = 1.0 - exp(1.0 - col.b) / exp(1.0);
|
|
|
|
col = sqrt(col); // Linear -> SRGB
|
|
|
|
|
2013-04-23 18:39:10 -04:00
|
|
|
if(fogDistance != 0.0){
|
|
|
|
float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));
|
|
|
|
a = mix(a, 0.0, d);
|
2013-04-27 23:04:52 -04:00
|
|
|
}
|
|
|
|
|
2013-04-23 18:39:10 -04:00
|
|
|
gl_FragColor = vec4(col.r, col.g, col.b, a);
|
|
|
|
}
|