-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathsharpen.frag
42 lines (30 loc) · 991 Bytes
/
sharpen.frag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
(C) 2019 David Lettier
lettier.com
*/
#version 150
uniform sampler2D colorTexture;
uniform vec2 enabled;
out vec4 fragColor;
void main() {
float amount = 0.3;
vec2 texSize = textureSize(colorTexture, 0).xy;
vec2 fragCoord = gl_FragCoord.xy;
vec2 texCoord = fragCoord / texSize;
if (enabled.x != 1) { fragColor = texture(colorTexture, texCoord); return; }
float neighbor = amount * -1.0;
float center = amount * 4.0 + 1.0;
vec3 color =
texture(colorTexture, (fragCoord + vec2( 0, 1)) / texSize).rgb
* neighbor
+ texture(colorTexture, (fragCoord + vec2(-1, 0)) / texSize).rgb
* neighbor
+ texture(colorTexture, (fragCoord + vec2( 0, 0)) / texSize).rgb
* center
+ texture(colorTexture, (fragCoord + vec2( 1, 0)) / texSize).rgb
* neighbor
+ texture(colorTexture, (fragCoord + vec2( 0, -1)) / texSize).rgb
* neighbor
;
fragColor = vec4(color, texture(colorTexture, texCoord).a);
}