-
Notifications
You must be signed in to change notification settings - Fork 0
/
Blur.pbk
63 lines (57 loc) · 2.38 KB
/
Blur.pbk
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<languageVersion : 1.0;>
kernel Blur
< namespace : "Blur";
vendor : "Paperless Post";
version : 1;
>
{
input image4 src;
output pixel4 dst;
/*parameter float strength
<
minValue:float(0.0);
maxValue:float(1.0);
defaultValue:float(0.5);
>;*/
parameter float threshold
<
minValue:float(0.0);
maxValue:float(1.0);
defaultValue:float(0.5);
>;
void
evaluatePixel()
{
float2 pos = outCoord();
dst = sampleNearest(src, pos);
float strength = length(dst.rgb) / length(float3(1.0,1.0,1.0));
if(strength > threshold){
dst += sampleNearest(src, float2(pos.x-1.0,pos.y-1.0));
dst += sampleNearest(src, float2(pos.x,pos.y-1.0));
dst += sampleNearest(src, float2(pos.x+1.0,pos.y-1.0));
dst += sampleNearest(src, float2(pos.x-1.0,pos.y));
dst += sampleNearest(src, float2(pos.x+1.0,pos.y));
dst += sampleNearest(src, float2(pos.x-1.0,pos.y+1.0));
dst += sampleNearest(src, float2(pos.x,pos.y+1.0));
dst += sampleNearest(src, float2(pos.x+1.0,pos.y+1.0));
dst += sampleNearest(src, float2(pos.x-2.0,pos.y-2.0));
dst += sampleNearest(src, float2(pos.x-1.0,pos.y-2.0));
dst += sampleNearest(src, float2(pos.x,pos.y-2.0));
dst += sampleNearest(src, float2(pos.x+1.0,pos.y-2.0));
dst += sampleNearest(src, float2(pos.x+2.0,pos.y-2.0));
dst += sampleNearest(src, float2(pos.x-2.0,pos.y-1.0));
dst += sampleNearest(src, float2(pos.x+2.0,pos.y-1.0));
dst += sampleNearest(src, float2(pos.x-2.0,pos.y));
dst += sampleNearest(src, float2(pos.x+2.0,pos.y));
dst += sampleNearest(src, float2(pos.x-2.0,pos.y+1.0));
dst += sampleNearest(src, float2(pos.x+2.0,pos.y+1.0));
dst += sampleNearest(src, float2(pos.x-2.0,pos.y+2.0));
dst += sampleNearest(src, float2(pos.x-1.0,pos.y+2.0));
dst += sampleNearest(src, float2(pos.x,pos.y+2.0));
dst += sampleNearest(src, float2(pos.x+1.0,pos.y+2.0));
dst += sampleNearest(src, float2(pos.x+2.0,pos.y+2.0));
dst/= 24.0;
dst = mix(sampleNearest(src,pos),dst,strength);
}
}
}