-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmake-convergence-hook.py
More file actions
executable file
·94 lines (82 loc) · 2.1 KB
/
make-convergence-hook.py
File metadata and controls
executable file
·94 lines (82 loc) · 2.1 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python
import struct
rxcoords = (
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0
)
rycoords = (
0.0, -0.001, 0.001, 0.006,
0.0, 0.0, -0.001, 0.0,
0.0, 0.0, 0.002, 0.0,
0.0, -0.001, -0.001, 0.0
)
gxcoords = (
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0
)
gycoords = (
0.003, 0.003, 0.005, 0.001,
0.0, 0.002, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, -0.003, -0.003, 0.0
)
bxcoords = (
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0
)
bycoords = (
-0.004, 0.0, 0.0, 0.0,
0.0, -0.001, 0.0, 0.0,
0.0, 0.001, 0.0, 0.0,
0.0, 0.0, 0.0, 0.002
)
print("""//!TEXTURE XCOORDS
//!SIZE 4 4
//!FORMAT rgb16f
//!FILTER LINEAR""")
for r, g, b in zip(rxcoords, gxcoords, bxcoords):
print(memoryview(struct.pack('fff', 1.0-r, 1.0-g, 1.0-b)).hex(), end='')
print()
print()
print("""//!TEXTURE YCOORDS
//!SIZE 4 4
//!FORMAT rgb16f
//!FILTER LINEAR""")
for r, g, b in zip(rycoords, gycoords, bycoords):
print(memoryview(struct.pack('fff', 1.0-r, 1.0-g, 1.0-b)).hex(), end='')
print()
print()
print("""//!HOOK OUTPUT
//!BIND HOOKED
//!BIND XCOORDS
//!BIND YCOORDS
//!COMPONENTS 3
//!DESC Convergence Adjust
#define COORDS_WIDTH (4.0)
#define COORDS_HEIGHT (4.0)
const vec2 COORDS_size = vec2(COORDS_WIDTH, COORDS_HEIGHT);
const vec2 border = 1.0 / COORDS_size / 2.0;
const vec2 area = 1.0 - (border * 2.0);
vec4 hook() {
vec2 pos = HOOKED_pos * area + border;
vec3 xoffset = texture(XCOORDS, pos).rgb - 1.0;
vec3 yoffset = texture(YCOORDS, pos).rgb - 1.0;
vec2 roffset = vec2(xoffset.r, yoffset.r);
vec2 goffset = vec2(xoffset.g, yoffset.g);
vec2 boffset = vec2(xoffset.b, yoffset.b);
//return vec4(roffset.x + 1.0 / 2.0,
// goffset.x + 1.0 / 2.0,
// boffset.x + 1.0 / 2.0,
// 1.0);
return vec4(HOOKED_tex(HOOKED_pos + roffset).r,
HOOKED_tex(HOOKED_pos + goffset).g,
HOOKED_tex(HOOKED_pos + boffset).b,
1.0);
}""")
print()