2023-01-14 12:00:59 +01:00
|
|
|
#version 330 core
|
|
|
|
out vec4 FragColor;
|
|
|
|
|
|
|
|
in vec2 tc;
|
|
|
|
|
2023-01-30 12:10:43 +01:00
|
|
|
uniform sampler2D color;
|
|
|
|
uniform sampler2D highlight;
|
2023-01-14 12:00:59 +01:00
|
|
|
|
2023-01-16 17:25:19 +01:00
|
|
|
float rescale_z(float z){
|
|
|
|
float n = 0.05;
|
|
|
|
float f = 20.;
|
|
|
|
return (2*n*f/(z*(n-f)+n+f))/f;
|
|
|
|
}
|
2023-01-30 13:05:38 +01:00
|
|
|
float weight[5] = float[] (0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
|
|
|
|
|
|
|
|
vec4 blur()
|
|
|
|
{
|
|
|
|
vec2 tex_offset = 1.0 / textureSize(color, 0); // gets size of single texel
|
|
|
|
vec3 result = texture(color, tc).rgb * weight[0]; // current fragment's contribution
|
|
|
|
bool horizontal = true;
|
|
|
|
if(horizontal)
|
|
|
|
{
|
|
|
|
for(int i = 1; i < 5; ++i)
|
|
|
|
{
|
|
|
|
result += texture(color, tc + vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
|
|
|
|
result += texture(color, tc - vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(int i = 1; i < 5; ++i)
|
|
|
|
{
|
|
|
|
result += texture(color, tc + vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
|
|
|
result += texture(color, tc - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return vec4(result, 1.0);
|
|
|
|
}
|
2023-01-16 17:25:19 +01:00
|
|
|
|
2023-01-14 12:00:59 +01:00
|
|
|
void main()
|
|
|
|
{
|
2023-01-30 12:10:43 +01:00
|
|
|
//float depthValue = texture(depthMap, tc).r;
|
2023-01-23 12:11:20 +01:00
|
|
|
//FragColor = vec4(vec3(rescale_z(depthValue)+0.5), 1.0);
|
2023-01-30 12:10:43 +01:00
|
|
|
//FragColor = vec4(vec3((depthValue)+0.5), 1.0);
|
2023-01-30 13:05:38 +01:00
|
|
|
|
|
|
|
FragColor = vec4( blur());
|
|
|
|
//FragColor = vec4( (texture(color, tc)-0.98)*50);
|
2023-01-14 12:00:59 +01:00
|
|
|
}
|