This repository was archived by the owner on Jan 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathantiring.hook
70 lines (52 loc) · 1.85 KB
/
antiring.hook
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
//!DESC scale antiringing
//!HOOK POSTKERNEL
//!BIND PREKERNEL
//!BIND HOOKED
//-- Configurable parameters --
const float radius = 0.5;
const float strength = 1.0;
//-- Configurable parameters end --
const float sq2i = 0.7071067811865475;
vec4 hook() {
vec2 kpos = (input_size * PREKERNEL_pos + tex_offset) / PREKERNEL_size;
#define get(x,y) PREKERNEL_tex(kpos + PREKERNEL_pt * radius * vec2(x,y))
vec4 c0 = get(-1, 0);
vec4 c1 = get( 1, 0);
vec4 c2 = get( 0, -1);
vec4 c3 = get( 0, 1);
vec4 c4 = get(-sq2i, sq2i);
vec4 c5 = get( sq2i, sq2i);
vec4 c6 = get(-sq2i, -sq2i);
vec4 c7 = get( sq2i, -sq2i);
vec4 lo = min( min(min(c0,c1), min(c2,c3)), min(min(c4,c5), min(c6,c7)) );
vec4 hi = max( max(max(c0,c1), max(c2,c3)), max(max(c4,c5), max(c6,c7)) );
vec4 color = HOOKED_texOff(0);
return mix(color, clamp(color, lo, hi), strength);
}
//!DESC cscale antiringing
//!HOOK CHROMA_SCALED
//!BIND CHROMA
//!BIND HOOKED
// !!! WARNING: This introduces some error due to failing to account for chroma
// offsets, but I don't have a good solution for that.. If you don't like it,
// you can remove this pass
//-- Configurable parameters --
const float radius = 0.5;
const float strength = 1.0;
//-- Configurable parameters end --
const float sq2i = 0.7071067811865475;
vec4 hook() {
#define get(x,y) CHROMA_texOff(radius * vec2(x,y))
vec4 c0 = get(-1, 0);
vec4 c1 = get( 1, 0);
vec4 c2 = get( 0, -1);
vec4 c3 = get( 0, 1);
vec4 c4 = get(-sq2i, sq2i);
vec4 c5 = get( sq2i, sq2i);
vec4 c6 = get(-sq2i, -sq2i);
vec4 c7 = get( sq2i, -sq2i);
vec4 lo = min( min(min(c0,c1), min(c2,c3)), min(min(c4,c5), min(c6,c7)) );
vec4 hi = max( max(max(c0,c1), max(c2,c3)), max(max(c4,c5), max(c6,c7)) );
vec4 color = HOOKED_texOff(0);
return mix(color, clamp(color, lo, hi), strength);
}