1 | R""( |
2 |
|
3 | #version 460 core |
4 |
|
5 |
|
6 | in ivec4 gl_FragCoord; |
7 | layout(binding=0, rgba32f) uniform image2D texture0; |
8 | uniform ivec2 screensize; |
9 | uniform int it_count; |
10 | uniform double zoom; |
11 | uniform float brightness; |
12 | uniform bool enable_interlacing; |
13 | uniform int interlace_layer; |
14 | uniform bool first_interlace; |
15 | out vec4 fragColor; |
16 |
|
17 | const float INTERLACE_COLOR_MULTIPLIERS[7] = {3., 3., 2., 2., 2., 1., 1.}; |
18 |
|
19 | void main() |
20 | { |
21 | ivec2 texcoord = gl_FragCoord.xy; |
22 | bool point_contains_data = imageLoad(texture0, texcoord).r >= 0.9; |
23 | if (enable_interlacing && first_interlace && !point_contains_data) |
24 | { |
25 | int nearest_x = 8; |
26 | int nearest_y = 8; |
27 | int offset_x = 0; |
28 | int offset_y = 0; |
29 | switch (interlace_layer) |
30 | { |
31 | case 1: |
32 | nearest_x = 8; |
33 | nearest_y = 8; |
34 | int offset_x = 8; |
35 | int offset_y = 8; |
36 | break; |
37 | case 2: |
38 | nearest_x = 8; |
39 | nearest_y = 8; |
40 | offset_x = 4; |
41 | break; |
42 | case 3: |
43 | nearest_x = 4; |
44 | nearest_y = 8; |
45 | offset_y = 4; |
46 | break; |
47 | case 4: |
48 | nearest_x = 4; |
49 | nearest_y = 4; |
50 | offset_x = 2; |
51 | break; |
52 | case 5: |
53 | nearest_x = 2; |
54 | nearest_y = 4; |
55 | offset_y = 2; |
56 | break; |
57 | case 6: |
58 | nearest_x = 2; |
59 | nearest_y = 2; |
60 | offset_x = 1; |
61 | break; |
62 | case 7: |
63 | nearest_x = 1; |
64 | nearest_y = 2; |
65 | offset_y = 1; |
66 | break; |
67 | } |
68 |
|
69 | int xpos = (int(gl_FragCoord.x) - (int(gl_FragCoord.x) % nearest_x)) + offset_x; |
70 | int ypos = (int(gl_FragCoord.y) - (int(gl_FragCoord.y) % nearest_y)) + offset_y; |
71 |
|
72 | texcoord = ivec2(xpos, ypos).xy; |
73 | } |
74 |
|
75 | float iterations = imageLoad(texture0, texcoord).r; |
76 | float col = iterations; |
77 | if (enable_interlacing && first_interlace) { col *= INTERLACE_COLOR_MULTIPLIERS[interlace_layer - 1]; } |
78 |
|
79 | if (iterations <= 0.6) |
80 | { |
81 | fragColor = vec4(0.0, 0.0, 0.0, 0.0); |
82 | } |
83 | else |
84 | { |
85 | col = clamp(col/it_count*brightness, 0.0, 1.0); |
86 | fragColor = vec4(col*0.65, col*0.35, col*0.7, 0.0); |
87 | } |
88 | } |
89 |
|
90 | )"" |
91 |
|