2013-11-30 16:33:06 -05:00
|
|
|
uniform sampler2D tex;
|
|
|
|
|
|
|
|
uniform float fogmax;
|
|
|
|
uniform float startH;
|
|
|
|
uniform float endH;
|
|
|
|
uniform float start;
|
|
|
|
uniform float end;
|
|
|
|
uniform vec3 col;
|
|
|
|
|
2014-05-02 12:11:34 -04:00
|
|
|
#ifdef UBO_DISABLED
|
|
|
|
uniform mat4 ViewMatrix;
|
|
|
|
uniform mat4 ProjectionMatrix;
|
|
|
|
uniform mat4 InverseViewMatrix;
|
|
|
|
uniform mat4 InverseProjectionMatrix;
|
2014-02-28 11:29:05 -05:00
|
|
|
#else
|
2014-05-02 12:11:34 -04:00
|
|
|
layout (std140) uniform MatrixesData
|
|
|
|
{
|
|
|
|
mat4 ViewMatrix;
|
|
|
|
mat4 ProjectionMatrix;
|
|
|
|
mat4 InverseViewMatrix;
|
|
|
|
mat4 InverseProjectionMatrix;
|
|
|
|
mat4 ShadowViewProjMatrixes[4];
|
|
|
|
};
|
2014-02-28 11:29:05 -05:00
|
|
|
#endif
|
|
|
|
|
2014-05-02 12:11:34 -04:00
|
|
|
in vec2 uv;
|
|
|
|
out vec4 FragColor;
|
|
|
|
|
|
|
|
|
|
|
|
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
|
2014-01-08 18:11:10 -05:00
|
|
|
|
2013-11-30 16:33:06 -05:00
|
|
|
void main()
|
|
|
|
{
|
2014-01-27 13:31:03 -05:00
|
|
|
float z = texture(tex, uv).x;
|
2014-05-02 12:11:34 -04:00
|
|
|
vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix);
|
2013-11-30 16:33:06 -05:00
|
|
|
|
2014-02-03 13:35:37 -05:00
|
|
|
float dist = length(xpos.xyz);
|
2013-11-30 16:33:06 -05:00
|
|
|
float fog = smoothstep(start, end, dist);
|
|
|
|
|
|
|
|
fog = min(fog, fogmax);
|
|
|
|
|
2014-01-19 13:31:00 -05:00
|
|
|
FragColor = vec4(col, fog);
|
2013-11-30 16:33:06 -05:00
|
|
|
}
|