-
Notifications
You must be signed in to change notification settings - Fork 3
/
tm.fs
40 lines (30 loc) · 979 Bytes
/
tm.fs
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
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D u_image0; // original
uniform sampler2D u_image1; // template
uniform vec2 u_ires0;
uniform vec2 u_ires1;
void main()
{
float sumR = 0.0;
float sumG = 0.0;
float sumB = 0.0;
for (int i = 0; i <= 32; i++)
{
for (int j = 0; j <= 32; j++)
{
vec2 d0 = vec2(float(i), float(j)) * u_ires0;
vec2 d1 = vec2(float(i), float(j)) * u_ires1;
vec4 I = texture2D(u_image0, v_texCoord + d0);
vec4 T = texture2D(u_image1, d1);
float diffR = T.r - I.r;
float diffG = T.g - I.g;
float diffB = T.b - I.b;
sumR += diffR * diffR;
sumG += diffG * diffG;
sumB += diffB * diffB;
}
}
gl_FragColor = vec4(sumR / float(255), sumG / float(255), sumB / float(255), 1);
// gl_FragColor = texture2D(u_image0, v_texCoord);
}