blob: fc987b178253343a1f35c3833720bf8dbda9e92d (
plain)
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
|
//go:build ignore
//kage:unit pixels
package main
const THRESHOLD = .9
const DIRECTIONS = 30.0 // BLUR DIRECTIONS (Default 16.0 - More is better but slower)
const QUALITY = 12.0 // BLUR QUALITY (Default 4.0 - More is better but slower)
const SIZE = 5.0 // BLUR SIZE (Radius)
const PI = 6.28318530718 // Pi*2
const OPACITY = 0.21
var Time float
var NoiseOffset float
func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
uv := srcPos
average := vec3(0.0)
radius := SIZE / 2
amount := 0.0
for d:=0.0; d<PI; d+=PI/DIRECTIONS{
for i:=1.0/QUALITY; i<=1.0; i+=1.0/QUALITY{
t := imageSrc0UnsafeAt(uv + vec2(cos(d),sin(d))*radius*log(i)).rgb
brightness := dot(t.rgb, vec3(0.2126, 0.7152, 0.0722))
if brightness > THRESHOLD {
average += t
amount += 1.0
}
}
}
col := imageSrc0UnsafeAt(uv).rgb
if amount > 0 {
col += (average / amount) * OPACITY
}
return vec4(col,1.0)
}
|