@thenick775/mgba-wasm 2.5.0-beta.2 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mgba.data DELETED
@@ -1,3446 +0,0 @@
1
- varying vec2 texCoord;
2
- uniform sampler2D tex;
3
- uniform vec2 texSize;
4
- uniform vec2 outputSize;
5
-
6
- #ifdef GL_FRAGMENT_PRECISION_HIGH
7
- precision highp float;
8
- #else
9
- precision mediump float;
10
- #endif
11
-
12
- void main() {
13
- vec3 c = texture2D(tex, texCoord).rgb;
14
-
15
- // gamma-ish shaping the original shader intended
16
- c = pow(c * vec3(0.8), vec3(1.8)) + vec3(0.16);
17
-
18
- // Stripe mask aligned to OUTPUT pixels (stable across scale factors)
19
- float x = mod(floor(gl_FragCoord.x), 3.0);
20
- vec3 maskX =
21
- (x < 0.5) ? vec3(0.2, 0.2, 1.0) :
22
- (x < 1.5) ? vec3(0.2, 1.0, 0.2) :
23
- vec3(1.0, 0.2, 0.2);
24
-
25
- float y = mod(floor(gl_FragCoord.y), 4.0);
26
- vec3 maskY = (y < 3.5) ? vec3(1.0) : vec3(0.8);
27
-
28
- c *= (maskX * maskY);
29
-
30
- gl_FragColor = vec4(c, 1.0);
31
- }
32
- [shader]
33
- name=AGB-001
34
- author=endrift
35
- description=A glorious recreation of the original Game Boy Advance
36
- passes=1
37
-
38
- [pass.0]
39
- fragmentShader=agb001.fs
40
- blend=1
41
- width=-3
42
- height=-4
43
- varying vec2 texCoord;
44
- uniform sampler2D tex;
45
- uniform float reflectionBrightness;
46
- uniform vec2 reflectionDistance;
47
- uniform float lightBrightness;
48
-
49
- const float speed = 2.0;
50
- const float decay = 2.0;
51
- const float coeff = 2.5;
52
-
53
- void main() {
54
- float sp = pow(speed, lightBrightness);
55
- float dc = pow(decay, -lightBrightness);
56
- float s = (sp - dc) / (sp + dc);
57
- vec2 radius = (texCoord.st - vec2(0.5, 0.5)) * vec2(coeff * s);
58
- radius = pow(abs(radius), vec2(4.0));
59
- vec3 bleed = vec3(0.12, 0.14, 0.19);
60
- bleed += (dot(radius, radius) + vec3(0.02, 0.03, 0.05)) * vec3(0.14, 0.18, 0.2);
61
-
62
- vec4 color = texture2D(tex, texCoord);
63
- color.rgb += pow(bleed, pow(vec3(lightBrightness), vec3(-0.5)));
64
-
65
- vec4 reflection = texture2D(tex, texCoord - reflectionDistance);
66
- color.rgb += reflection.rgb * reflectionBrightness;
67
- color.a = 1.0;
68
- gl_FragColor = color;
69
- }
70
- varying vec2 texCoord;
71
- uniform sampler2D tex;
72
- uniform vec2 texSize;
73
-
74
- const vec3 kArrayX0 = vec3(0.2, 0.2, 1.0);
75
- const vec3 kArrayX1 = vec3(0.2, 1.0, 0.2);
76
- const vec3 kArrayX2 = vec3(1.0, 0.2, 0.2);
77
- const vec3 kArrayY0 = vec3(1.0, 1.0, 1.0);
78
- const vec3 kArrayY1 = vec3(1.0, 1.0, 1.0);
79
- const vec3 kArrayY2 = vec3(1.0, 1.0, 1.0);
80
- const vec3 kArrayY3 = vec3(0.9, 0.9, 0.9);
81
-
82
-
83
- void main() {
84
- vec4 color = texture2D(tex, texCoord);
85
- // WebGL1-safe: precomputed constant LUTs (no runtime array writes)
86
- color.rgb = pow(color.rgb, vec3(1.6, 1.6, 1.6));
87
- int xi = int(mod(texCoord.s * texSize.x * 3.0, 3.0));
88
- vec3 ax = (xi == 0) ? kArrayX0 : ((xi == 1) ? kArrayX1 : kArrayX2);
89
- int yi = int(mod(texCoord.t * texSize.y * 4.0, 4.0));
90
- vec3 ay = (yi == 0) ? kArrayY0 : ((yi == 1) ? kArrayY1 : ((yi == 2) ? kArrayY2 : kArrayY3));
91
- color.rgb *= ax;
92
- color.rgb *= ay;
93
- color.a = 0.8;
94
- gl_FragColor = color;
95
- }
96
- [shader]
97
- name=AGS-001
98
- author=endrift
99
- description=A pristine recreation of the illuminated Game Boy Advance SP
100
- passes=2
101
-
102
- [pass.0]
103
- fragmentShader=ags001.fs
104
- blend=1
105
- width=-3
106
- height=-4
107
-
108
- [pass.1]
109
- fragmentShader=ags001-light.fs
110
- width=-3
111
- height=-4
112
-
113
- [pass.1.uniform.lightBrightness]
114
- type=float
115
- default=1
116
- readableName=Light brightness
117
-
118
- [pass.1.uniform.reflectionBrightness]
119
- type=float
120
- default=0.07
121
- readableName=Reflection brightness
122
-
123
- [pass.1.uniform.reflectionDistance]
124
- type=float2
125
- default[0]=0
126
- default[1]=0.025
127
- readableName=Reflection distance
128
- // Shader that replicates the LCD Colorspace from a Nintendo DS Lite --
129
- varying vec2 texCoord;
130
- varying mat4 profile;
131
- uniform sampler2D tex;
132
- uniform vec2 texSize;
133
-
134
- const float target_gamma = 2.2;
135
- const float display_gamma = 2.2;
136
-
137
- void main() {
138
- // bring out our stored luminance value
139
- float lum = profile[3].w;
140
-
141
- // our adjustments need to happen in linear gamma
142
- vec4 screen = pow(texture2D(tex, texCoord), vec4(target_gamma)).rgba;
143
-
144
- screen = clamp(screen * lum, 0.0, 1.0);
145
- screen = profile * screen;
146
- gl_FragColor = pow(screen, vec4(1.0 / display_gamma));
147
- }
148
- uniform int color_mode;
149
- attribute vec4 position;
150
- varying vec2 texCoord;
151
- varying mat4 profile;
152
-
153
- const mat4 DSL_sRGB = mat4(
154
- 0.93, 0.025, 0.008, 0.0, //red channel
155
- 0.14, 0.90, -0.03, 0.0, //green channel
156
- -0.07, 0.075, 1.022, 0.0, //blue channel
157
- 0.0, 0.0, 0.0, 0.935 //alpha channel
158
- );
159
-
160
- const mat4 DSL_DCI = mat4(
161
- 0.76, 0.055, 0.0225, 0.0, //red channel
162
- 0.27, 0.875, 0.0225, 0.0, //green channel
163
- -0.03, 0.07, 0.955, 0.0, //blue channel
164
- 0.0, 0.0, 0.0, 0.97 //alpha channel
165
- );
166
-
167
- const mat4 DSL_Rec2020 = mat4(
168
- 0.585, 0.09, 0.0225, 0.0, //red channel
169
- 0.3725, 0.825, 0.035, 0.0, //green channel
170
- 0.0425, 0.085, 0.9425, 0.0, //blue channel
171
- 0.0, 0.0, 0.0, 1.0 //alpha channel
172
- );
173
-
174
- void main() {
175
- if (color_mode == 1) profile = DSL_sRGB;
176
- else if (color_mode == 2) profile = DSL_DCI;
177
- else if (color_mode == 3) profile = DSL_Rec2020;
178
-
179
- gl_Position = position;
180
- texCoord = (position.st + vec2(1.0, 1.0)) * vec2(0.5, 0.5);
181
- }
182
- [shader]
183
- name=Nintendo DS Lite Color
184
- author=Pokefan531 and hunterk
185
- description=Shader that replicates the LCD Colorspace from a Nintendo DS Lite.
186
- passes=1
187
-
188
- [pass.0]
189
- fragmentShader=dslite-color.fs
190
- vertexShader=dslite-color.vs
191
- blend=1
192
- width=-1
193
- height=-1
194
-
195
- [pass.0.uniform.color_mode]
196
- type=int
197
- default=1
198
- min=1
199
- max=3
200
- readableName=Color Profile (1=sRGB, 2=DCI, 3=Rec2020)
201
- /*
202
- fish shader
203
-
204
- algorithm and original implementation by Miloslav "drummyfish" Ciz
205
- (tastyfish@seznam.cz)
206
-
207
- Permission is hereby granted, free of charge, to any person obtaining a copy
208
- of this software and associated documentation files (the "Software"), to deal
209
- in the Software without restriction, including without limitation the rights
210
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
211
- copies of the Software, and to permit persons to whom the Software is
212
- furnished to do so, subject to the following conditions:
213
-
214
- The above copyright notice and this permission notice shall be included in
215
- all copies or substantial portions of the Software.
216
-
217
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
218
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
219
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
220
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
221
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
222
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
223
- THE SOFTWARE.
224
- */
225
-
226
- uniform sampler2D tex;
227
- uniform vec2 texSize;
228
- varying vec2 texCoord;
229
-
230
- uniform float similarity_threshold;
231
-
232
- vec4 texel_fetch(sampler2D t, ivec2 c) // because GLSL TexelFetch is not supported
233
- {
234
- return texture2D(t, (2.0 * vec2(c) + vec2(1.0,1.0)) / (2.0 * texSize));
235
- }
236
-
237
- float pixel_brightness(vec4 pixel)
238
- {
239
- return 0.21 * pixel.x + 0.72 * pixel.y + 0.07 * pixel.z;
240
- }
241
-
242
- bool pixel_is_brighter(vec4 pixel1, vec4 pixel2)
243
- {
244
- return pixel_brightness(pixel1) > pixel_brightness(pixel2);
245
- }
246
-
247
- vec3 pixel_to_yuv(vec4 pixel)
248
- {
249
- float y = 0.299 * pixel.x + 0.587 * pixel.y + 0.114 * pixel.z;
250
- return vec3(y, 0.492 * (pixel.z - y), 0.877 * (pixel.x - y));
251
- }
252
-
253
- bool yuvs_are_similar(vec3 yuv1, vec3 yuv2)
254
- {
255
- vec3 yuv_difference = abs(yuv1 - yuv2);
256
- return yuv_difference.x <= similarity_threshold && yuv_difference.y <= similarity_threshold && yuv_difference.z <= similarity_threshold;
257
- }
258
-
259
- bool pixels_are_similar(vec4 pixel1, vec4 pixel2)
260
- {
261
- vec3 yuv1 = pixel_to_yuv(pixel1);
262
- vec3 yuv2 = pixel_to_yuv(pixel2);
263
-
264
- return yuvs_are_similar(yuv1, yuv2);
265
- }
266
-
267
- vec4 interpolate_nondiagonal(vec4 neighbour1, vec4 neighbour2)
268
- {
269
- if (pixels_are_similar(neighbour1,neighbour2))
270
- return mix(neighbour1,neighbour2,0.5);
271
- else
272
- return pixel_is_brighter(neighbour1, neighbour2) ? neighbour1 : neighbour2;
273
- }
274
-
275
- vec4 mix3(vec4 value1, vec4 value2, vec4 value3)
276
- {
277
- return (value1 + value2 + value3) / 3.0;
278
- }
279
-
280
- vec4 straight_line(vec4 p0, vec4 p1, vec4 p2, vec4 p3)
281
- {
282
- return pixel_is_brighter(p2,p0) ? mix(p2,p3,0.5) : mix(p0,p1,0.5);
283
- }
284
-
285
- vec4 corner(vec4 p0, vec4 p1, vec4 p2, vec4 p3)
286
- {
287
- return pixel_is_brighter(p1,p0) ? mix3(p1,p2,p3) : mix3(p0,p1,p2);
288
- }
289
-
290
- vec4 interpolate_diagonal(vec4 a, vec4 b, vec4 c, vec4 d)
291
- {
292
- // a b
293
- // c d
294
-
295
- vec3 a_yuv = pixel_to_yuv(a);
296
- vec3 b_yuv = pixel_to_yuv(b);
297
- vec3 c_yuv = pixel_to_yuv(c);
298
- vec3 d_yuv = pixel_to_yuv(d);
299
-
300
- bool ad = yuvs_are_similar(a_yuv,d_yuv);
301
- bool bc = yuvs_are_similar(b_yuv,c_yuv);
302
- bool ab = yuvs_are_similar(a_yuv,b_yuv);
303
- bool cd = yuvs_are_similar(c_yuv,d_yuv);
304
- bool ac = yuvs_are_similar(a_yuv,c_yuv);
305
- bool bd = yuvs_are_similar(b_yuv,d_yuv);
306
-
307
- if (ad && cd && ab) // all pixels are equal?
308
- return( mix(mix(a,b,0.5), mix(c,d,0.5), 0.5) );
309
-
310
- else if (ac && cd && ! ab) // corner 1?
311
- return corner(b,a,d,c);
312
- else if (bd && cd && ! ab) // corner 2?
313
- return corner(a,b,c,d);
314
- else if (ac && ab && ! bd) // corner 3?
315
- return corner(d,c,b,a);
316
- else if (ab && bd && ! ac) // corner 4?
317
- return corner(c,a,d,b);
318
-
319
- else if (ad && (!bc || pixel_is_brighter(b,a))) // diagonal line 1?
320
- return mix(a,d,0.5);
321
- else if (bc && (!ad || pixel_is_brighter(a,b))) // diagonal line 2?
322
- return mix(b,c,0.5);
323
-
324
- else if (ab) // horizontal line 1?
325
- return straight_line(a,b,c,d);
326
- else if (cd) // horizontal line 2?
327
- return straight_line(c,d,a,b);
328
-
329
- else if (ac) // vertical line 1?
330
- return straight_line(a,c,b,d);
331
- else if (bd) // vertical line 2?
332
- return straight_line(b,d,a,c);
333
-
334
- return( mix(mix(a,b,0.5), mix(c,d,0.5), 0.5) );
335
- }
336
-
337
- void main()
338
- {
339
- ivec2 pixel_coords2 = ivec2(vec2(texCoord) * vec2(texSize) * 2.0);
340
- ivec2 pixel_coords = pixel_coords2 / 2;
341
-
342
- bool x_even = (pixel_coords2.x - (pixel_coords2.x / 2) * 2) == 0;
343
- bool y_even = (pixel_coords2.y - (pixel_coords2.y / 2) * 2) == 0;
344
-
345
- if (x_even)
346
- {
347
- if (y_even)
348
- {
349
-
350
- gl_FragColor = interpolate_diagonal(
351
- texel_fetch(tex, pixel_coords + ivec2(-1,-1)),
352
- texel_fetch(tex, pixel_coords + ivec2(0,-1)),
353
- texel_fetch(tex, pixel_coords + ivec2(-1,0)),
354
- texel_fetch(tex, pixel_coords + ivec2(0,0))
355
- );
356
-
357
- }
358
- else
359
- {
360
- gl_FragColor = interpolate_nondiagonal
361
- (
362
- texel_fetch(tex, pixel_coords + ivec2(-1,0)),
363
- texel_fetch(tex, pixel_coords)
364
- );
365
- }
366
- }
367
- else if (y_even)
368
- {
369
- gl_FragColor = interpolate_nondiagonal
370
- (
371
- texel_fetch(tex, pixel_coords + ivec2(0,-1)),
372
- texel_fetch(tex, pixel_coords)
373
- );
374
- }
375
- else
376
- gl_FragColor = texel_fetch(tex, pixel_coords);
377
- }
378
- [shader]
379
- name=fish
380
- author=Drummyfish
381
- description=Attempts to keep thin lines thin.
382
- passes=1
383
-
384
- [pass.0]
385
- fragmentShader=fish.fs
386
- integerScaling=1
387
-
388
- [pass.0.uniform.similarity_threshold]
389
- type=float
390
- default=0.2
391
- readableName=Similarity Threshold
392
- min=0
393
- max=1
394
- // Shader that replicates the LCD Colorspace from a Gameboy Micro (OXY-001) --
395
- varying vec2 texCoord;
396
- varying mat4 profile;
397
- uniform sampler2D tex;
398
- uniform vec2 texSize;
399
-
400
- const float target_gamma = 2.2;
401
- const float display_gamma = 2.2;
402
-
403
- void main() {
404
- // bring out our stored luminance value
405
- float lum = profile[3].w;
406
-
407
- // our adjustments need to happen in linear gamma
408
- vec4 screen = pow(texture2D(tex, texCoord), vec4(target_gamma)).rgba;
409
-
410
- screen = clamp(screen * lum, 0.0, 1.0);
411
- screen = profile * screen;
412
- gl_FragColor = pow(screen, vec4(1.0 / display_gamma));
413
- }
414
- uniform int color_mode;
415
- attribute vec4 position;
416
- varying vec2 texCoord;
417
- varying mat4 profile;
418
-
419
- const mat4 GBM_sRGB = mat4(
420
- 0.8025, 0.10, 0.1225, 0.0, //red channel
421
- 0.31, 0.6875, 0.1125, 0.0, //green channel
422
- -0.1125, 0.2125, 0.765, 0.0, //blue channel
423
- 0.0, 0.0, 0.0, 0.9 //alpha channel
424
- );
425
-
426
- const mat4 GBM_DCI = mat4(
427
- 0.6675, 0.125, 0.13, 0.0, //red channel
428
- 0.3825, 0.675, 0.1475, 0.0, //green channel
429
- -0.05, 0.20, 0.7225, 0.0, //blue channel
430
- 0.0, 0.0, 0.0, 0.96 //alpha channel
431
- );
432
-
433
- const mat4 GBM_Rec2020 = mat4(
434
- 0.525, 0.15, 0.13, 0.0, //red channel
435
- 0.43, 0.65, 0.155, 0.0, //green channel
436
- 0.045, 0.20, 0.715, 0.0, //blue channel
437
- 0.0, 0.0, 0.0, 1.0 //alpha channel
438
- );
439
-
440
- void main() {
441
- if (color_mode == 1) profile = GBM_sRGB;
442
- else if (color_mode == 2) profile = GBM_DCI;
443
- else if (color_mode == 3) profile = GBM_Rec2020;
444
-
445
- gl_Position = position;
446
- texCoord = (position.st + vec2(1.0, 1.0)) * vec2(0.5, 0.5);
447
- }
448
- [shader]
449
- name=GB Micro Color
450
- author=Pokefan531 and hunterk
451
- description=Shader that replicates the LCD Colorspace from a Gameboy Micro (OXY-001).
452
- passes=1
453
-
454
- [pass.0]
455
- fragmentShader=gb-micro-color.fs
456
- vertexShader=gb-micro-color.vs
457
- blend=1
458
- width=-1
459
- height=-1
460
-
461
- [pass.0.uniform.color_mode]
462
- type=int
463
- default=1
464
- min=1
465
- max=3
466
- readableName=Color Profile (1=sRGB, 2=DCI, 3=Rec2020)
467
- // Shader that replicates the LCD Colorspace from Gameboy Advance --
468
- varying vec2 texCoord;
469
- varying mat4 profile;
470
- uniform sampler2D tex;
471
- uniform vec2 texSize;
472
-
473
- uniform float darken_screen;
474
- const float target_gamma = 2.0;
475
- const float display_gamma = 2.0;
476
-
477
- void main() {
478
- // bring out our stored luminance value
479
- float lum = profile[3].w;
480
-
481
- // our adjustments need to happen in linear gamma
482
- vec4 screen = pow(texture2D(tex, texCoord), vec4(target_gamma + darken_screen)).rgba;
483
-
484
- screen = clamp(screen * lum, 0.0, 1.0);
485
- screen = profile * screen;
486
- gl_FragColor = pow(screen, vec4(1.0 / display_gamma));
487
- }
488
- uniform int color_mode;
489
- attribute vec4 position;
490
- varying vec2 texCoord;
491
- varying mat4 profile;
492
-
493
- const mat4 GBA_sRGB = mat4(
494
- 0.80, 0.135, 0.195, 0.0, //red channel
495
- 0.275, 0.64, 0.155, 0.0, //green channel
496
- -0.075, 0.225, 0.65, 0.0, //blue channel
497
- 0.0, 0.0, 0.0, 0.93 //alpha channel
498
- );
499
-
500
- const mat4 GBA_DCI = mat4(
501
- 0.685, 0.16, 0.20, 0.0, //red channel
502
- 0.34, 0.629, 0.19, 0.0, //green channel
503
- -0.025, 0.211, 0.61, 0.0, //blue channel
504
- 0.0, 0.0, 0.0, 0.975 //alpha channel
505
- );
506
-
507
- const mat4 GBA_Rec2020 = mat4(
508
- 0.555, 0.1825, 0.20, 0.0, //red channel
509
- 0.395, 0.61, 0.195, 0.0, //green channel
510
- 0.05, 0.2075, 0.605, 0.0, //blue channel
511
- 0.0, 0.0, 0.0, 1.0 //alpha channel
512
- );
513
-
514
- void main() {
515
- if (color_mode == 1) profile = GBA_sRGB;
516
- else if (color_mode == 2) profile = GBA_DCI;
517
- else if (color_mode == 3) profile = GBA_Rec2020;
518
-
519
- gl_Position = position;
520
- texCoord = (position.st + vec2(1.0, 1.0)) * vec2(0.5, 0.5);
521
- }
522
- [shader]
523
- name=GBA Color
524
- author=Pokefan531 and hunterk
525
- description=Modifies the color output to simulate the GBA LCD characteristics.
526
- passes=1
527
-
528
- [pass.0]
529
- fragmentShader=gba-color.fs
530
- vertexShader=gba-color.vs
531
- blend=1
532
- width=-1
533
- height=-1
534
-
535
- [pass.0.uniform.darken_screen]
536
- type=float
537
- default=0.5
538
- min=0
539
- max=1
540
- readableName=Darken Screen
541
-
542
- [pass.0.uniform.color_mode]
543
- type=int
544
- default=1
545
- min=1
546
- max=3
547
- readableName=Color Profile (1=sRGB, 2=DCI, 3=Rec2020)
548
- // Shader that replicates the LCD Colorspace from Gameboy Color --
549
- varying vec2 texCoord;
550
- varying mat4 profile;
551
- uniform sampler2D tex;
552
- uniform vec2 texSize;
553
-
554
- uniform float lighten_screen;
555
- const float target_gamma = 2.2;
556
- const float display_gamma = 2.2;
557
-
558
- void main() {
559
- // bring out our stored luminance value
560
- float lum = profile[3].w;
561
-
562
- // our adjustments need to happen in linear gamma
563
- vec4 screen = pow(texture2D(tex, texCoord), vec4(target_gamma - lighten_screen)).rgba;
564
-
565
- screen = clamp(screen * lum, 0.0, 1.0);
566
- screen = profile * screen;
567
- gl_FragColor = pow(screen, vec4(1.0 / display_gamma));
568
- }
569
- uniform int color_mode;
570
- attribute vec4 position;
571
- varying vec2 texCoord;
572
- varying mat4 profile;
573
-
574
- const mat4 GBC_sRGB = mat4(
575
- 0.905, 0.10, 0.1575, 0.0, //red channel
576
- 0.195, 0.65, 0.1425, 0.0, //green channel
577
- -0.10, 0.25, 0.70, 0.0, //blue channel
578
- 0.0, 0.0, 0.0, 0.91 //alpha channel
579
- );
580
-
581
- const mat4 GBC_DCI = mat4(
582
- 0.76, 0.125, 0.16, 0.0, //red channel
583
- 0.27, 0.6375, 0.18, 0.0, //green channel
584
- -0.03, 0.2375, 0.66, 0.0, //blue channel
585
- 0.0, 0.0, 0.0, 0.97 //alpha channel
586
- );
587
-
588
- const mat4 GBC_Rec2020 = mat4(
589
- 0.61, 0.155, 0.16, 0.0, //red channel
590
- 0.345, 0.615, 0.1875, 0.0, //green channel
591
- 0.045, 0.23, 0.6525, 0.0, //blue channel
592
- 0.0, 0.0, 0.0, 1.0 //alpha channel
593
- );
594
-
595
- void main() {
596
- if (color_mode == 1) profile = GBC_sRGB;
597
- else if (color_mode == 2) profile = GBC_DCI;
598
- else if (color_mode == 3) profile = GBC_Rec2020;
599
-
600
- gl_Position = position;
601
- texCoord = (position.st + vec2(1.0, 1.0)) * vec2(0.5, 0.5);
602
- }
603
- [shader]
604
- name=GBC Color
605
- author=Pokefan531 and hunterk
606
- description=Modifies the color output to simulate the GBA LCD characteristics.
607
- passes=1
608
-
609
- [pass.0]
610
- fragmentShader=gbc-color.fs
611
- vertexShader=gbc-color.vs
612
- blend=1
613
- width=-1
614
- height=-1
615
-
616
- [pass.0.uniform.lighten_screen]
617
- type=float
618
- default=1.0
619
- min=0
620
- max=1
621
- readableName=External Lighten Screen
622
-
623
- [pass.0.uniform.color_mode]
624
- type=int
625
- default=1
626
- min=1
627
- max=3
628
- readableName=Color Profile (1=sRGB, 2=DCI, 3=Rec2020)
629
- /**
630
- * This shader creates a backlight bleeding effect,
631
- * and an internal reflection or ghosting effect.
632
- */
633
-
634
- varying vec2 texCoord;
635
- uniform sampler2D tex;
636
-
637
- /**
638
- * Determines the color of the backlight bleed.
639
- * Lower values produce less, dimmer light.
640
- * Higher values produce brighter or more colorful light.
641
- * You'll normally want each of these numbers to be close
642
- * to 1, and not normally lower than 0.
643
- */
644
- uniform vec3 LightColor;
645
-
646
- /**
647
- * Affects the shape of the backlight bleed glow.
648
- * Lower values cause the light bleed to fade out quickly
649
- * from the edges.
650
- * Higher values cause the light bleed to fade out more
651
- * softly and gradually toward the center.
652
- * You'll normally want this to be a number from 0 to 1.
653
- */
654
- uniform float LightSoftness;
655
-
656
- /**
657
- * Lower values result in a less visible or intense
658
- * backlight bleed.
659
- * Higher values make the backlight bleed more pronounced.
660
- * You'll normally want this to be a number close to 0,
661
- * and not normally higher than 1.
662
- */
663
- uniform float LightIntensity;
664
-
665
- /**
666
- * Lower values cause the internal reflection or ghosting
667
- * effect to be less visible.
668
- * Higher values cause the effect to be brighter and more
669
- * visible.
670
- * You'll normally want this to be a number close to 0,
671
- * and not normally higher than 1.
672
- */
673
- uniform float ReflectionBrightness;
674
-
675
- /**
676
- * Lower values have the internal reflection or ghosting
677
- * effect appear offset by a lesser distance.
678
- * Higher values have the effect offset by a greater
679
- * distance.
680
- * You'll normally want each of these numbers to be close
681
- * to 0, and not normally higher than 1.
682
- */
683
- uniform vec2 ReflectionDistance;
684
-
685
- #define M_PI 3.1415926535897932384626433832795
686
-
687
- const vec2 CENTER = vec2(0.5, 0.5);
688
- const float INV_SQRT_HALF = 1.4142135623730951; // 1.0 / sqrt(0.5)
689
-
690
- /**
691
- * Helper to compute backlight bleed intensity
692
- * for a texCoord input.
693
- */
694
- float getLightIntensity(vec2 coord) {
695
- vec2 coordCentered = coord - CENTER;
696
-
697
- // length(coordCentered) / sqrt(0.5) == length(coordCentered) * (1/sqrt(0.5))
698
- float coordDistCenter = length(coordCentered) * INV_SQRT_HALF;
699
-
700
- vec2 coordQuadrant = vec2(
701
- 1.0 - (1.5 * min(coord.x, 1.0 - coord.x)),
702
- 1.0 - (1.5 * min(coord.y, 1.0 - coord.y))
703
- );
704
-
705
- float lightIntensityEdges = (
706
- pow(coordQuadrant.x, 5.0) +
707
- pow(coordQuadrant.y, 5.0)
708
- );
709
-
710
- float lightIntensity = (
711
- (1.0 - LightSoftness) * lightIntensityEdges +
712
- LightSoftness * coordDistCenter
713
- );
714
-
715
- return clamp(lightIntensity, 0.0, 1.0);
716
- }
717
-
718
- /**
719
- * Helper to convert an intensity value into a white
720
- * gray color with that intensity. A radial distortion
721
- * effect with subtle chromatic abberation is applied that
722
- * makes it look a little more like a real old or cheap
723
- * backlight, and also helps to reduce color banding.
724
- */
725
- vec3 getWhiteVector(float intensity) {
726
- const float DeformAmount = 0.0025;
727
-
728
- vec2 texCoordCentered = texCoord - CENTER;
729
- float radians = atan(texCoordCentered.y, texCoordCentered.x);
730
-
731
- float ring = floor(6.0 * length(texCoordCentered));
732
- float rot = pow(2.0, 4.0 + ring);
733
-
734
- float deformRed = cos(rot * radians + (2.0 / 3.0 * M_PI));
735
- float deformGreen = cos(rot * radians);
736
- float deformBlue = cos(rot * radians + (4.0 / 3.0 * M_PI));
737
-
738
- return clamp(vec3(
739
- intensity + (deformRed * DeformAmount),
740
- intensity + (deformGreen * DeformAmount),
741
- intensity + (deformBlue * DeformAmount)
742
- ), 0.0, 1.0);
743
- }
744
-
745
- void main() {
746
- vec3 colorSource = texture2D(tex, texCoord).rgb;
747
- vec3 lightWhiteVector = getWhiteVector(getLightIntensity(texCoord));
748
- vec3 colorLight = LightColor * lightWhiteVector;
749
- vec3 colorReflection = texture2D(tex, texCoord - ReflectionDistance).rgb;
750
- vec3 colorResult = (
751
- colorSource +
752
- (colorLight * LightIntensity) +
753
- (colorReflection * ReflectionBrightness)
754
- );
755
- gl_FragColor = vec4(
756
- colorResult,
757
- 1.0
758
- );
759
- }
760
- /**
761
- * This shader imitates the GameBoy Color subpixel
762
- * arrangement.
763
- */
764
-
765
- varying vec2 texCoord;
766
- uniform sampler2D tex;
767
- uniform vec2 texSize;
768
-
769
- /**
770
- * Adds a base color to everything.
771
- * Lower values make black colors darker.
772
- * Higher values make black colors lighter.
773
- * You'll normally want each of these numbers to be close
774
- * to 0, and not normally higher than 1.
775
- */
776
- uniform vec3 BaseColor;
777
-
778
- /**
779
- * Modifies the contrast or saturation of the image.
780
- * Lower values make the image more gray and higher values
781
- * make it more colorful.
782
- * A value of 1 represents a normal, baseline level of
783
- * contrast.
784
- * You'll normally want this to be somewhere around 1.
785
- */
786
- uniform float SourceContrast;
787
-
788
- /**
789
- * Modifies the luminosity of the image.
790
- * Lower values make the image darker and higher values make
791
- * it lighter.
792
- * A value of 1 represents normal, baseline luminosity.
793
- * You'll normally want this to be somewhere around 1.
794
- */
795
- uniform float SourceLuminosity;
796
-
797
- /**
798
- * Lower values look more like a sharp, unshaded image.
799
- * Higher values look more like an LCD display with subpixels.
800
- * You'll normally want this to be a number from 0 to 1.
801
- */
802
- uniform float SubpixelBlendAmount;
803
-
804
- /**
805
- * Lower values make subpixels darker.
806
- * Higher values make them lighter and over-bright.
807
- * A value of 1 represents a normal, baseline gamma value.
808
- * You'll normally want this to be somewhere around 1.
809
- */
810
- uniform float SubpixelGamma;
811
-
812
- /**
813
- * Higher values allow subpixels to be more blended-together
814
- * and brighter.
815
- * Lower values keep subpixel colors more separated.
816
- * You'll normally want this to be a number from 0 to 1.
817
- */
818
- uniform float SubpixelColorBleed;
819
-
820
- /**
821
- * Determines the distance between subpixels.
822
- * Lower values put the red, green, and blue subpixels
823
- * within a single pixel closer together.
824
- * Higher values put them farther apart.
825
- * You'll normally want this to be a number from 0 to 1.
826
- */
827
- uniform float SubpixelSpread;
828
-
829
- /**
830
- * Determines the vertical offset of subpixels within
831
- * a pixel.
832
- * Lower values put the red, green, and blue subpixels
833
- * within a single pixel higher up.
834
- * Higher values put them further down.
835
- * You'll normally want this to be a number from 0 to 1.
836
- */
837
- uniform float SubpixelVerticalOffset;
838
-
839
- /**
840
- * Lower values make the subpixels horizontally thinner,
841
- * and higher values make them thicker.
842
- * You'll normally want this to be a number from 0 to 1.
843
- */
844
- uniform float SubpixelLightWidth;
845
-
846
- /**
847
- * Lower values make the subpixels vertically taller,
848
- * and higher values make them shorter.
849
- * You'll normally want this to be a number from 0 to 1.
850
- */
851
- uniform float SubpixelLightHeight;
852
-
853
- /**
854
- * Lower values make the subpixels sharper and more
855
- * individually distinct.
856
- * Higher values add an increasingly intense glowing
857
- * effect around each subpixel.
858
- * You'll normally want this to be a number from 0 to 1.
859
- */
860
- uniform float SubpixelLightGlow;
861
-
862
- /**
863
- * Scale the size of pixels up or down.
864
- * Useful for looking at larger than 8x8 subpixel sizes.
865
- * You'll normally want this number to be exactly 1,
866
- * meaning that every group of 3 subpixels corresponds
867
- * to one pixel in the display.
868
- */
869
- uniform float SubpixelScale;
870
-
871
- /**
872
- * GBC subpixels are roughly rectangular shaped, but
873
- * with a rectangular gap in the lower-right corner.
874
- * Lower values make the lower-right gap in each GBC
875
- * subpixel less distinct. A value of 0 results in no
876
- * gap being shown at all.
877
- * Higher values make the gap more distinct.
878
- * You'll normally want this to be a number from 0 to 1.
879
- */
880
- uniform float SubpixelTabHeight;
881
-
882
- /**
883
- * The following three uniforms decide the base colors
884
- * of each of the subpixels.
885
- *
886
- * Default subpixel colors are based on this resource:
887
- * https://gbcc.dev/technology/
888
- * R: #FF7145 (1.00, 0.44, 0.27)
889
- * G: #C1D650 (0.75, 0.84, 0.31)
890
- * B: #3BCEFF (0.23, 0.81, 1.00)
891
- */
892
- uniform vec3 SubpixelColorRed; // vec3(1.00, 0.38, 0.22);
893
- uniform vec3 SubpixelColorGreen; // vec3(0.60, 0.88, 0.30);
894
- uniform vec3 SubpixelColorBlue; // vec3(0.23, 0.65, 1.00);
895
-
896
- const vec3 ONE = vec3(1.0, 1.0, 1.0);
897
-
898
- /**
899
- * Helper to get luminosity of an RGB color.
900
- * Used with HCL color space related code.
901
- */
902
- float getColorLumosity(in vec3 rgb) {
903
- return (
904
- (rgb.r * (5.0 / 16.0)) +
905
- (rgb.g * (9.0 / 16.0)) +
906
- (rgb.b * (2.0 / 16.0))
907
- );
908
- }
909
-
910
- /**
911
- * Helper to convert RGB color to HCL. (Hue, Chroma, Luma)
912
- */
913
- vec3 convertRgbToHcl(in vec3 rgb) {
914
- float xMin = min(rgb.r, min(rgb.g, rgb.b));
915
- float xMax = max(rgb.r, max(rgb.g, rgb.b));
916
- float c = xMax - xMin;
917
- float l = getColorLumosity(rgb);
918
-
919
- float h = mod((
920
- c == 0.0 ? 0.0 :
921
- xMax == rgb.r ? ((rgb.g - rgb.b) / c) :
922
- xMax == rgb.g ? ((rgb.b - rgb.r) / c) + 2.0 :
923
- xMax == rgb.b ? ((rgb.r - rgb.g) / c) + 4.0 :
924
- 0.0
925
- ), 6.0);
926
-
927
- return vec3(h, c, l);
928
- }
929
-
930
- /**
931
- * Helper to convert HCL color to RGB. (Hue, Chroma, Luma)
932
- */
933
- vec3 convertHclToRgb(in vec3 hcl) {
934
- vec3 rgb;
935
- float h = mod(hcl.x, 6.0);
936
- float c = hcl.y;
937
- float l = hcl.z;
938
- float x = c * (1.0 - abs(mod(h, 2.0) - 1.0));
939
-
940
- if (h <= 1.0) {
941
- rgb = vec3(c, x, 0.0);
942
- } else if (h <= 2.0) {
943
- rgb = vec3(x, c, 0.0);
944
- } else if (h <= 3.0) {
945
- rgb = vec3(0.0, c, x);
946
- } else if (h <= 4.0) {
947
- rgb = vec3(0.0, x, c);
948
- } else if (h <= 5.0) {
949
- rgb = vec3(x, 0.0, c);
950
- } else {
951
- rgb = vec3(c, 0.0, x);
952
- }
953
-
954
- float lRgb = getColorLumosity(rgb);
955
- float m = l - lRgb;
956
-
957
- return clamp(vec3(m, m, m) + rgb, 0.0, 1.0);
958
- }
959
-
960
- /**
961
- * Helper to check if a point is contained within
962
- * a rectangular area.
963
- */
964
- bool getPointInRect(vec2 point, vec2 rectTopLeft, vec2 rectBottomRight) {
965
- return (
966
- point.x >= rectTopLeft.x &&
967
- point.y >= rectTopLeft.y &&
968
- point.x <= rectBottomRight.x &&
969
- point.y <= rectBottomRight.y
970
- );
971
- }
972
-
973
- /**
974
- * Helper to get the nearest offset vector from a
975
- * point to a line segment.
976
- * (The length of this offset vector is the nearest
977
- * distance from the point to the line segment.)
978
- * Thank you to https://stackoverflow.com/a/1501725
979
- */
980
- vec2 getPointLineDistance(vec2 point, vec2 line0, vec2 line1) {
981
- vec2 lineDelta = line0 - line1;
982
- float lineLengthSq = dot(lineDelta, lineDelta);
983
- if (lineLengthSq <= 0.0) {
984
- return line0 - point;
985
- }
986
- float t = dot(point - line0, line1 - line0) / lineLengthSq;
987
- vec2 projection = line0 + clamp(t, 0.0, 1.0) * (line1 - line0);
988
- return projection - point;
989
- }
990
-
991
- /**
992
- * Helper to get the nearest offset vector from a
993
- * point to a rectangle.
994
- * Returns (0, 0) for points within the rectangle.
995
- */
996
- vec2 getPointRectDistance(vec2 point, vec2 rectTopLeft, vec2 rectBottomRight) {
997
- if (getPointInRect(point, rectTopLeft, rectBottomRight)) {
998
- return vec2(0.0, 0.0);
999
- }
1000
-
1001
- vec2 rectTopRight = vec2(rectBottomRight.x, rectTopLeft.y);
1002
- vec2 rectBottomLeft = vec2(rectTopLeft.x, rectBottomRight.y);
1003
-
1004
- vec2 v0 = getPointLineDistance(point, rectTopLeft, rectTopRight);
1005
- vec2 v1 = getPointLineDistance(point, rectBottomLeft, rectBottomRight);
1006
- vec2 v2 = getPointLineDistance(point, rectTopLeft, rectBottomLeft);
1007
- vec2 v3 = getPointLineDistance(point, rectTopRight, rectBottomRight);
1008
-
1009
- float v0LengthSq = dot(v0, v0);
1010
- float v1LengthSq = dot(v1, v1);
1011
- float v2LengthSq = dot(v2, v2);
1012
- float v3LengthSq = dot(v3, v3);
1013
-
1014
- float minLengthSq = min(min(v0LengthSq, v1LengthSq), min(v2LengthSq, v3LengthSq));
1015
-
1016
- if (minLengthSq == v0LengthSq) return v0;
1017
- if (minLengthSq == v1LengthSq) return v1;
1018
- if (minLengthSq == v2LengthSq) return v2;
1019
- return v3;
1020
- }
1021
-
1022
- /**
1023
- * Helper to get the nearest offset vector from a
1024
- * point to a subpixel.
1025
- * GBC subpixels are roughly rectangular in shape,
1026
- * but have a rectangular gap in their bottom-left
1027
- * corner.
1028
- * Returns (0, 0) for points within the subpixel.
1029
- */
1030
- vec2 getPointSubpixelDistance(vec2 point, vec2 subpixelCenter, vec2 subpixelSizeHalf) {
1031
- float rectLeft = subpixelCenter.x - subpixelSizeHalf.x;
1032
- float rectRight = subpixelCenter.x + subpixelSizeHalf.x;
1033
- float rectTop = subpixelCenter.y - subpixelSizeHalf.y;
1034
- float rectBottom = subpixelCenter.y + subpixelSizeHalf.y;
1035
-
1036
- vec2 offsetLeft = getPointRectDistance(
1037
- point,
1038
- vec2(rectLeft, rectTop + SubpixelTabHeight),
1039
- vec2(subpixelCenter.x, rectBottom)
1040
- );
1041
-
1042
- vec2 offsetRight = getPointRectDistance(
1043
- point,
1044
- vec2(subpixelCenter.x, rectTop),
1045
- vec2(rectRight, rectBottom)
1046
- );
1047
-
1048
- float offsetLeftLengthSq = dot(offsetLeft, offsetLeft);
1049
- float offsetRightLengthSq = dot(offsetRight, offsetRight);
1050
-
1051
- return (offsetLeftLengthSq <= offsetRightLengthSq) ? offsetLeft : offsetRight;
1052
- }
1053
-
1054
- /**
1055
- * Helper to get the intensity of light from a
1056
- * subpixel.
1057
- * The pixelPosition argument represents a
1058
- * fragment's position within a pixel.
1059
- * Spread represents the subpixel's horizontal
1060
- * position within the pixel.
1061
- */
1062
- float getSubpixelIntensity(vec2 pixelPosition, float spread) {
1063
- vec2 subpixelCenter = vec2(
1064
- 0.5 + (spread * SubpixelSpread),
1065
- 1.0 - SubpixelVerticalOffset
1066
- );
1067
-
1068
- vec2 subpixelSizeHalf = 0.5 * vec2(SubpixelLightWidth, SubpixelLightHeight);
1069
-
1070
- vec2 offset = getPointSubpixelDistance(pixelPosition, subpixelCenter, subpixelSizeHalf);
1071
-
1072
- if (SubpixelLightGlow <= 0.0) {
1073
- return (dot(offset, offset) <= 0.0) ? 1.0 : 0.0;
1074
- }
1075
-
1076
- float dist = length(offset);
1077
- float glow = max(0.0, 1.0 - (dist / SubpixelLightGlow));
1078
- return glow;
1079
- }
1080
-
1081
- /**
1082
- * Helper to apply SubpixelColorBleed to the intensity
1083
- * value computed for a fragment and subpixel.
1084
- * Subpixel color bleed allows subpixel colors to be
1085
- * more strongly coerced to more accurately represent
1086
- * the underlying pixel color.
1087
- */
1088
- float applySubpixelBleed(float subpixelIntensity, float colorSourceChannel) {
1089
- return subpixelIntensity * (
1090
- SubpixelColorBleed +
1091
- ((1.0 - SubpixelColorBleed) * colorSourceChannel)
1092
- );
1093
- }
1094
-
1095
- void main() {
1096
- // Get base color of the pixel, adjust based on
1097
- // contrast and luminosity settings.
1098
- vec3 colorSource = texture2D(tex, texCoord).rgb;
1099
- vec3 colorSourceHcl = convertRgbToHcl(colorSource);
1100
- vec3 colorSourceAdjusted = convertHclToRgb(vec3(
1101
- colorSourceHcl.x,
1102
- colorSourceHcl.y * SourceContrast,
1103
- colorSourceHcl.z * SourceLuminosity
1104
- ));
1105
- // Determine how much each subpixel's light should
1106
- // affect this fragment.
1107
- vec2 pixelPosition = mod(texCoord * texSize * SubpixelScale, 1.0);
1108
- float subpixelIntensityRed = applySubpixelBleed(
1109
- getSubpixelIntensity(pixelPosition, -1.0),
1110
- colorSourceAdjusted.r
1111
- );
1112
- float subpixelIntensityGreen = applySubpixelBleed(
1113
- getSubpixelIntensity(pixelPosition, 0.0),
1114
- colorSourceAdjusted.g
1115
- );
1116
- float subpixelIntensityBlue = applySubpixelBleed(
1117
- getSubpixelIntensity(pixelPosition, 1.0),
1118
- colorSourceAdjusted.b
1119
- );
1120
- vec3 subpixelLightColor = SubpixelGamma * (
1121
- (subpixelIntensityRed * SubpixelColorRed) +
1122
- (subpixelIntensityGreen * SubpixelColorGreen) +
1123
- (subpixelIntensityBlue * SubpixelColorBlue)
1124
- );
1125
- // Compute final color
1126
- vec3 colorResult = clamp(subpixelLightColor * colorSourceAdjusted, 0.0, 1.0);
1127
-
1128
- vec3 colorResultBlended =
1129
- ((1.0 - SubpixelBlendAmount) * colorSourceAdjusted) +
1130
- (SubpixelBlendAmount * colorResult);
1131
-
1132
- colorResultBlended = BaseColor + (colorResultBlended * (ONE - BaseColor));
1133
-
1134
- gl_FragColor = vec4(colorResultBlended, 1.0);
1135
- }This is free and unencumbered software released into the public domain.
1136
-
1137
- Anyone is free to copy, modify, publish, use, compile, sell, or
1138
- distribute this software, either in source code form or as a compiled
1139
- binary, for any purpose, commercial or non-commercial, and by any
1140
- means.
1141
-
1142
- In jurisdictions that recognize copyright laws, the author or authors
1143
- of this software dedicate any and all copyright interest in the
1144
- software to the public domain. We make this dedication for the benefit
1145
- of the public at large and to the detriment of our heirs and
1146
- successors. We intend this dedication to be an overt act of
1147
- relinquishment in perpetuity of all present and future rights to this
1148
- software under copyright law.
1149
-
1150
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1151
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1152
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1153
- IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
1154
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1155
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1156
- OTHER DEALINGS IN THE SOFTWARE.
1157
-
1158
- For more information, please refer to <http://unlicense.org/>
1159
- [shader]
1160
- name=gbc-lcd
1161
- author=Sophie Kirschner
1162
- description=Imitates the GameBoy Color LCD screen subpixel arrangement, with an optional backlight effect.
1163
- passes=2
1164
-
1165
- [pass.0]
1166
- integerScaling=1
1167
- fragmentShader=gbc-lcd.fs
1168
- blend=1
1169
-
1170
- [pass.1]
1171
- fragmentShader=gbc-lcd-light.fs
1172
-
1173
- [pass.0.uniform.BaseColor]
1174
- type=float3
1175
- default[0]=0.130
1176
- default[1]=0.128
1177
- default[2]=0.101
1178
- readableName=Screen base color
1179
-
1180
- [pass.0.uniform.SubpixelColorRed]
1181
- type=float3
1182
- default[0]=1.00
1183
- default[1]=0.38
1184
- default[2]=0.22
1185
- readableName=Red subpixel color
1186
-
1187
- [pass.0.uniform.SubpixelColorGreen]
1188
- type=float3
1189
- default[0]=0.60
1190
- default[1]=0.88
1191
- default[2]=0.30
1192
- readableName=Green subpixel color
1193
-
1194
- [pass.0.uniform.SubpixelColorBlue]
1195
- type=float3
1196
- default[0]=0.23
1197
- default[1]=0.65
1198
- default[2]=1.00
1199
- readableName=Blue subpixel color
1200
-
1201
- [pass.0.uniform.SourceContrast]
1202
- type=float
1203
- default=0.85
1204
- readableName=Screen contrast
1205
-
1206
- [pass.0.uniform.SourceLuminosity]
1207
- type=float
1208
- default=0.88
1209
- readableName=Screen luminosity
1210
-
1211
- [pass.0.uniform.SubpixelBlendAmount]
1212
- type=float
1213
- default=1.0
1214
- readableName=Subpixel effect amount
1215
-
1216
- [pass.0.uniform.SubpixelColorBleed]
1217
- type=float
1218
- default=0.31
1219
- readableName=Subpixel color bleeding
1220
-
1221
- [pass.0.uniform.SubpixelSpread]
1222
- type=float
1223
- default=0.333
1224
- readableName=Subpixel spread X
1225
-
1226
- [pass.0.uniform.SubpixelVerticalOffset]
1227
- type=float
1228
- default=0.48
1229
- readableName=Subpixel offset Y
1230
-
1231
- [pass.0.uniform.SubpixelGamma]
1232
- type=float
1233
- default=1.040
1234
- readableName=Subpixel brightness
1235
-
1236
- [pass.0.uniform.SubpixelLightWidth]
1237
- type=float
1238
- default=0.220
1239
- readableName=Subpixel width
1240
-
1241
- [pass.0.uniform.SubpixelLightHeight]
1242
- type=float
1243
- default=0.850
1244
- readableName=Subpixel height
1245
-
1246
- [pass.0.uniform.SubpixelLightGlow]
1247
- type=float
1248
- default=0.195
1249
- readableName=Subpixel glow size
1250
-
1251
- [pass.0.uniform.SubpixelTabHeight]
1252
- type=float
1253
- default=0.175
1254
- readableName=Subpixel tab shaping
1255
-
1256
- [pass.0.uniform.SubpixelScale]
1257
- type=float
1258
- default=1.0
1259
- readableName=Subpixel scale
1260
-
1261
- [pass.1.uniform.LightColor]
1262
- type=float3
1263
- default[0]=1.000
1264
- default[1]=0.968
1265
- default[2]=0.882
1266
- readableName=Backlight color
1267
-
1268
- [pass.1.uniform.LightIntensity]
1269
- type=float
1270
- default=0.06
1271
- readableName=Backlight intensity
1272
-
1273
- [pass.1.uniform.LightSoftness]
1274
- type=float
1275
- default=0.67
1276
- readableName=Backlight softness
1277
-
1278
- [pass.1.uniform.ReflectionDistance]
1279
- type=float2
1280
- default[0]=0
1281
- default[1]=0.025
1282
- readableName=Internal reflection distance
1283
-
1284
- [pass.1.uniform.ReflectionBrightness]
1285
- type=float
1286
- default=0.032
1287
- readableName=Internal reflection brightness
1288
- /* MIT License
1289
- *
1290
- * Copyright (c) 2015-2023 Lior Halphon
1291
- *
1292
- * Permission is hereby granted, free of charge, to any person obtaining a copy
1293
- * of this software and associated documentation files (the "Software"), to deal
1294
- * in the Software without restriction, including without limitation the rights
1295
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1296
- * copies of the Software, and to permit persons to whom the Software is
1297
- * furnished to do so, subject to the following conditions:
1298
- *
1299
- * The above copyright notice and this permission notice shall be included in all
1300
- * copies or substantial portions of the Software.
1301
- *
1302
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1303
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1304
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1305
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1306
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1307
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1308
- * SOFTWARE.
1309
- */
1310
- /* Based on this (really good) article: http://blog.pkh.me/p/19-butchering-hqx-scaling-filters.html */
1311
-
1312
- /* The colorspace used by the HQnx filters is not really YUV, despite the algorithm description claims it is. It is
1313
- also not normalized. Therefore, we shall call the colorspace used by HQnx "HQ Colorspace" to avoid confusion. */
1314
-
1315
- varying vec2 texCoord;
1316
- uniform sampler2D tex;
1317
- uniform vec2 texSize;
1318
-
1319
- float _bit(float v, int i)
1320
- {
1321
- // v is an integer value stored as float
1322
- float p = exp2(float(i)); // 2^i, GLSL ES 1.00-friendly
1323
- return floor(mod(floor(v / p), 2.0));
1324
- }
1325
-
1326
- bool _matchMask(float pattern, int mask, int ref)
1327
- {
1328
- // (pattern & mask) == ref, implemented without bitwise ops.
1329
- float m = float(mask);
1330
- float r = float(ref);
1331
- float mism = 0.0;
1332
- for (int i = 0; i < 8; ++i)
1333
- {
1334
- float mb = _bit(m, i);
1335
- if (mb > 0.5)
1336
- {
1337
- float pb = _bit(pattern, i);
1338
- float rb = _bit(r, i);
1339
- mism += abs(pb - rb);
1340
- }
1341
- }
1342
- return mism < 0.5;
1343
- }
1344
-
1345
- vec3 rgb_to_hq_colospace(vec4 rgb)
1346
- {
1347
- return vec3(
1348
- 0.250 * rgb.r + 0.250 * rgb.g + 0.250 * rgb.b,
1349
- 0.250 * rgb.r - 0.000 * rgb.g - 0.250 * rgb.b,
1350
- -0.125 * rgb.r + 0.250 * rgb.g - 0.125 * rgb.b
1351
- );
1352
- }
1353
-
1354
- bool is_different(vec4 a, vec4 b)
1355
- {
1356
- vec3 diff = abs(rgb_to_hq_colospace(a) - rgb_to_hq_colospace(b));
1357
- return diff.x > 0.018 || diff.y > 0.002 || diff.z > 0.005;
1358
- }
1359
-
1360
- // WebGL1: no bitwise ops in GLSL ES 1.00
1361
-
1362
- vec4 interp_2px(vec4 c1, float w1, vec4 c2, float w2)
1363
- {
1364
- return (c1 * w1 + c2 * w2) / (w1 + w2);
1365
- }
1366
-
1367
- vec4 interp_3px(vec4 c1, float w1, vec4 c2, float w2, vec4 c3, float w3)
1368
- {
1369
- return (c1 * w1 + c2 * w2 + c3 * w3) / (w1 + w2 + w3);
1370
- }
1371
-
1372
- vec4 scale(sampler2D image, vec2 position, vec2 input_resolution)
1373
- {
1374
- // o = offset, the width of a pixel
1375
- vec2 o = vec2(1.0, 1.0) / input_resolution;
1376
-
1377
- /* We always calculate the top left pixel. If we need a different pixel, we flip the image */
1378
-
1379
- // p = the position within a pixel [0...1]
1380
- vec2 p = fract(position * input_resolution);
1381
-
1382
- if (p.x > 0.5) o.x = -o.x;
1383
- if (p.y > 0.5) o.y = -o.y;
1384
-
1385
- vec4 w0 = texture2D(image, position + vec2( -o.x, -o.y));
1386
- vec4 w1 = texture2D(image, position + vec2( 0.0, -o.y));
1387
- vec4 w2 = texture2D(image, position + vec2( o.x, -o.y));
1388
- vec4 w3 = texture2D(image, position + vec2( -o.x, 0.0));
1389
- vec4 w4 = texture2D(image, position + vec2( 0.0, 0.0));
1390
- vec4 w5 = texture2D(image, position + vec2( o.x, 0.0));
1391
- vec4 w6 = texture2D(image, position + vec2( -o.x, o.y));
1392
- vec4 w7 = texture2D(image, position + vec2( 0.0, o.y));
1393
- vec4 w8 = texture2D(image, position + vec2( o.x, o.y));
1394
-
1395
- float pattern = 0.0;
1396
- if (is_different(w0, w4)) pattern += 1.0;
1397
- if (is_different(w1, w4)) pattern += 2.0;
1398
- if (is_different(w2, w4)) pattern += 4.0;
1399
- if (is_different(w3, w4)) pattern += 8.0;
1400
- if (is_different(w5, w4)) pattern += 16.0;
1401
- if (is_different(w6, w4)) pattern += 32.0;
1402
- if (is_different(w7, w4)) pattern += 64.0;
1403
- if (is_different(w8, w4)) pattern += 128.0;
1404
-
1405
- // NOTE: hex literals (0x..) are not GLSL ES 1.00. Converted to decimal.
1406
-
1407
- if ((_matchMask(pattern, 191, 55) || _matchMask(pattern, 219, 19)) && is_different(w1, w5))
1408
- {
1409
- return interp_2px(w4, 3.0, w3, 1.0);
1410
- }
1411
- if ((_matchMask(pattern, 219, 73) || _matchMask(pattern, 239, 109)) && is_different(w7, w3))
1412
- {
1413
- return interp_2px(w4, 3.0, w1, 1.0);
1414
- }
1415
- if ((_matchMask(pattern, 11, 11) || _matchMask(pattern, 254, 74) || _matchMask(pattern, 254, 26)) && is_different(w3, w1))
1416
- {
1417
- return w4;
1418
- }
1419
- if ((_matchMask(pattern, 111, 42) || _matchMask(pattern, 91, 10) || _matchMask(pattern, 191, 58) || _matchMask(pattern, 223, 90) ||
1420
- _matchMask(pattern, 159, 138) || _matchMask(pattern, 207, 138) || _matchMask(pattern, 239, 78) || _matchMask(pattern, 63, 14) ||
1421
- _matchMask(pattern, 251, 90) || _matchMask(pattern, 187, 138) || _matchMask(pattern, 127, 90) || _matchMask(pattern, 175, 138) ||
1422
- _matchMask(pattern, 235, 138)) && is_different(w3, w1))
1423
- {
1424
- return interp_2px(w4, 3.0, w0, 1.0);
1425
- }
1426
- if (_matchMask(pattern, 11, 8))
1427
- {
1428
- return interp_3px(w4, 2.0, w0, 1.0, w1, 1.0);
1429
- }
1430
- if (_matchMask(pattern, 11, 2))
1431
- {
1432
- return interp_3px(w4, 2.0, w0, 1.0, w3, 1.0);
1433
- }
1434
- if (_matchMask(pattern, 47, 47))
1435
- {
1436
- return interp_3px(w4, 4.0, w3, 1.0, w1, 1.0);
1437
- }
1438
- if (_matchMask(pattern, 191, 55) || _matchMask(pattern, 219, 19))
1439
- {
1440
- return interp_3px(w4, 5.0, w1, 2.0, w3, 1.0);
1441
- }
1442
- if (_matchMask(pattern, 219, 73) || _matchMask(pattern, 239, 109))
1443
- {
1444
- return interp_3px(w4, 5.0, w3, 2.0, w1, 1.0);
1445
- }
1446
- if (_matchMask(pattern, 27, 3) || _matchMask(pattern, 79, 67) || _matchMask(pattern, 139, 131) || _matchMask(pattern, 107, 67))
1447
- {
1448
- return interp_2px(w4, 3.0, w3, 1.0);
1449
- }
1450
- if (_matchMask(pattern, 75, 9) || _matchMask(pattern, 139, 137) || _matchMask(pattern, 31, 25) || _matchMask(pattern, 59, 25))
1451
- {
1452
- return interp_2px(w4, 3.0, w1, 1.0);
1453
- }
1454
- if (_matchMask(pattern, 126, 42) || _matchMask(pattern, 239, 171) || _matchMask(pattern, 191, 143) || _matchMask(pattern, 126, 14))
1455
- {
1456
- return interp_3px(w4, 2.0, w3, 3.0, w1, 3.0);
1457
- }
1458
- if (_matchMask(pattern, 251, 106) || _matchMask(pattern, 111, 110) || _matchMask(pattern, 63, 62) || _matchMask(pattern, 251, 250) ||
1459
- _matchMask(pattern, 223, 222) || _matchMask(pattern, 223, 30))
1460
- {
1461
- return interp_2px(w4, 3.0, w0, 1.0);
1462
- }
1463
- if (_matchMask(pattern, 10, 0) || _matchMask(pattern, 79, 75) || _matchMask(pattern, 159, 27) || _matchMask(pattern, 47, 11) ||
1464
- _matchMask(pattern, 190, 10) || _matchMask(pattern, 238, 10) || _matchMask(pattern, 126, 10) || _matchMask(pattern, 235, 75) ||
1465
- _matchMask(pattern, 59, 27))
1466
- {
1467
- return interp_3px(w4, 2.0, w3, 1.0, w1, 1.0);
1468
- }
1469
-
1470
- return interp_3px(w4, 6.0, w3, 1.0, w1, 1.0);
1471
- }
1472
-
1473
- void main()
1474
- {
1475
- gl_FragColor = scale(tex, texCoord, texSize);
1476
- }
1477
- [shader]
1478
- name=hq2x
1479
- author=Lior Halphon
1480
- description="High Quality" 2x scaling
1481
- passes=1
1482
-
1483
- [pass.0]
1484
- fragmentShader=hq2x.fs
1485
- blend=0
1486
- width=-2
1487
- height=-2
1488
- /*
1489
- LCD Shader
1490
-
1491
- Copyright (C) 2017 Dominus Iniquitatis - zerosaiko@gmail.com
1492
-
1493
- Permission is hereby granted, free of charge, to any person obtaining a copy
1494
- of this software and associated documentation files (the "Software"), to deal
1495
- in the Software without restriction, including without limitation the rights
1496
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1497
- copies of the Software, and to permit persons to whom the Software is
1498
- furnished to do so, subject to the following conditions:
1499
- The above copyright notice and this permission notice shall be included in
1500
- all copies or substantial portions of the Software.
1501
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1502
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1503
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1504
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1505
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1506
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1507
- THE SOFTWARE.
1508
- */
1509
-
1510
- uniform sampler2D tex;
1511
- uniform vec2 texSize;
1512
- varying vec2 texCoord;
1513
-
1514
- uniform float boundBrightness;
1515
-
1516
- void main()
1517
- {
1518
- vec4 color = texture2D(tex, texCoord);
1519
-
1520
- if (int(mod(texCoord.s * texSize.x * 3.0, 3.0)) == 0 ||
1521
- int(mod(texCoord.t * texSize.y * 3.0, 3.0)) == 0)
1522
- {
1523
- color.rgb *= vec3(1.0, 1.0, 1.0) * boundBrightness;
1524
- }
1525
-
1526
- gl_FragColor = color;
1527
- }
1528
- [shader]
1529
- name=LCD
1530
- author=Dominus Iniquitatis
1531
- description=Simple LCD emulation.
1532
- passes=1
1533
-
1534
- [pass.0]
1535
- fragmentShader=lcd.fs
1536
- blend=1
1537
- width=-3
1538
- height=-3
1539
-
1540
- [pass.0.uniform.boundBrightness]
1541
- type=float
1542
- readableName=Bound brightness
1543
- default=0.9
1544
- min=0.0
1545
- max=1.0
1546
- [shader]
1547
- name=Motion Blur
1548
- author=Dominus Iniquitatis
1549
- description=Simple motion blur.
1550
- passes=1
1551
-
1552
- [pass.0]
1553
- fragmentShader=motion_blur.fs
1554
- blend=1
1555
- width=-1
1556
- height=-1
1557
-
1558
- [pass.0.uniform.amount]
1559
- type=float
1560
- readableName=Amount
1561
- default=0.3
1562
- min=0.0
1563
- max=1.0
1564
- /*
1565
- Motion Blur Shader
1566
-
1567
- Copyright (C) 2017 Dominus Iniquitatis - zerosaiko@gmail.com
1568
-
1569
- Permission is hereby granted, free of charge, to any person obtaining a copy
1570
- of this software and associated documentation files (the "Software"), to deal
1571
- in the Software without restriction, including without limitation the rights
1572
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1573
- copies of the Software, and to permit persons to whom the Software is
1574
- furnished to do so, subject to the following conditions:
1575
- The above copyright notice and this permission notice shall be included in
1576
- all copies or substantial portions of the Software.
1577
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1578
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1579
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1580
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1581
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1582
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1583
- THE SOFTWARE.
1584
- */
1585
-
1586
- uniform sampler2D tex;
1587
- uniform vec2 texSize;
1588
- varying vec2 texCoord;
1589
-
1590
- uniform float amount;
1591
-
1592
- void main()
1593
- {
1594
- vec4 color = texture2D(tex, texCoord);
1595
- color.a = 1.0 - amount;
1596
-
1597
- gl_FragColor = color;
1598
- }
1599
- [shader]
1600
- name=Nintendo DS Color
1601
- author=Pokefan531 and hunterk
1602
- description=Shader that replicates the LCD Colorspace from a Nintendo DS Phat.
1603
- passes=1
1604
-
1605
- [pass.0]
1606
- fragmentShader=nds-color.fs
1607
- vertexShader=nds-color.vs
1608
- blend=1
1609
- width=-1
1610
- height=-1
1611
-
1612
- [pass.0.uniform.color_mode]
1613
- type=int
1614
- default=1
1615
- min=1
1616
- max=3
1617
- readableName=Color Profile (1=sRGB, 2=DCI, 3=Rec2020)
1618
- // Shader that replicates the LCD Colorspace from a Nintendo DS Phat --
1619
- varying vec2 texCoord;
1620
- varying mat4 profile;
1621
- uniform sampler2D tex;
1622
- uniform vec2 texSize;
1623
-
1624
- const float target_gamma = 2.2;
1625
- const float display_gamma = 2.2;
1626
-
1627
- void main() {
1628
- // bring out our stored luminance value
1629
- float lum = profile[3].w;
1630
-
1631
- // our adjustments need to happen in linear gamma
1632
- vec4 screen = pow(texture2D(tex, texCoord), vec4(target_gamma)).rgba;
1633
-
1634
- screen = clamp(screen * lum, 0.0, 1.0);
1635
- screen = profile * screen;
1636
- gl_FragColor = pow(screen, vec4(1.0 / display_gamma));
1637
- }
1638
- uniform int color_mode;
1639
- attribute vec4 position;
1640
- varying vec2 texCoord;
1641
- varying mat4 profile;
1642
-
1643
- const mat4 NDS_sRGB = mat4(
1644
- 0.835, 0.10, 0.105, 0.0, //red channel
1645
- 0.27, 0.6375, 0.175, 0.0, //green channel
1646
- -0.105, 0.2625, 0.72, 0.0, //blue channel
1647
- 0.0, 0.0, 0.0, 0.905 //alpha channel
1648
- );
1649
-
1650
- const mat4 NDS_DCI = mat4(
1651
- 0.70, 0.125, 0.12, 0.0, //red channel
1652
- 0.34, 0.625, 0.20, 0.0, //green channel
1653
- -0.04, 0.25, 0.68, 0.0, //blue channel
1654
- 0.0, 0.0, 0.0, 0.96 //alpha channel
1655
- );
1656
-
1657
- const mat4 NDS_Rec2020 = mat4(
1658
- 0.555, 0.1475, 0.1175, 0.0, //red channel
1659
- 0.39, 0.6075, 0.2075, 0.0, //green channel
1660
- 0.055, 0.245, 0.675, 0.0, //blue channel
1661
- 0.0, 0.0, 0.0, 1.0 //alpha channel
1662
- );
1663
-
1664
- void main() {
1665
- if (color_mode == 1) profile = NDS_sRGB;
1666
- else if (color_mode == 2) profile = NDS_DCI;
1667
- else if (color_mode == 3) profile = NDS_Rec2020;
1668
-
1669
- gl_Position = position;
1670
- texCoord = (position.st + vec2(1.0, 1.0)) * vec2(0.5, 0.5);
1671
- }
1672
- [shader]
1673
- name=NSO GBA Color
1674
- author=Pokefan531 and hunterk
1675
- description=Shader that replicates the Nintendo Switch Online's GBA color filter.
1676
- passes=1
1677
-
1678
- [pass.0]
1679
- fragmentShader=nso-gba-color.fs
1680
- vertexShader=nso-gba-color.vs
1681
- blend=1
1682
- width=-1
1683
- height=-1
1684
-
1685
- [pass.0.uniform.darken_screen]
1686
- type=float
1687
- default=0.8
1688
- min=0
1689
- max=1
1690
- readableName=Darken Screen
1691
-
1692
- [pass.0.uniform.color_mode]
1693
- type=int
1694
- default=1
1695
- min=1
1696
- max=3
1697
- readableName=Color Profile (1=sRGB, 2=DCI, 3=Rec2020)
1698
- // Shader that replicates the LCD Colorspace from Gameboy Advance --
1699
- varying vec2 texCoord;
1700
- varying mat4 profile;
1701
- uniform sampler2D tex;
1702
- uniform vec2 texSize;
1703
-
1704
- uniform float darken_screen;
1705
- const float target_gamma = 2.2;
1706
- const float display_gamma = 2.2;
1707
-
1708
- void main() {
1709
- // bring out our stored luminance value
1710
- float lum = profile[3].w;
1711
-
1712
- // our adjustments need to happen in linear gamma
1713
- vec4 screen = pow(texture2D(tex, texCoord), vec4(target_gamma + darken_screen)).rgba;
1714
-
1715
- screen = clamp(screen * lum, 0.0, 1.0);
1716
- screen = profile * screen;
1717
- gl_FragColor = pow(screen, vec4(1.0 / display_gamma));
1718
- }
1719
- uniform int color_mode;
1720
- attribute vec4 position;
1721
- varying vec2 texCoord;
1722
- varying mat4 profile;
1723
-
1724
- const mat4 GBA_sRGB = mat4(
1725
- 0.865, 0.0575, 0.0575, 0.0, //red channel
1726
- 0.1225, 0.925, 0.1225, 0.0, //green channel
1727
- 0.0125, 0.0125, 0.82, 0.0, //blue channel
1728
- 0.0, 0.0, 0.0, 1.0 //alpha channel
1729
- );
1730
-
1731
- const mat4 GBA_DCI = mat4(
1732
- 0.72, 0.0875, 0.0725, 0.0, //red channel
1733
- 0.2675, 0.9, 0.185, 0.0, //green channel
1734
- 0.0125, 0.0125, 0.7425, 0.0, //blue channel
1735
- 0.0, 0.0, 0.0, 1.0 //alpha channel
1736
- );
1737
-
1738
- const mat4 GBA_Rec2020 = mat4(
1739
- 0.57, 0.115, 0.0725, 0.0, //red channel
1740
- 0.3825, 0.8625, 0.195, 0.0, //green channel
1741
- 0.0475, 0.0225, 0.7325, 0.0, //blue channel
1742
- 0.0, 0.0, 0.0, 1.0 //alpha channel
1743
- );
1744
-
1745
- void main() {
1746
- if (color_mode == 1) profile = GBA_sRGB;
1747
- else if (color_mode == 2) profile = GBA_DCI;
1748
- else if (color_mode == 3) profile = GBA_Rec2020;
1749
-
1750
- gl_Position = position;
1751
- texCoord = (position.st + vec2(1.0, 1.0)) * vec2(0.5, 0.5);
1752
- }
1753
- [shader]
1754
- name=NSO GBC Color
1755
- author=Pokefan531 and hunterk
1756
- description=Shader that replicates the Nintendo Switch Online's GBC color filter.
1757
- passes=1
1758
-
1759
- [pass.0]
1760
- fragmentShader=nso-gbc-color.fs
1761
- vertexShader=nso-gbc-color.vs
1762
- blend=1
1763
- width=-1
1764
- height=-1
1765
-
1766
- [pass.0.uniform.lighten_screen]
1767
- type=float
1768
- default=0.0
1769
- min=0
1770
- max=1
1771
- readableName=Lighten Screen
1772
-
1773
- [pass.0.uniform.color_mode]
1774
- type=int
1775
- default=1
1776
- min=1
1777
- max=3
1778
- readableName=Color Profile (1=sRGB, 2=DCI, 3=Rec2020)
1779
- // Shader that replicates the Nintendo Switch Online's GBC color filter --
1780
- varying vec2 texCoord;
1781
- varying mat4 profile;
1782
- uniform sampler2D tex;
1783
- uniform vec2 texSize;
1784
-
1785
- uniform float lighten_screen;
1786
-
1787
- void main() {
1788
- // bring out our stored luminance value
1789
- float lum = profile[3].w;
1790
-
1791
- // our adjustments need to happen in linear gamma
1792
- vec4 screen = pow(texture2D(tex, texCoord), vec4(1.24, 0.8, 0.7, 1.0)).rgba;
1793
-
1794
- screen = clamp(screen * lum, 0.0, 1.0);
1795
- screen = profile * screen;
1796
- gl_FragColor = pow(screen, vec4(1.0));
1797
- }
1798
- uniform int color_mode;
1799
- attribute vec4 position;
1800
- varying vec2 texCoord;
1801
- varying mat4 profile;
1802
-
1803
- const mat4 GBC_sRGB = mat4(
1804
- 0.84, 0.105, 0.15, 0.0, //red channel
1805
- 0.265, 0.67, 0.30, 0.0, //green channel
1806
- 0.0, 0.24, 0.525, 0.0, //blue channel
1807
- 0.175, 0.18, 0.18, 0.85 //alpha channel
1808
- );
1809
-
1810
- const mat4 GBC_DCI = mat4(
1811
- 0.84, 0.105, 0.15, 0.0, //red channel
1812
- 0.265, 0.67, 0.30, 0.0, //green channel
1813
- 0.0, 0.24, 0.525, 0.0, //blue channel
1814
- 0.175, 0.18, 0.18, 1.0 //alpha channel
1815
- );
1816
-
1817
- const mat4 GBC_Rec2020 = mat4(
1818
- 0.84, 0.105, 0.15, 0.0, //red channel
1819
- 0.265, 0.67, 0.30, 0.0, //green channel
1820
- 0.0, 0.24, 0.525, 0.0, //blue channel
1821
- 0.175, 0.18, 0.18, 1.0 //alpha channel
1822
- );
1823
-
1824
- void main() {
1825
- if (color_mode == 1) profile = GBC_sRGB;
1826
- else if (color_mode == 2) profile = GBC_DCI;
1827
- else if (color_mode == 3) profile = GBC_Rec2020;
1828
-
1829
- gl_Position = position;
1830
- texCoord = (position.st + vec2(1.0, 1.0)) * vec2(0.5, 0.5);
1831
- }
1832
- [shader]
1833
- name=OmniScale
1834
- author=Lior Halphon
1835
- description=Resolution-indepedent scaler inspired by the hqx family scalers
1836
- passes=1
1837
-
1838
- [pass.0]
1839
- fragmentShader=omniscale.fs
1840
- blend=0
1841
- /* MIT License
1842
- *
1843
- * Copyright (c) 2015-2023 Lior Halphon
1844
- *
1845
- * Permission is hereby granted, free of charge, to any person obtaining a copy
1846
- * of this software and associated documentation files (the "Software"), to deal
1847
- * in the Software without restriction, including without limitation the rights
1848
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1849
- * copies of the Software, and to permit persons to whom the Software is
1850
- * furnished to do so, subject to the following conditions:
1851
- *
1852
- * The above copyright notice and this permission notice shall be included in all
1853
- * copies or substantial portions of the Software.
1854
- *
1855
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1856
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1857
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1858
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1859
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1860
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1861
- * SOFTWARE.
1862
- */
1863
- /* OmniScale is derived from the pattern based design of HQnx, but with the following general differences:
1864
- - The actual output calculating was completely redesigned as resolution independent graphic generator. This allows
1865
- scaling to any factor.
1866
- - HQnx approximations that were good enough for a 2x/3x/4x factor were refined, creating smoother gradients.
1867
- - "Quarters" can be interpolated in more ways than in the HQnx filters
1868
- - If a pattern does not provide enough information to determine the suitable scaling interpolation, up to 16 pixels
1869
- per quarter are sampled (in contrast to the usual 9) in order to determine the best interpolation.
1870
- */
1871
-
1872
- varying vec2 texCoord;
1873
- uniform sampler2D tex;
1874
- uniform vec2 texSize;
1875
- uniform vec2 outputSize;
1876
-
1877
- float _bit(float v, int i)
1878
- {
1879
- // v is an integer value stored as float
1880
- float p = exp2(float(i)); // 2^i, GLSL ES 1.00-friendly
1881
- return floor(mod(floor(v / p), 2.0));
1882
- }
1883
-
1884
- bool _matchMask(float pattern, int mask, int ref)
1885
- {
1886
- // (pattern & mask) == ref, implemented without bitwise ops.
1887
- float m = float(mask);
1888
- float r = float(ref);
1889
- float mism = 0.0;
1890
- for (int i = 0; i < 15; ++i)
1891
- {
1892
- float mb = _bit(m, i);
1893
- if (mb > 0.5)
1894
- {
1895
- float pb = _bit(pattern, i);
1896
- float rb = _bit(r, i);
1897
- mism += abs(pb - rb);
1898
- }
1899
- }
1900
- return mism < 0.5;
1901
- }
1902
-
1903
- /* We use the same colorspace as the HQ algorithms. */
1904
- vec3 rgb_to_hq_colospace(vec4 rgb)
1905
- {
1906
- return vec3(
1907
- 0.250 * rgb.r + 0.250 * rgb.g + 0.250 * rgb.b,
1908
- 0.250 * rgb.r - 0.000 * rgb.g - 0.250 * rgb.b,
1909
- -0.125 * rgb.r + 0.250 * rgb.g - 0.125 * rgb.b
1910
- );
1911
- }
1912
-
1913
- bool is_different(vec4 a, vec4 b)
1914
- {
1915
- vec3 diff = abs(rgb_to_hq_colospace(a) - rgb_to_hq_colospace(b));
1916
- return diff.x > 0.018 || diff.y > 0.002 || diff.z > 0.005;
1917
- }
1918
-
1919
- // WebGL1: no bitwise ops in GLSL ES 1.00
1920
-
1921
- vec4 scale(sampler2D image, vec2 position, vec2 input_resolution, vec2 output_resolution)
1922
- {
1923
- // o = offset, the width of a pixel
1924
- vec2 o = vec2(1.0, 1.0) / input_resolution;
1925
-
1926
- /* We always calculate the top left quarter. If we need a different quarter, we flip our co-ordinates */
1927
-
1928
- // p = the position within a pixel [0...1]
1929
- vec2 p = fract(position * input_resolution);
1930
-
1931
- if (p.x > 0.5)
1932
- {
1933
- o.x = -o.x;
1934
- p.x = 1.0 - p.x;
1935
- }
1936
- if (p.y > 0.5)
1937
- {
1938
- o.y = -o.y;
1939
- p.y = 1.0 - p.y;
1940
- }
1941
-
1942
- vec4 w0 = texture2D(image, position + vec2(-o.x, -o.y));
1943
- vec4 w1 = texture2D(image, position + vec2( 0.0, -o.y));
1944
- vec4 w2 = texture2D(image, position + vec2( o.x, -o.y));
1945
- vec4 w3 = texture2D(image, position + vec2(-o.x, 0.0));
1946
- vec4 w4 = texture2D(image, position + vec2( 0.0, 0.0));
1947
- vec4 w5 = texture2D(image, position + vec2( o.x, 0.0));
1948
- vec4 w6 = texture2D(image, position + vec2(-o.x, o.y));
1949
- vec4 w7 = texture2D(image, position + vec2( 0.0, o.y));
1950
- vec4 w8 = texture2D(image, position + vec2( o.x, o.y));
1951
-
1952
- float pattern = 0.0;
1953
- if (is_different(w0, w4)) pattern += 1.0;
1954
- if (is_different(w1, w4)) pattern += 2.0;
1955
- if (is_different(w2, w4)) pattern += 4.0;
1956
- if (is_different(w3, w4)) pattern += 8.0;
1957
- if (is_different(w5, w4)) pattern += 16.0;
1958
- if (is_different(w6, w4)) pattern += 32.0;
1959
- if (is_different(w7, w4)) pattern += 64.0;
1960
- if (is_different(w8, w4)) pattern += 128.0;
1961
-
1962
- // NOTE: hex literals (0x..) are not GLSL ES 1.00. Converted to decimal.
1963
-
1964
- if ((_matchMask(pattern, 191, 55) || _matchMask(pattern, 219, 19)) && is_different(w1, w5))
1965
- {
1966
- return mix(w4, w3, 0.5 - p.x);
1967
- }
1968
- if ((_matchMask(pattern, 219, 73) || _matchMask(pattern, 239, 109)) && is_different(w7, w3))
1969
- {
1970
- return mix(w4, w1, 0.5 - p.y);
1971
- }
1972
- if ((_matchMask(pattern, 11, 11) || _matchMask(pattern, 254, 74) || _matchMask(pattern, 254, 26)) && is_different(w3, w1))
1973
- {
1974
- return w4;
1975
- }
1976
- if ((_matchMask(pattern, 111, 42) || _matchMask(pattern, 91, 10) || _matchMask(pattern, 191, 58) || _matchMask(pattern, 223, 90) ||
1977
- _matchMask(pattern, 159, 138) || _matchMask(pattern, 207, 138) || _matchMask(pattern, 239, 78) || _matchMask(pattern, 63, 14) ||
1978
- _matchMask(pattern, 251, 90) || _matchMask(pattern, 187, 138) || _matchMask(pattern, 127, 90) || _matchMask(pattern, 175, 138) ||
1979
- _matchMask(pattern, 235, 138)) && is_different(w3, w1))
1980
- {
1981
- return mix(w4, mix(w4, w0, 0.5 - p.x), 0.5 - p.y);
1982
- }
1983
- if (_matchMask(pattern, 11, 8))
1984
- {
1985
- return mix(mix(w0 * 0.375 + w1 * 0.25 + w4 * 0.375, w4 * 0.5 + w1 * 0.5, p.x * 2.0), w4, p.y * 2.0);
1986
- }
1987
- if (_matchMask(pattern, 11, 2))
1988
- {
1989
- return mix(mix(w0 * 0.375 + w3 * 0.25 + w4 * 0.375, w4 * 0.5 + w3 * 0.5, p.y * 2.0), w4, p.x * 2.0);
1990
- }
1991
- if (_matchMask(pattern, 47, 47))
1992
- {
1993
- float dist = length(p - vec2(0.5));
1994
- float pixel_size = length(1.0 / (output_resolution / input_resolution));
1995
- if (dist < 0.5 - pixel_size / 2.0)
1996
- {
1997
- return w4;
1998
- }
1999
- vec4 r;
2000
- if (is_different(w0, w1) || is_different(w0, w3))
2001
- {
2002
- r = mix(w1, w3, p.y - p.x + 0.5);
2003
- }
2004
- else
2005
- {
2006
- r = mix(mix(w1 * 0.375 + w0 * 0.25 + w3 * 0.375, w3, p.y * 2.0), w1, p.x * 2.0);
2007
- }
2008
-
2009
- if (dist > 0.5 + pixel_size / 2.0)
2010
- {
2011
- return r;
2012
- }
2013
- return mix(w4, r, (dist - 0.5 + pixel_size / 2.0) / pixel_size);
2014
- }
2015
- if (_matchMask(pattern, 191, 55) || _matchMask(pattern, 219, 19))
2016
- {
2017
- float dist = p.x - 2.0 * p.y;
2018
- float pixel_size = length(1.0 / (output_resolution / input_resolution)) * sqrt(5.0);
2019
- if (dist > pixel_size / 2.0)
2020
- {
2021
- return w1;
2022
- }
2023
- vec4 r = mix(w3, w4, p.x + 0.5);
2024
- if (dist < -pixel_size / 2.0)
2025
- {
2026
- return r;
2027
- }
2028
- return mix(r, w1, (dist + pixel_size / 2.0) / pixel_size);
2029
- }
2030
- if (_matchMask(pattern, 219, 73) || _matchMask(pattern, 239, 109))
2031
- {
2032
- float dist = p.y - 2.0 * p.x;
2033
- float pixel_size = length(1.0 / (output_resolution / input_resolution)) * sqrt(5.0);
2034
- if (dist > pixel_size / 2.0)
2035
- {
2036
- return w3;
2037
- }
2038
- vec4 r = mix(w1, w4, p.x + 0.5);
2039
- if (dist < -pixel_size / 2.0)
2040
- {
2041
- return r;
2042
- }
2043
- return mix(r, w3, (dist + pixel_size / 2.0) / pixel_size);
2044
- }
2045
- if (_matchMask(pattern, 191, 143) || _matchMask(pattern, 126, 14))
2046
- {
2047
- float dist = p.x + 2.0 * p.y;
2048
- float pixel_size = length(1.0 / (output_resolution / input_resolution)) * sqrt(5.0);
2049
-
2050
- if (dist > 1.0 + pixel_size / 2.0)
2051
- {
2052
- return w4;
2053
- }
2054
-
2055
- vec4 r;
2056
- if (is_different(w0, w1) || is_different(w0, w3))
2057
- {
2058
- r = mix(w1, w3, p.y - p.x + 0.5);
2059
- }
2060
- else
2061
- {
2062
- r = mix(mix(w1 * 0.375 + w0 * 0.25 + w3 * 0.375, w3, p.y * 2.0), w1, p.x * 2.0);
2063
- }
2064
-
2065
- if (dist < 1.0 - pixel_size / 2.0)
2066
- {
2067
- return r;
2068
- }
2069
-
2070
- return mix(r, w4, (dist + pixel_size / 2.0 - 1.0) / pixel_size);
2071
- }
2072
-
2073
- if (_matchMask(pattern, 126, 42) || _matchMask(pattern, 239, 171))
2074
- {
2075
- float dist = p.y + 2.0 * p.x;
2076
- float pixel_size = length(1.0 / (output_resolution / input_resolution)) * sqrt(5.0);
2077
-
2078
- if (dist > 1.0 + pixel_size / 2.0)
2079
- {
2080
- return w4;
2081
- }
2082
-
2083
- vec4 r;
2084
-
2085
- if (is_different(w0, w1) || is_different(w0, w3))
2086
- {
2087
- r = mix(w1, w3, p.y - p.x + 0.5);
2088
- }
2089
- else
2090
- {
2091
- r = mix(mix(w1 * 0.375 + w0 * 0.25 + w3 * 0.375, w3, p.y * 2.0), w1, p.x * 2.0);
2092
- }
2093
-
2094
- if (dist < 1.0 - pixel_size / 2.0)
2095
- {
2096
- return r;
2097
- }
2098
-
2099
- return mix(r, w4, (dist + pixel_size / 2.0 - 1.0) / pixel_size);
2100
- }
2101
-
2102
- if (_matchMask(pattern, 27, 3) || _matchMask(pattern, 79, 67) || _matchMask(pattern, 139, 131) || _matchMask(pattern, 107, 67))
2103
- {
2104
- return mix(w4, w3, 0.5 - p.x);
2105
- }
2106
-
2107
- if (_matchMask(pattern, 75, 9) || _matchMask(pattern, 139, 137) || _matchMask(pattern, 31, 25) || _matchMask(pattern, 59, 25))
2108
- {
2109
- return mix(w4, w1, 0.5 - p.y);
2110
- }
2111
-
2112
- if (_matchMask(pattern, 251, 106) || _matchMask(pattern, 111, 110) || _matchMask(pattern, 63, 62) || _matchMask(pattern, 251, 250) ||
2113
- _matchMask(pattern, 223, 222) || _matchMask(pattern, 223, 30))
2114
- {
2115
- return mix(w4, w0, (1.0 - p.x - p.y) / 2.0);
2116
- }
2117
-
2118
- if (_matchMask(pattern, 79, 75) || _matchMask(pattern, 159, 27) || _matchMask(pattern, 47, 11) ||
2119
- _matchMask(pattern, 190, 10) || _matchMask(pattern, 238, 10) || _matchMask(pattern, 126, 10) || _matchMask(pattern, 235, 75) ||
2120
- _matchMask(pattern, 59, 27))
2121
- {
2122
- float dist = p.x + p.y;
2123
- float pixel_size = length(1.0 / (output_resolution / input_resolution));
2124
-
2125
- if (dist > 0.5 + pixel_size / 2.0)
2126
- {
2127
- return w4;
2128
- }
2129
-
2130
- vec4 r;
2131
- if (is_different(w0, w1) || is_different(w0, w3))
2132
- {
2133
- r = mix(w1, w3, p.y - p.x + 0.5);
2134
- }
2135
- else
2136
- {
2137
- r = mix(mix(w1 * 0.375 + w0 * 0.25 + w3 * 0.375, w3, p.y * 2.0), w1, p.x * 2.0);
2138
- }
2139
-
2140
- if (dist < 0.5 - pixel_size / 2.0)
2141
- {
2142
- return r;
2143
- }
2144
-
2145
- return mix(r, w4, (dist + pixel_size / 2.0 - 0.5) / pixel_size);
2146
- }
2147
-
2148
- if (_matchMask(pattern, 11, 1))
2149
- {
2150
- return mix(mix(w4, w3, 0.5 - p.x), mix(w1, (w1 + w3) / 2.0, 0.5 - p.x), 0.5 - p.y);
2151
- }
2152
-
2153
- if (_matchMask(pattern, 11, 0))
2154
- {
2155
- return mix(mix(w4, w3, 0.5 - p.x), mix(w1, w0, 0.5 - p.x), 0.5 - p.y);
2156
- }
2157
-
2158
- float dist = p.x + p.y;
2159
- float pixel_size = length(1.0 / (output_resolution / input_resolution));
2160
-
2161
- if (dist > 0.5 + pixel_size / 2.0)
2162
- {
2163
- return w4;
2164
- }
2165
-
2166
- /* We need more samples to "solve" this diagonal */
2167
- vec4 x0 = texture2D(image, position + vec2(-o.x * 2.0, -o.y * 2.0));
2168
- vec4 x1 = texture2D(image, position + vec2(-o.x , -o.y * 2.0));
2169
- vec4 x2 = texture2D(image, position + vec2( 0.0 , -o.y * 2.0));
2170
- vec4 x3 = texture2D(image, position + vec2( o.x , -o.y * 2.0));
2171
- vec4 x4 = texture2D(image, position + vec2(-o.x * 2.0, -o.y ));
2172
- vec4 x5 = texture2D(image, position + vec2(-o.x * 2.0, 0.0 ));
2173
- vec4 x6 = texture2D(image, position + vec2(-o.x * 2.0, o.y ));
2174
-
2175
- if (is_different(x0, w4)) pattern += exp2(8.0);
2176
- if (is_different(x1, w4)) pattern += exp2(9.0);
2177
- if (is_different(x2, w4)) pattern += exp2(10.0);
2178
- if (is_different(x3, w4)) pattern += exp2(11.0);
2179
- if (is_different(x4, w4)) pattern += exp2(12.0);
2180
- if (is_different(x5, w4)) pattern += exp2(13.0);
2181
- if (is_different(x6, w4)) pattern += exp2(14.0);
2182
-
2183
- float diagonal_bias = -7.0;
2184
- for (int i = 0; i < 15; ++i)
2185
- {
2186
- diagonal_bias += _bit(pattern, i);
2187
- }
2188
-
2189
- if (diagonal_bias <= 0.0)
2190
- {
2191
- vec4 r = mix(w1, w3, p.y - p.x + 0.5);
2192
- if (dist < 0.5 - pixel_size / 2.0)
2193
- {
2194
- return r;
2195
- }
2196
- return mix(r, w4, (dist + pixel_size / 2.0 - 0.5) / pixel_size);
2197
- }
2198
-
2199
- return w4;
2200
- }
2201
-
2202
- void main()
2203
- {
2204
- gl_FragColor = scale(tex, texCoord, texSize, outputSize);
2205
- }
2206
- [shader]
2207
- name=Pixelate
2208
- author=endrift
2209
- description=Only scale up the screen at an integer ratio
2210
- passes=1
2211
-
2212
- [pass.0]
2213
- blend=1
2214
- integerScaling=1
2215
- [shader]
2216
- name=Scale2x
2217
- author=singron
2218
- description=AdvanceMAME's Scale2x algorithm
2219
- passes=1
2220
-
2221
- [pass.0]
2222
- fragmentShader=scale2x.fs
2223
- blend=1
2224
- width=-2
2225
- height=-2
2226
- /* Shader implementation of Scale2x is adapted from https://gist.github.com/singron/3161079 */
2227
- varying vec2 texCoord;
2228
- uniform sampler2D tex;
2229
- uniform vec2 texSize;
2230
-
2231
- void main() {
2232
- // o = offset, the width of a pixel
2233
- vec2 o = 1.0 / texSize;
2234
-
2235
- // texel arrangement
2236
- // A B C
2237
- // D E F
2238
- // G H I
2239
- vec4 B = texture2D(tex, texCoord + vec2( 0.0, o.y));
2240
- vec4 D = texture2D(tex, texCoord + vec2( -o.x, 0.0));
2241
- vec4 E = texture2D(tex, texCoord + vec2( 0.0, 0.0));
2242
- vec4 F = texture2D(tex, texCoord + vec2( o.x, 0.0));
2243
- vec4 H = texture2D(tex, texCoord + vec2( 0.0, -o.y));
2244
- vec2 p = texCoord * texSize;
2245
- // p = the texCoord within a pixel [0...1]
2246
- p = fract(p);
2247
- if (p.x > .5) {
2248
- if (p.y > .5) {
2249
- // Top Right
2250
- gl_FragColor = B == F && B != D && F != H ? F : E;
2251
- } else {
2252
- // Bottom Right
2253
- gl_FragColor = H == F && D != H && B != F ? F : E;
2254
- }
2255
- } else {
2256
- if (p.y > .5) {
2257
- // Top Left
2258
- gl_FragColor = D == B && B != F && D != H ? D : E;
2259
- } else {
2260
- // Bottom Left
2261
- gl_FragColor = D == H && D != B && H != F ? D : E;
2262
- }
2263
- }
2264
- }
2265
- [shader]
2266
- name=Scale4x
2267
- author=singron, endrift
2268
- description=AdvanceMAME's Scale4x algorithm
2269
- passes=1
2270
-
2271
- [pass.0]
2272
- fragmentShader=scale4x.fs
2273
- blend=1
2274
- width=-4
2275
- height=-4
2276
- /* Shader implementation of Scale2x is adapted from https://gist.github.com/singron/3161079 */
2277
- varying vec2 texCoord;
2278
- uniform sampler2D tex;
2279
- uniform vec2 texSize;
2280
-
2281
- vec4 scale2x(vec4 pixels[5], vec2 p) {
2282
- // texel arrangement
2283
- // x 0 x
2284
- // 1 2 3
2285
- // x 4 x
2286
- // p = the texCoord within a pixel [0...1]
2287
- p = fract(p);
2288
- if (p.x > .5) {
2289
- if (p.y > .5) {
2290
- // Top Right
2291
- return pixels[0] == pixels[3] && pixels[0] != pixels[1] && pixels[3] != pixels[4] ? pixels[3] : pixels[2];
2292
- } else {
2293
- // Bottom Right
2294
- return pixels[4] == pixels[3] && pixels[1] != pixels[4] && pixels[0] != pixels[3] ? pixels[3] : pixels[2];
2295
- }
2296
- } else {
2297
- if (p.y > .5) {
2298
- // Top Left
2299
- return pixels[1] == pixels[0] && pixels[0] != pixels[3] && pixels[1] != pixels[4] ? pixels[1] : pixels[2];
2300
- } else {
2301
- // Bottom Left
2302
- return pixels[1] == pixels[4] && pixels[1] != pixels[0] && pixels[4] != pixels[3] ? pixels[1] : pixels[2];
2303
- }
2304
- }
2305
- }
2306
-
2307
- vec4 scaleNeighborhood(vec2 p, vec2 x, vec2 o) {
2308
- vec4 neighborhood[5];
2309
- neighborhood[0] = texture2D(tex, texCoord + x + vec2( 0.0, o.y));
2310
- neighborhood[1] = texture2D(tex, texCoord + x + vec2(-o.x, 0.0));
2311
- neighborhood[2] = texture2D(tex, texCoord + x + vec2( 0.0, 0.0));
2312
- neighborhood[3] = texture2D(tex, texCoord + x + vec2( o.x, 0.0));
2313
- neighborhood[4] = texture2D(tex, texCoord + x + vec2( 0.0, -o.y));
2314
- return scale2x(neighborhood, p + x * texSize);
2315
- }
2316
-
2317
- void main() {
2318
- // o = offset, the width of a pixel
2319
- vec2 o = 1.0 / texSize;
2320
-
2321
- vec2 p = texCoord * texSize;
2322
- vec4 pixels[5];
2323
- pixels[0] = scaleNeighborhood(p, vec2( 0.0, o.y / 2.0), o);
2324
- pixels[1] = scaleNeighborhood(p, vec2(-o.x / 2.0, 0.0), o);
2325
- pixels[2] = scaleNeighborhood(p, vec2( 0.0, 0.0), o);
2326
- pixels[3] = scaleNeighborhood(p, vec2( o.x / 2.0, 0.0), o);
2327
- pixels[4] = scaleNeighborhood(p, vec2( 0.0, -o.y / 2.0), o);
2328
- gl_FragColor = scale2x(pixels, p * 2.0);
2329
- }
2330
- [shader]
2331
- name=Scanlines
2332
- author=Dominus Iniquitatis
2333
- description=Simple scanlines.
2334
- passes=1
2335
-
2336
- [pass.0]
2337
- fragmentShader=scanlines.fs
2338
- blend=1
2339
- width=-2
2340
- height=-2
2341
-
2342
- [pass.0.uniform.lineBrightness]
2343
- type=float
2344
- readableName=Line brightness
2345
- default=0.5
2346
- min=0.0
2347
- max=1.0
2348
- /*
2349
- Scanlines Shader
2350
-
2351
- Copyright (C) 2017 Dominus Iniquitatis - zerosaiko@gmail.com
2352
-
2353
- Permission is hereby granted, free of charge, to any person obtaining a copy
2354
- of this software and associated documentation files (the "Software"), to deal
2355
- in the Software without restriction, including without limitation the rights
2356
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2357
- copies of the Software, and to permit persons to whom the Software is
2358
- furnished to do so, subject to the following conditions:
2359
- The above copyright notice and this permission notice shall be included in
2360
- all copies or substantial portions of the Software.
2361
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2362
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2363
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2364
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2365
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2366
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2367
- THE SOFTWARE.
2368
- */
2369
-
2370
- uniform sampler2D tex;
2371
- uniform vec2 texSize;
2372
- varying vec2 texCoord;
2373
-
2374
- uniform float lineBrightness;
2375
-
2376
- void main() {
2377
- vec4 color = texture2D(tex, texCoord);
2378
-
2379
- // Compute the Y coordinate in pixel space
2380
- float y = texCoord.y * texSize.y;
2381
-
2382
- // Use floor and mod to get even/odd row
2383
- if (mod(floor(y), 2.0) < 1.0) {
2384
- color.rgb *= lineBrightness;
2385
- }
2386
-
2387
- gl_FragColor = color;
2388
- }
2389
- [shader]
2390
- name=Soften
2391
- author=Dominus Iniquitatis
2392
- description=Soft image blurring.
2393
- passes=1
2394
-
2395
- [pass.0]
2396
- fragmentShader=soften.fs
2397
- blend=1
2398
- width=-1
2399
- height=-1
2400
-
2401
- [pass.0.uniform.amount]
2402
- type=float
2403
- readableName=Amount
2404
- default=0.5
2405
- min=0.0
2406
- max=1.0
2407
- /*
2408
- Soften Shader
2409
-
2410
- Copyright (C) 2017 Dominus Iniquitatis - zerosaiko@gmail.com
2411
-
2412
- Permission is hereby granted, free of charge, to any person obtaining a copy
2413
- of this software and associated documentation files (the "Software"), to deal
2414
- in the Software without restriction, including without limitation the rights
2415
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2416
- copies of the Software, and to permit persons to whom the Software is
2417
- furnished to do so, subject to the following conditions:
2418
- The above copyright notice and this permission notice shall be included in
2419
- all copies or substantial portions of the Software.
2420
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2421
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2422
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2423
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2424
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2425
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2426
- THE SOFTWARE.
2427
- */
2428
-
2429
- uniform sampler2D tex;
2430
- uniform vec2 texSize;
2431
- varying vec2 texCoord;
2432
-
2433
- uniform float amount;
2434
-
2435
- vec2 GetTexelSize()
2436
- {
2437
- return vec2(1.0 / texSize.x, 1.0 / texSize.y);
2438
- }
2439
-
2440
- void main()
2441
- {
2442
- vec4 color = texture2D(tex, texCoord);
2443
-
2444
- vec4 northColor = texture2D(tex, texCoord + vec2(0.0, GetTexelSize().y));
2445
- vec4 southColor = texture2D(tex, texCoord - vec2(0.0, GetTexelSize().y));
2446
- vec4 eastColor = texture2D(tex, texCoord + vec2(GetTexelSize().x, 0.0));
2447
- vec4 westColor = texture2D(tex, texCoord - vec2(GetTexelSize().x, 0.0));
2448
-
2449
- if (abs(length(color) - length(northColor)) > 0.0)
2450
- {
2451
- color = mix(color, northColor, amount / 4.0);
2452
- }
2453
-
2454
- if (abs(length(color) - length(southColor)) > 0.0)
2455
- {
2456
- color = mix(color, southColor, amount / 4.0);
2457
- }
2458
-
2459
- if (abs(length(color) - length(eastColor)) > 0.0)
2460
- {
2461
- color = mix(color, eastColor, amount / 4.0);
2462
- }
2463
-
2464
- if (abs(length(color) - length(westColor)) > 0.0)
2465
- {
2466
- color = mix(color, westColor, amount / 4.0);
2467
- }
2468
-
2469
- gl_FragColor = color;
2470
- }
2471
- [shader]
2472
- name=GBA SP 101 Color
2473
- author=Pokefan531 and hunterk
2474
- description=Shader that replicates the LCD Colorspace from a Gameboy SP 101 (backlit version).
2475
- passes=1
2476
-
2477
- [pass.0]
2478
- fragmentShader=sp101-color.fs
2479
- vertexShader=sp101-color.vs
2480
- blend=1
2481
- width=-1
2482
- height=-1
2483
-
2484
- [pass.0.uniform.color_mode]
2485
- type=int
2486
- default=1
2487
- min=1
2488
- max=3
2489
- readableName=Color Profile (1=sRGB, 2=DCI, 3=Rec2020)
2490
- // Shader that replicates the LCD Colorspace from a Gameboy SP 101 (backlit version) --
2491
- varying vec2 texCoord;
2492
- varying mat4 profile;
2493
- uniform sampler2D tex;
2494
- uniform vec2 texSize;
2495
-
2496
- const float target_gamma = 2.2;
2497
- const float display_gamma = 2.2;
2498
-
2499
- void main() {
2500
- // bring out our stored luminance value
2501
- float lum = profile[3].w;
2502
-
2503
- // our adjustments need to happen in linear gamma
2504
- vec4 screen = pow(texture2D(tex, texCoord), vec4(target_gamma)).rgba;
2505
-
2506
- screen = clamp(screen * lum, 0.0, 1.0);
2507
- screen = profile * screen;
2508
- gl_FragColor = pow(screen, vec4(1.0 / display_gamma));
2509
- }
2510
- uniform int color_mode;
2511
- attribute vec4 position;
2512
- varying vec2 texCoord;
2513
- varying mat4 profile;
2514
-
2515
- const mat4 SP1_sRGB = mat4(
2516
- 0.96, 0.0325, 0.001, 0.0, //red channel
2517
- 0.11, 0.89, -0.03, 0.0, //green channel
2518
- -0.07, 0.0775, 1.029, 0.0, //blue channel
2519
- 0.0, 0.0, 0.0, 0.935 //alpha channel
2520
- );
2521
-
2522
- const mat4 SP1_DCI = mat4(
2523
- 0.805, 0.0675, 0.017, 0.0, //red channel
2524
- 0.24, 0.86, 0.02, 0.0, //green channel
2525
- -0.045, 0.0725, 0.963, 0.0, //blue channel
2526
- 0.0, 0.0, 0.0, 0.955 //alpha channel
2527
- );
2528
-
2529
- const mat4 SP1_Rec2020 = mat4(
2530
- 0.625, 0.10, 0.015, 0.0, //red channel
2531
- 0.35, 0.82, 0.0325, 0.0, //green channel
2532
- 0.025, 0.08, 0.9525, 0.0, //blue channel
2533
- 0.0, 0.0, 0.0, 1.0 //alpha channel
2534
- );
2535
-
2536
- void main() {
2537
- if (color_mode == 1) profile = SP1_sRGB;
2538
- else if (color_mode == 2) profile = SP1_DCI;
2539
- else if (color_mode == 3) profile = SP1_Rec2020;
2540
-
2541
- gl_Position = position;
2542
- texCoord = (position.st + vec2(1.0, 1.0)) * vec2(0.5, 0.5);
2543
- }
2544
- [shader]
2545
- name=TV Mode
2546
- author=Dominus Iniquitatis
2547
- description=Scanlines along with a subtle blurring.
2548
- passes=1
2549
-
2550
- [pass.0]
2551
- fragmentShader=tv.fs
2552
- blend=1
2553
- width=-2
2554
- height=-2
2555
-
2556
- [pass.0.uniform.lineBrightness]
2557
- type=float
2558
- readableName=Line brightness
2559
- default=0.75
2560
- min=0.0
2561
- max=1.0
2562
-
2563
- [pass.0.uniform.blurring]
2564
- type=float
2565
- readableName=Blurring
2566
- default=1.0
2567
- min=0.0
2568
- max=1.0
2569
- /*
2570
- TV Mode Shader
2571
-
2572
- Copyright (C) 2022 Dominus Iniquitatis - zerosaiko@gmail.com
2573
-
2574
- Permission is hereby granted, free of charge, to any person obtaining a copy
2575
- of this software and associated documentation files (the "Software"), to deal
2576
- in the Software without restriction, including without limitation the rights
2577
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2578
- copies of the Software, and to permit persons to whom the Software is
2579
- furnished to do so, subject to the following conditions:
2580
- The above copyright notice and this permission notice shall be included in
2581
- all copies or substantial portions of the Software.
2582
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2583
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2584
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2585
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2586
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2587
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2588
- THE SOFTWARE.
2589
- */
2590
-
2591
- uniform sampler2D tex;
2592
- uniform vec2 texSize;
2593
- varying vec2 texCoord;
2594
-
2595
- uniform float lineBrightness;
2596
- uniform float blurring;
2597
-
2598
- void main()
2599
- {
2600
- vec4 c = texture2D(tex, texCoord);
2601
- vec4 n = texture2D(tex, texCoord + vec2(1.0 / texSize.x * 0.5, 0.0));
2602
-
2603
- vec4 color = mix(c, (c + n) / 2.0, blurring);
2604
- color.a = c.a;
2605
-
2606
- if (int(mod(texCoord.t * texSize.y * 2.0, 2.0)) == 0)
2607
- {
2608
- color.rgb *= lineBrightness;
2609
- }
2610
-
2611
- gl_FragColor = color;
2612
- }
2613
- [shader]
2614
- name=VBA Pixelate
2615
- author=Dominus Iniquitatis
2616
- description=VisualBoyAdvance-style pixelation.
2617
- passes=1
2618
-
2619
- [pass.0]
2620
- fragmentShader=vba_pixelate.fs
2621
- blend=1
2622
- width=-2
2623
- height=-2
2624
-
2625
- [pass.0.uniform.boundBrightness]
2626
- type=float
2627
- readableName=Bound brightness
2628
- default=0.5
2629
- min=0.0
2630
- max=1.0
2631
- /*
2632
- VBA Pixelate Shader
2633
-
2634
- Copyright (C) 2017 Dominus Iniquitatis - zerosaiko@gmail.com
2635
-
2636
- Permission is hereby granted, free of charge, to any person obtaining a copy
2637
- of this software and associated documentation files (the "Software"), to deal
2638
- in the Software without restriction, including without limitation the rights
2639
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2640
- copies of the Software, and to permit persons to whom the Software is
2641
- furnished to do so, subject to the following conditions:
2642
- The above copyright notice and this permission notice shall be included in
2643
- all copies or substantial portions of the Software.
2644
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2645
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2646
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2647
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2648
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2649
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2650
- THE SOFTWARE.
2651
- */
2652
-
2653
- uniform sampler2D tex;
2654
- uniform vec2 texSize;
2655
- varying vec2 texCoord;
2656
-
2657
- uniform float boundBrightness;
2658
-
2659
- void main()
2660
- {
2661
- vec4 color = texture2D(tex, texCoord);
2662
-
2663
- float x = floor(texCoord.s * texSize.x);
2664
- float y = floor(texCoord.t * texSize.y);
2665
-
2666
- bool onVerticalLine = mod(x, 2.0) == 0.0;
2667
- bool onHorizontalLine = mod(y, 2.0) == 0.0;
2668
-
2669
- if (onVerticalLine || onHorizontalLine)
2670
- {
2671
- color.rgb *= boundBrightness;
2672
- }
2673
-
2674
- gl_FragColor = color;
2675
- }[shader]
2676
- name=Vignette
2677
- author=Dominus Iniquitatis
2678
- description=Configurable vignette effect.
2679
- passes=1
2680
-
2681
- [pass.0]
2682
- fragmentShader=vignette.fs
2683
- blend=1
2684
- width=-1
2685
- height=-1
2686
-
2687
- [pass.0.uniform.intensity]
2688
- type=float
2689
- readableName=Intensity
2690
- default=1.0
2691
- min=0.0
2692
- max=1.0
2693
- /*
2694
- Vignette Shader
2695
-
2696
- Copyright (C) 2017 Dominus Iniquitatis - zerosaiko@gmail.com
2697
-
2698
- Permission is hereby granted, free of charge, to any person obtaining a copy
2699
- of this software and associated documentation files (the "Software"), to deal
2700
- in the Software without restriction, including without limitation the rights
2701
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2702
- copies of the Software, and to permit persons to whom the Software is
2703
- furnished to do so, subject to the following conditions:
2704
- The above copyright notice and this permission notice shall be included in
2705
- all copies or substantial portions of the Software.
2706
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2707
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2708
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2709
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2710
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2711
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2712
- THE SOFTWARE.
2713
- */
2714
-
2715
- uniform sampler2D tex;
2716
- uniform vec2 texSize;
2717
- varying vec2 texCoord;
2718
-
2719
- uniform float intensity;
2720
-
2721
- void main()
2722
- {
2723
- vec4 color = texture2D(tex, texCoord);
2724
- color = mix(color, vec4(0.0, 0.0, 0.0, 1.0), length(texCoord - 0.5) * intensity);
2725
-
2726
- gl_FragColor = color;
2727
- }
2728
- [shader]
2729
- name=Wii U
2730
- author=Prof. 9
2731
- description=Uses the color palette from the Wii U Virtual Console. Enable bilinear filtering to further mimic Wii U output.
2732
- passes=1
2733
-
2734
- [pass.0]
2735
- fragmentShader=wiiu.fs
2736
- blend=1
2737
- width=-4
2738
- height=-4
2739
- varying vec2 texCoord;
2740
- uniform sampler2D tex;
2741
- uniform vec2 texSize;
2742
-
2743
- float wiiuLut31(float x) {
2744
- int i = int(floor(x * 31.0 + 0.5));
2745
-
2746
- if (i < 0) i = 0;
2747
- if (i > 31) i = 31;
2748
-
2749
- if (i == 0) return 0.0 / 255.0;
2750
- if (i == 1) return 6.0 / 255.0;
2751
- if (i == 2) return 12.0 / 255.0;
2752
- if (i == 3) return 18.0 / 255.0;
2753
- if (i == 4) return 24.0 / 255.0;
2754
- if (i == 5) return 31.0 / 255.0;
2755
- if (i == 6) return 37.0 / 255.0;
2756
- if (i == 7) return 43.0 / 255.0;
2757
- if (i == 8) return 49.0 / 255.0;
2758
- if (i == 9) return 55.0 / 255.0;
2759
- if (i == 10) return 61.0 / 255.0;
2760
- if (i == 11) return 67.0 / 255.0;
2761
- if (i == 12) return 73.0 / 255.0;
2762
- if (i == 13) return 79.0 / 255.0;
2763
- if (i == 14) return 86.0 / 255.0;
2764
- if (i == 15) return 92.0 / 255.0;
2765
- if (i == 16) return 98.0 / 255.0;
2766
- if (i == 17) return 104.0 / 255.0;
2767
- if (i == 18) return 111.0 / 255.0;
2768
- if (i == 19) return 117.0 / 255.0;
2769
- if (i == 20) return 123.0 / 255.0;
2770
- if (i == 21) return 129.0 / 255.0;
2771
- if (i == 22) return 135.0 / 255.0;
2772
- if (i == 23) return 141.0 / 255.0;
2773
- if (i == 24) return 148.0 / 255.0;
2774
- if (i == 25) return 154.0 / 255.0;
2775
- if (i == 26) return 159.0 / 255.0;
2776
- if (i == 27) return 166.0 / 255.0;
2777
- if (i == 28) return 172.0 / 255.0;
2778
- if (i == 29) return 178.0 / 255.0;
2779
- if (i == 30) return 184.0 / 255.0;
2780
- // i == 31
2781
- return 191.0 / 255.0;
2782
- }
2783
-
2784
- void main() {
2785
- vec4 color = texture2D(tex, texCoord);
2786
-
2787
- color.r = wiiuLut31(color.r);
2788
- color.g = wiiuLut31(color.g);
2789
- color.b = wiiuLut31(color.b);
2790
-
2791
- gl_FragColor = color;
2792
- }
2793
- [shader]
2794
- name=xBR-lv2
2795
- author=Hyllian
2796
- description=xBR-lv2 upsampling filter
2797
- passes=1
2798
-
2799
- [pass.0]
2800
- integerScaling=1
2801
- vertexShader=xbr.vs
2802
- fragmentShader=xbr.fs
2803
-
2804
- [pass.0.uniform.XBR_Y_WEIGHT]
2805
- type=float
2806
- default=48
2807
- readableName=Y Weight
2808
- min=0
2809
- max=100
2810
-
2811
- [pass.0.uniform.XBR_EQ_THRESHOLD]
2812
- type=float
2813
- readableName=Eq Threshold
2814
- default=25.0
2815
- min=0.0
2816
- max=50.0
2817
-
2818
- [pass.0.uniform.XBR_SCALE]
2819
- type=float
2820
- readableName=xBR Scale
2821
- default=4.0
2822
- min=1.0
2823
- max=5.0
2824
-
2825
- [pass.0.uniform.XBR_LV2_COEFFICIENT]
2826
- type=float
2827
- readableName=Lv2 Coefficient
2828
- default=2.0
2829
- min=1.0
2830
- max=3.0
2831
- /*
2832
- Hyllian's xBR-lv2 Shader
2833
-
2834
- Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com
2835
-
2836
- Permission is hereby granted, free of charge, to any person obtaining a copy
2837
- of this software and associated documentation files (the "Software"), to deal
2838
- in the Software without restriction, including without limitation the rights
2839
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2840
- copies of the Software, and to permit persons to whom the Software is
2841
- furnished to do so, subject to the following conditions:
2842
-
2843
- The above copyright notice and this permission notice shall be included in
2844
- all copies or substantial portions of the Software.
2845
-
2846
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2847
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2848
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2849
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2850
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2851
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2852
- THE SOFTWARE.
2853
-
2854
-
2855
- Incorporates some of the ideas from SABR shader. Thanks to Joshua Street.
2856
- */
2857
-
2858
- uniform float XBR_Y_WEIGHT;
2859
- uniform float XBR_EQ_THRESHOLD;
2860
- uniform float XBR_SCALE;
2861
- uniform float XBR_LV2_COEFFICIENT;
2862
-
2863
- uniform sampler2D tex;
2864
- uniform vec2 texSize;
2865
-
2866
- varying vec2 texCoord;
2867
- varying vec4 TEX1;
2868
- varying vec4 TEX2;
2869
- varying vec4 TEX3;
2870
- varying vec4 TEX4;
2871
- varying vec4 TEX5;
2872
- varying vec4 TEX6;
2873
- varying vec4 TEX7;
2874
-
2875
- const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
2876
- const vec4 Bo = vec4( 1.0, 1.0, -1.0, -1.0 );
2877
- const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
2878
- const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
2879
- const vec4 Bx = vec4( 0.5, 2.0, -0.5, -2.0 );
2880
- const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
2881
- const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
2882
- const vec4 By = vec4( 2.0, 0.5, -2.0, -0.5 );
2883
- const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
2884
- const vec4 Ci = vec4( 0.25, 0.25, 0.25, 0.25 );
2885
-
2886
- const vec3 Y = vec3(0.2126, 0.7152, 0.0722);
2887
-
2888
- vec4 df4(vec4 A, vec4 B) {
2889
- return abs(A - B);
2890
- }
2891
-
2892
- float c_df(vec3 c1, vec3 c2) {
2893
- vec3 d = abs(c1 - c2);
2894
- return d.r + d.g + d.b;
2895
- }
2896
-
2897
- bvec4 eq4(vec4 A, vec4 B) {
2898
- return lessThan(df4(A, B), vec4(XBR_EQ_THRESHOLD));
2899
- }
2900
-
2901
- bvec4 and4(bvec4 A, bvec4 B) {
2902
- return bvec4(A.x && B.x, A.y && B.y, A.z && B.z, A.w && B.w);
2903
- }
2904
-
2905
- bvec4 nand4(bvec4 A, bvec4 B) {
2906
- return bvec4(!(A.x && B.x), !(A.y && B.y), !(A.z && B.z), !(A.w && B.w));
2907
- }
2908
-
2909
- vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h) {
2910
- return (df4(a,b) + df4(a,c) + df4(d,e) + df4(d,f) + 4.0 * df4(g,h));
2911
- }
2912
-
2913
- float lum(vec3 rgb) {
2914
- return dot(rgb, Y) * XBR_Y_WEIGHT;
2915
- }
2916
-
2917
- void main() {
2918
- // fractional position inside the source pixel (in source-pixel space)
2919
- vec2 fp = fract(texCoord * texSize);
2920
-
2921
- // Sample neighborhood
2922
- vec3 A1 = texture2D(tex, TEX1.xw).rgb;
2923
- vec3 B1 = texture2D(tex, TEX1.yw).rgb;
2924
- vec3 C1 = texture2D(tex, TEX1.zw).rgb;
2925
-
2926
- vec3 A = texture2D(tex, TEX2.xw).rgb;
2927
- vec3 B = texture2D(tex, TEX2.yw).rgb;
2928
- vec3 C = texture2D(tex, TEX2.zw).rgb;
2929
-
2930
- vec3 D = texture2D(tex, TEX3.xw).rgb;
2931
- vec3 E = texture2D(tex, TEX3.yw).rgb;
2932
- vec3 F = texture2D(tex, TEX3.zw).rgb;
2933
-
2934
- vec3 G = texture2D(tex, TEX4.xw).rgb;
2935
- vec3 H = texture2D(tex, TEX4.yw).rgb;
2936
- vec3 I = texture2D(tex, TEX4.zw).rgb;
2937
-
2938
- vec3 G5 = texture2D(tex, TEX5.xw).rgb;
2939
- vec3 H5 = texture2D(tex, TEX5.yw).rgb;
2940
- vec3 I5 = texture2D(tex, TEX5.zw).rgb;
2941
-
2942
- vec3 A0 = texture2D(tex, TEX6.xy).rgb;
2943
- vec3 D0 = texture2D(tex, TEX6.xz).rgb;
2944
- vec3 G0 = texture2D(tex, TEX6.xw).rgb;
2945
-
2946
- vec3 C4 = texture2D(tex, TEX7.xy).rgb;
2947
- vec3 F4 = texture2D(tex, TEX7.xz).rgb;
2948
- vec3 I4 = texture2D(tex, TEX7.xw).rgb;
2949
-
2950
- // Replace mat4x3/transpose with explicit luma packing (GLSL ES 1.00 safe)
2951
- vec4 b = vec4(lum(B), lum(D), lum(H), lum(F));
2952
- vec4 c = vec4(lum(C), lum(A), lum(G), lum(I));
2953
- vec4 e = vec4(lum(E), lum(E), lum(E), lum(E));
2954
- vec4 d = b.yzwx;
2955
- vec4 f = b.wxyz;
2956
- vec4 g = c.zwxy;
2957
- vec4 h = b.zwxy;
2958
- vec4 i = c.wxyz;
2959
-
2960
- vec4 i4v = vec4(lum(I4), lum(C1), lum(A0), lum(G5));
2961
- vec4 i5v = vec4(lum(I5), lum(C4), lum(A1), lum(G0));
2962
- vec4 h5v = vec4(lum(H5), lum(F4), lum(B1), lum(D0));
2963
- vec4 f4v = h5v.yzwx;
2964
-
2965
- // Edge detection math
2966
- vec4 fx = (Ao * fp.y + Bo * fp.x);
2967
- vec4 fx_left = (Ax * fp.y + Bx * fp.x);
2968
- vec4 fx_up = (Ay * fp.y + By * fp.x);
2969
-
2970
- bvec4 interp_restriction_lv0 = and4(notEqual(e, f), notEqual(e, h));
2971
- bvec4 interp_restriction_lv1 = interp_restriction_lv0;
2972
-
2973
- bvec4 interp_restriction_lv2_left = and4(notEqual(e, g), notEqual(d, g));
2974
- bvec4 interp_restriction_lv2_up = and4(notEqual(e, c), notEqual(b, c));
2975
-
2976
- vec4 delta = vec4(1.0 / XBR_SCALE);
2977
- vec4 deltaL = vec4(0.5 / XBR_SCALE, 1.0 / XBR_SCALE, 0.5 / XBR_SCALE, 1.0 / XBR_SCALE);
2978
- vec4 deltaU = deltaL.yxwz;
2979
-
2980
- vec4 fx45i = clamp((fx + delta - Co - Ci) / (2.0 * delta ), 0.0, 1.0);
2981
- vec4 fx45 = clamp((fx + delta - Co ) / (2.0 * delta ), 0.0, 1.0);
2982
- vec4 fx30 = clamp((fx_left + deltaL - Co ) / (2.0 * deltaL), 0.0, 1.0);
2983
- vec4 fx60 = clamp((fx_up + deltaU - Co ) / (2.0 * deltaU), 0.0, 1.0);
2984
-
2985
- vec4 wd1 = weighted_distance(e, c, g, i, h5v, f4v, h, f);
2986
- vec4 wd2 = weighted_distance(h, d, i5v, f, i4v, b, e, i);
2987
-
2988
- bvec4 edri = and4(lessThanEqual(wd1, wd2), interp_restriction_lv0);
2989
- bvec4 edr = and4(lessThan(wd1, wd2), interp_restriction_lv1);
2990
-
2991
- bvec4 edr_left = and4(
2992
- lessThanEqual((XBR_LV2_COEFFICIENT * df4(f, g)), df4(h, c)),
2993
- interp_restriction_lv2_left
2994
- );
2995
- bvec4 edr_up = and4(
2996
- greaterThanEqual(df4(f, g), (XBR_LV2_COEFFICIENT * df4(h, c))),
2997
- interp_restriction_lv2_up
2998
- );
2999
-
3000
- edr = and4(edr, nand4(edri.yzwx, edri.wxyz));
3001
- edr_left = and4(and4(edr_left, edr), eq4(e, c));
3002
- edr_up = and4(and4(edr_up, edr), eq4(e, g));
3003
-
3004
- fx45 *= vec4(edr);
3005
- fx30 *= vec4(edr_left);
3006
- fx60 *= vec4(edr_up);
3007
- fx45i *= vec4(edri);
3008
-
3009
- vec4 px = vec4(lessThanEqual(df4(e, f), df4(e, h)));
3010
-
3011
- vec4 maximos = max(max(fx30, fx60), max(fx45, fx45i));
3012
-
3013
- vec3 res1 = E;
3014
- res1 = mix(res1, mix(H, F, px.x), maximos.x);
3015
- res1 = mix(res1, mix(B, D, px.z), maximos.z);
3016
-
3017
- vec3 res2 = E;
3018
- res2 = mix(res1, mix(F, B, px.y), maximos.y);
3019
- res2 = mix(res1, mix(D, H, px.w), maximos.w);
3020
-
3021
- vec3 res = mix(res1, res2, step(c_df(E, res1), c_df(E, res2)));
3022
-
3023
- gl_FragColor = vec4(res, 1.0);
3024
- }/*
3025
- Hyllian's xBR-lv3 Shader
3026
-
3027
- Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com
3028
-
3029
- Permission is hereby granted, free of charge, to any person obtaining a copy
3030
- of this software and associated documentation files (the "Software"), to deal
3031
- in the Software without restriction, including without limitation the rights
3032
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3033
- copies of the Software, and to permit persons to whom the Software is
3034
- furnished to do so, subject to the following conditions:
3035
-
3036
- The above copyright notice and this permission notice shall be included in
3037
- all copies or substantial portions of the Software.
3038
-
3039
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3040
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3041
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3042
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3043
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3044
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3045
- THE SOFTWARE.
3046
-
3047
- Incorporates some of the ideas from SABR shader. Thanks to Joshua Street.
3048
- */
3049
-
3050
- attribute vec4 position;
3051
-
3052
- uniform vec2 texSize;
3053
-
3054
- varying vec2 texCoord;
3055
- varying vec4 TEX1;
3056
- varying vec4 TEX2;
3057
- varying vec4 TEX3;
3058
- varying vec4 TEX4;
3059
- varying vec4 TEX5;
3060
- varying vec4 TEX6;
3061
- varying vec4 TEX7;
3062
-
3063
- void main() {
3064
- gl_Position = position;
3065
-
3066
- vec2 ps = vec2(1.0) / texSize;
3067
- float dx = ps.x;
3068
- float dy = ps.y;
3069
-
3070
- // A1 B1 C1
3071
- // A0 A B C C4
3072
- // D0 D E F F4
3073
- // G0 G H I I4
3074
- // G5 H5 I5
3075
-
3076
- texCoord = (position.st + vec2(1.0, 1.0)) * vec2(0.5, 0.5);
3077
-
3078
- // IMPORTANT: use 0.0 (float literal) for strict GLSL ES 1.00 compilers
3079
- TEX1 = texCoord.xxxy + vec4(-dx, 0.0, dx, -2.0 * dy); // A1 B1 C1
3080
- TEX2 = texCoord.xxxy + vec4(-dx, 0.0, dx, -1.0 * dy); // A B C
3081
- TEX3 = texCoord.xxxy + vec4(-dx, 0.0, dx, 0.0 ); // D E F
3082
- TEX4 = texCoord.xxxy + vec4(-dx, 0.0, dx, 1.0 * dy); // G H I
3083
- TEX5 = texCoord.xxxy + vec4(-dx, 0.0, dx, 2.0 * dy); // G5 H5 I5
3084
- TEX6 = texCoord.xyyy + vec4(-2.0 * dx, -dy, 0.0, dy); // A0 D0 G0
3085
- TEX7 = texCoord.xyyy + vec4( 2.0 * dx, -dy, 0.0, dy); // C4 F4 I4
3086
- }[shader]
3087
- name=xBR-lv3
3088
- author=Hyllian
3089
- description=xBR-lv3 upsampling filter
3090
- passes=1
3091
-
3092
- [pass.0]
3093
- integerScaling=1
3094
- vertexShader=xbr.vs
3095
- fragmentShader=xbr.fs
3096
-
3097
- [pass.0.uniform.XBR_Y_WEIGHT]
3098
- type=float
3099
- default=48
3100
- readableName=Y Weight
3101
- min=0
3102
- max=100
3103
-
3104
- [pass.0.uniform.XBR_EQ_THRESHOLD]
3105
- type=float
3106
- readableName=Eq Threshold
3107
- default=10.0
3108
- min=0.0
3109
- max=50.0
3110
-
3111
- [pass.0.uniform.XBR_EQ_THRESHOLD2]
3112
- type=float
3113
- readableName=Eq Threshold2
3114
- default=2.0
3115
- min=0.0
3116
- max=4.0
3117
-
3118
- [pass.0.uniform.XBR_LV2_COEFFICIENT]
3119
- type=float
3120
- readableName=Lv2 Coefficient
3121
- default=2.0
3122
- min=1.0
3123
- max=3.0
3124
- /*
3125
- Hyllian's xBR-lv3 Shader
3126
-
3127
- Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com
3128
-
3129
- Permission is hereby granted, free of charge, to any person obtaining a copy
3130
- of this software and associated documentation files (the "Software"), to deal
3131
- in the Software without restriction, including without limitation the rights
3132
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3133
- copies of the Software, and to permit persons to whom the Software is
3134
- furnished to do so, subject to the following conditions:
3135
-
3136
- The above copyright notice and this permission notice shall be included in
3137
- all copies or substantial portions of the Software.
3138
-
3139
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3140
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3141
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3142
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3143
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3144
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3145
- THE SOFTWARE.
3146
-
3147
-
3148
- Incorporates some of the ideas from SABR shader. Thanks to Joshua Street.
3149
- */
3150
-
3151
- uniform float XBR_Y_WEIGHT;
3152
- uniform float XBR_EQ_THRESHOLD;
3153
- uniform float XBR_EQ_THRESHOLD2;
3154
- uniform float XBR_LV2_COEFFICIENT;
3155
-
3156
- uniform sampler2D tex;
3157
- uniform vec2 texSize;
3158
-
3159
- varying vec2 texCoord;
3160
- varying vec4 TEX1;
3161
- varying vec4 TEX2;
3162
- varying vec4 TEX3;
3163
- varying vec4 TEX4;
3164
- varying vec4 TEX5;
3165
- varying vec4 TEX6;
3166
- varying vec4 TEX7;
3167
-
3168
- const mat3 yuv = mat3(
3169
- 0.299, 0.587, 0.114,
3170
- -0.169, -0.331, 0.499,
3171
- 0.499, -0.418, -0.0813
3172
- );
3173
-
3174
- // keep same delta
3175
- const vec4 delta = vec4(0.4, 0.4, 0.4, 0.4);
3176
-
3177
- vec4 df4(vec4 A, vec4 B) {
3178
- return abs(A - B);
3179
- }
3180
-
3181
- float c_df(vec3 c1, vec3 c2) {
3182
- vec3 d = abs(c1 - c2);
3183
- return d.r + d.g + d.b;
3184
- }
3185
-
3186
- bvec4 eq4(vec4 A, vec4 B) {
3187
- return lessThan(df4(A, B), vec4(XBR_EQ_THRESHOLD));
3188
- }
3189
-
3190
- bvec4 eq24(vec4 A, vec4 B) {
3191
- return lessThan(df4(A, B), vec4(XBR_EQ_THRESHOLD2));
3192
- }
3193
-
3194
- bvec4 and4(bvec4 A, bvec4 B) {
3195
- return bvec4(A.x && B.x, A.y && B.y, A.z && B.z, A.w && B.w);
3196
- }
3197
-
3198
- bvec4 or4(bvec4 A, bvec4 B) {
3199
- return bvec4(A.x || B.x, A.y || B.y, A.z || B.z, A.w || B.w);
3200
- }
3201
-
3202
- vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h) {
3203
- return (df4(a,b) + df4(a,c) + df4(d,e) + df4(d,f) + 4.0 * df4(g,h));
3204
- }
3205
-
3206
- void main() {
3207
- bvec4 edr, edr_left, edr_up, edr3_left, edr3_up, px;
3208
- bvec4 interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up;
3209
- bvec4 interp_restriction_lv3_left, interp_restriction_lv3_up;
3210
- bvec4 nc, nc30, nc60, nc45, nc15, nc75;
3211
- vec4 fx, fx_left, fx_up, fx3_left, fx3_up;
3212
- vec3 res1, res2, pix1, pix2;
3213
- float blend1, blend2;
3214
-
3215
- // IMPORTANT: initialize to avoid undefined reads on some compilers
3216
- pix1 = vec3(0.0);
3217
- pix2 = vec3(0.0);
3218
- blend1 = 0.0;
3219
- blend2 = 0.0;
3220
-
3221
- vec2 fp = fract(texCoord * texSize);
3222
-
3223
- vec3 A1 = texture2D(tex, TEX1.xw).rgb;
3224
- vec3 B1 = texture2D(tex, TEX1.yw).rgb;
3225
- vec3 C1 = texture2D(tex, TEX1.zw).rgb;
3226
-
3227
- vec3 A = texture2D(tex, TEX2.xw).rgb;
3228
- vec3 B = texture2D(tex, TEX2.yw).rgb;
3229
- vec3 C = texture2D(tex, TEX2.zw).rgb;
3230
-
3231
- vec3 D = texture2D(tex, TEX3.xw).rgb;
3232
- vec3 E = texture2D(tex, TEX3.yw).rgb;
3233
- vec3 F = texture2D(tex, TEX3.zw).rgb;
3234
-
3235
- vec3 G = texture2D(tex, TEX4.xw).rgb;
3236
- vec3 H = texture2D(tex, TEX4.yw).rgb;
3237
- vec3 I = texture2D(tex, TEX4.zw).rgb;
3238
-
3239
- vec3 G5 = texture2D(tex, TEX5.xw).rgb;
3240
- vec3 H5 = texture2D(tex, TEX5.yw).rgb;
3241
- vec3 I5 = texture2D(tex, TEX5.zw).rgb;
3242
-
3243
- vec3 A0 = texture2D(tex, TEX6.xy).rgb;
3244
- vec3 D0 = texture2D(tex, TEX6.xz).rgb;
3245
- vec3 G0 = texture2D(tex, TEX6.xw).rgb;
3246
-
3247
- vec3 C4 = texture2D(tex, TEX7.xy).rgb;
3248
- vec3 F4 = texture2D(tex, TEX7.xz).rgb;
3249
- vec3 I4 = texture2D(tex, TEX7.xw).rgb;
3250
-
3251
- // Replace mat4x3 + transpose with explicit dot products (GLSL ES 1.00 safe)
3252
- // Original: transpose(mat4x3(...)) * (XBR_Y_WEIGHT * yuv[0])
3253
- vec3 Yw = (XBR_Y_WEIGHT * yuv[0]);
3254
-
3255
- vec4 b = vec4(dot(B, Yw), dot(D, Yw), dot(H, Yw), dot(F, Yw));
3256
- vec4 c = vec4(dot(C, Yw), dot(A, Yw), dot(G, Yw), dot(I, Yw));
3257
- vec4 e = vec4(dot(E, Yw), dot(E, Yw), dot(E, Yw), dot(E, Yw));
3258
- vec4 d = b.yzwx;
3259
- vec4 f = b.wxyz;
3260
- vec4 g = c.zwxy;
3261
- vec4 h = b.zwxy;
3262
- vec4 i = c.wxyz;
3263
-
3264
- vec4 i4v = vec4(dot(I4, Yw), dot(C1, Yw), dot(A0, Yw), dot(G5, Yw));
3265
- vec4 i5v = vec4(dot(I5, Yw), dot(C4, Yw), dot(A1, Yw), dot(G0, Yw));
3266
- vec4 h5v = vec4(dot(H5, Yw), dot(F4, Yw), dot(B1, Yw), dot(D0, Yw));
3267
- vec4 f4v = h5v.yzwx;
3268
-
3269
- vec4 c1 = i4v.yzwx;
3270
- vec4 g0 = i5v.wxyz;
3271
- vec4 b1 = h5v.zwxy;
3272
- vec4 d0 = h5v.wxyz;
3273
-
3274
- // same constants as original
3275
- vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
3276
- vec4 Bo = vec4( 1.0, 1.0, -1.0, -1.0 );
3277
- vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
3278
- vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
3279
- vec4 Bx = vec4( 0.5, 2.0, -0.5, -2.0 );
3280
- vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
3281
- vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
3282
- vec4 By = vec4( 2.0, 0.5, -2.0, -0.5 );
3283
- vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
3284
-
3285
- vec4 Az = vec4( 6.0, -2.0, -6.0, 2.0 );
3286
- vec4 Bz = vec4( 2.0, 6.0, -2.0, -6.0 );
3287
- vec4 Cz = vec4( 5.0, 3.0, -3.0, -1.0 );
3288
- vec4 Aw = vec4( 2.0, -6.0, -2.0, 6.0 );
3289
- vec4 Bw = vec4( 6.0, 2.0, -6.0, -2.0 );
3290
- vec4 Cw = vec4( 5.0, -1.0, -3.0, 3.0 );
3291
-
3292
- fx = (Ao * fp.y + Bo * fp.x);
3293
- fx_left = (Ax * fp.y + Bx * fp.x);
3294
- fx_up = (Ay * fp.y + By * fp.x);
3295
- fx3_left = (Az * fp.y + Bz * fp.x);
3296
- fx3_up = (Aw * fp.y + Bw * fp.x);
3297
-
3298
- // Keep CORNER_* behavior EXACTLY. Default path is CORNER_C branch (the else).
3299
- #ifdef CORNER_A
3300
- interp_restriction_lv1 = and4(notEqual(e, f), notEqual(e, h));
3301
- #elif defined(CORNER_B)
3302
- interp_restriction_lv1 = ((e!=f) && (e!=h) && ( !eq4(f,b) && !eq4(h,d) || eq4(e,i) && !eq4(f,i4v) && !eq4(h,i5v) || eq4(e,g) || eq4(e,c) ) );
3303
- #elif defined(CORNER_D)
3304
- interp_restriction_lv1 = ((e!=f) && (e!=h) && ( !eq4(f,b) && !eq4(h,d) || eq4(e,i) && !eq4(f,i4v) && !eq4(h,i5v) || eq4(e,g) || eq4(e,c) ) && (f!=f4v && f!=i || h!=h5v && h!=i || h!=g || f!=c || eq4(b,c1) && eq4(d,g0)));
3305
- #else
3306
- interp_restriction_lv1 = and4(
3307
- and4(notEqual(e, f), notEqual(e, h)),
3308
- or4(
3309
- or4(
3310
- and4(not(eq4(f,b)), not(eq4(f,c))),
3311
- and4(not(eq4(h,d)), not(eq4(h,g)))
3312
- ),
3313
- or4(
3314
- and4(
3315
- eq4(e,i),
3316
- or4(
3317
- and4(not(eq4(f,f4v)), not(eq4(f,i4v))),
3318
- and4(not(eq4(h,h5v)), not(eq4(h,i5v)))
3319
- )
3320
- ),
3321
- or4(eq4(e,g), eq4(e,c))
3322
- )
3323
- )
3324
- );
3325
- #endif
3326
-
3327
- interp_restriction_lv2_left = and4(notEqual(e, g), notEqual(d, g));
3328
- interp_restriction_lv2_up = and4(notEqual(e, c), notEqual(b, c));
3329
- interp_restriction_lv3_left = and4(eq24(g, g0), not(eq24(d0, g0)));
3330
- interp_restriction_lv3_up = and4(eq24(c, c1), not(eq24(b1, c1)));
3331
-
3332
- vec4 fx45 = smoothstep(Co - delta, Co + delta, fx);
3333
- vec4 fx30 = smoothstep(Cx - delta, Cx + delta, fx_left);
3334
- vec4 fx60 = smoothstep(Cy - delta, Cy + delta, fx_up);
3335
- vec4 fx15 = smoothstep(Cz - delta, Cz + delta, fx3_left);
3336
- vec4 fx75 = smoothstep(Cw - delta, Cw + delta, fx3_up);
3337
-
3338
- edr = and4(
3339
- lessThan(
3340
- weighted_distance(e, c, g, i, h5v, f4v, h, f),
3341
- weighted_distance(h, d, i5v, f, i4v, b, e, i)
3342
- ),
3343
- interp_restriction_lv1
3344
- );
3345
-
3346
- edr_left = and4(lessThanEqual((XBR_LV2_COEFFICIENT * df4(f,g)), df4(h,c)), interp_restriction_lv2_left);
3347
- edr_up = and4(greaterThanEqual(df4(f,g), (XBR_LV2_COEFFICIENT * df4(h,c))), interp_restriction_lv2_up);
3348
- edr3_left = interp_restriction_lv3_left;
3349
- edr3_up = interp_restriction_lv3_up;
3350
-
3351
- nc45 = and4(edr, bvec4(fx45));
3352
- nc30 = and4(edr, and4(edr_left, bvec4(fx30)));
3353
- nc60 = and4(edr, and4(edr_up, bvec4(fx60)));
3354
- nc15 = and4(and4(edr, edr_left), and4(edr3_left, bvec4(fx15)));
3355
- nc75 = and4(and4(edr, edr_up), and4(edr3_up, bvec4(fx75)));
3356
-
3357
- px = lessThanEqual(df4(e, f), df4(e, h));
3358
-
3359
- nc = bvec4(
3360
- (nc75.x || nc15.x || nc30.x || nc60.x || nc45.x),
3361
- (nc75.y || nc15.y || nc30.y || nc60.y || nc45.y),
3362
- (nc75.z || nc15.z || nc30.z || nc60.z || nc45.z),
3363
- (nc75.w || nc15.w || nc30.w || nc60.w || nc45.w)
3364
- );
3365
-
3366
- vec4 final45 = vec4(nc45) * fx45;
3367
- vec4 final30 = vec4(nc30) * fx30;
3368
- vec4 final60 = vec4(nc60) * fx60;
3369
- vec4 final15 = vec4(nc15) * fx15;
3370
- vec4 final75 = vec4(nc75) * fx75;
3371
-
3372
- vec4 maximo = max(max(max(final15, final75), max(final30, final60)), final45);
3373
-
3374
- if (nc.x) { pix1 = px.x ? F : H; blend1 = maximo.x; }
3375
- else if (nc.y) { pix1 = px.y ? B : F; blend1 = maximo.y; }
3376
- else if (nc.z) { pix1 = px.z ? D : B; blend1 = maximo.z; }
3377
- else if (nc.w) { pix1 = px.w ? H : D; blend1 = maximo.w; }
3378
-
3379
- if (nc.w) { pix2 = px.w ? H : D; blend2 = maximo.w; }
3380
- else if (nc.z) { pix2 = px.z ? D : B; blend2 = maximo.z; }
3381
- else if (nc.y) { pix2 = px.y ? B : F; blend2 = maximo.y; }
3382
- else if (nc.x) { pix2 = px.x ? F : H; blend2 = maximo.x; }
3383
-
3384
- res1 = mix(E, pix1, blend1);
3385
- res2 = mix(E, pix2, blend2);
3386
-
3387
- vec3 res = mix(res1, res2, step(c_df(E, res1), c_df(E, res2)));
3388
-
3389
- gl_FragColor = vec4(res, 1.0);
3390
- }/*
3391
- Hyllian's xBR-lv3 Shader
3392
-
3393
- Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com
3394
-
3395
- Permission is hereby granted, free of charge, to any person obtaining a copy
3396
- of this software and associated documentation files (the "Software"), to deal
3397
- in the Software without restriction, including without limitation the rights
3398
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3399
- copies of the Software, and to permit persons to whom the Software is
3400
- furnished to do so, subject to the following conditions:
3401
-
3402
- The above copyright notice and this permission notice shall be included in
3403
- all copies or substantial portions of the Software.
3404
-
3405
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3406
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3407
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3408
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3409
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3410
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3411
- THE SOFTWARE.
3412
-
3413
- Incorporates some of the ideas from SABR shader. Thanks to Joshua Street.
3414
- */
3415
-
3416
- attribute vec4 position;
3417
-
3418
- uniform vec2 texSize;
3419
-
3420
- varying vec2 texCoord;
3421
- varying vec4 TEX1;
3422
- varying vec4 TEX2;
3423
- varying vec4 TEX3;
3424
- varying vec4 TEX4;
3425
- varying vec4 TEX5;
3426
- varying vec4 TEX6;
3427
- varying vec4 TEX7;
3428
-
3429
- void main() {
3430
- gl_Position = position;
3431
-
3432
- vec2 ps = vec2(1.0) / texSize;
3433
- float dx = ps.x;
3434
- float dy = ps.y;
3435
-
3436
- texCoord = (position.st + vec2(1.0, 1.0)) * vec2(0.5, 0.5);
3437
-
3438
- // use 0.0 (float literals) for strict GLSL ES 1.00 compilers
3439
- TEX1 = texCoord.xxxy + vec4(-dx, 0.0, dx, -2.0 * dy); // A1 B1 C1
3440
- TEX2 = texCoord.xxxy + vec4(-dx, 0.0, dx, -1.0 * dy); // A B C
3441
- TEX3 = texCoord.xxxy + vec4(-dx, 0.0, dx, 0.0 ); // D E F
3442
- TEX4 = texCoord.xxxy + vec4(-dx, 0.0, dx, 1.0 * dy); // G H I
3443
- TEX5 = texCoord.xxxy + vec4(-dx, 0.0, dx, 2.0 * dy); // G5 H5 I5
3444
- TEX6 = texCoord.xyyy + vec4(-2.0 * dx, -dy, 0.0, dy); // A0 D0 G0
3445
- TEX7 = texCoord.xyyy + vec4( 2.0 * dx, -dy, 0.0, dy); // C4 F4 I4
3446
- }