GRK_Room/cw 9/shaders/test.frag

48 lines
1.4 KiB
GLSL
Raw Normal View History

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
2023-02-06 17:29:54 +01:00
vec3 result = texture(highlight, tc).rgb * weight[0]; // current fragment's contribution
2023-01-30 13:05:38 +01:00
bool horizontal = true;
if(horizontal)
{
for(int i = 1; i < 5; ++i)
{
2023-02-06 17:29:54 +01:00
result += texture(highlight, tc + vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
result += texture(highlight, tc - vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
2023-01-30 13:05:38 +01:00
}
}
else
{
for(int i = 1; i < 5; ++i)
{
2023-02-06 17:29:54 +01:00
result += texture(highlight, tc + vec2(0.0, tex_offset.y * i)).rgb * weight[i];
result += texture(highlight, tc - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
2023-01-30 13:05:38 +01:00
}
}
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
2023-02-06 17:29:54 +01:00
FragColor = vec4(texture(highlight, tc).rgb+texture(color, tc).rgb,1);
2023-01-30 13:05:38 +01:00
//FragColor = vec4( (texture(color, tc)-0.98)*50);
2023-01-14 12:00:59 +01:00
}