2014-08-18 11:49:44 -04:00
|
|
|
#ifdef GL_ARB_bindless_texture
|
|
|
|
layout(bindless_sampler) uniform sampler2D tex;
|
|
|
|
#else
|
2014-02-03 14:14:12 -05:00
|
|
|
uniform sampler2D tex;
|
2014-08-18 11:49:44 -04:00
|
|
|
#endif
|
|
|
|
|
2014-02-03 14:14:12 -05:00
|
|
|
|
|
|
|
uniform float fogmax;
|
|
|
|
uniform float startH;
|
|
|
|
uniform float endH;
|
|
|
|
uniform float start;
|
|
|
|
uniform float end;
|
|
|
|
uniform vec3 col;
|
2014-05-16 21:09:21 -04:00
|
|
|
|
2014-02-03 14:14:12 -05:00
|
|
|
in vec2 uv;
|
2014-03-20 13:25:44 -04:00
|
|
|
in vec4 color;
|
2014-02-03 14:14:12 -05:00
|
|
|
out vec4 FragColor;
|
2014-02-28 11:29:05 -05:00
|
|
|
|
2014-02-03 14:14:12 -05:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2014-06-25 08:53:49 -04:00
|
|
|
vec4 diffusecolor = texture(tex, uv);
|
2014-08-18 11:49:44 -04:00
|
|
|
#ifdef GL_ARB_bindless_texture
|
|
|
|
diffusecolor.xyz = pow(diffusecolor.xyz, vec3(2.2));
|
|
|
|
#endif
|
2014-06-25 08:53:49 -04:00
|
|
|
diffusecolor.xyz *= pow(color.xyz, vec3(2.2));
|
|
|
|
diffusecolor.a *= color.a;
|
|
|
|
vec3 tmp = vec3(gl_FragCoord.xy / screen, gl_FragCoord.z);
|
|
|
|
tmp = 2. * tmp - 1.;
|
2014-02-03 14:14:12 -05:00
|
|
|
|
2014-06-25 08:53:49 -04:00
|
|
|
vec4 xpos = vec4(tmp, 1.0);
|
|
|
|
xpos = InverseProjectionMatrix * xpos;
|
|
|
|
xpos.xyz /= xpos.w;
|
2014-02-03 14:14:12 -05:00
|
|
|
|
2014-06-25 08:53:49 -04:00
|
|
|
float dist = length(xpos.xyz);
|
|
|
|
float fog = smoothstep(start, end, dist);
|
2014-02-03 14:14:12 -05:00
|
|
|
|
2014-06-25 08:53:49 -04:00
|
|
|
fog = min(fog, fogmax);
|
2014-02-03 14:14:12 -05:00
|
|
|
|
2014-06-25 08:53:49 -04:00
|
|
|
vec4 finalcolor = vec4(col, 0.) * fog + diffusecolor *(1. - fog);
|
|
|
|
FragColor = vec4(finalcolor.rgb * finalcolor.a, finalcolor.a);
|
2014-02-03 14:14:12 -05:00
|
|
|
}
|