forked from Themaister/slang-shaders
/
crt-sony-megatron.slang
1697 lines (1385 loc) · 68.1 KB
/
crt-sony-megatron.slang
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#version 450
/*
A shader that tries to emulate a sony PVM type aperture grille screen but with full brightness.
The novel thing about this shader is that it relies on the HDR shaders to brighten up the image so that when
we apply this shader which emulates the apperture grille the resulting screen isn't left too dark.
I think you need at least a DisplayHDR 600 monitor but to get close to CRT levels of brightness I think DisplayHDR 1000.
Please Enable HDR in RetroArch 1.10+
NOTE: when this shader is envoked the Contrast, Peak Luminance and Paper White Luminance in the HDR menu do nothing instead set those values through the shader parameters
For this shader set Paper White Luminance to above 700 and Peak Luminance to the peak luminance of your monitor.
Also try to use a integer scaling - its just better - overscaling is fine.
This shader doesn't do any geometry warping or bouncing of light around inside the screen etc - I think these effects just add unwanted noise, I know people disagree. Please feel free to make you own and add them
Dont use this shader directly - use the hdr\crt-make-model-hdr.slangp where make and model are the make and model of the CRT you want.
THIS SHADER DOES NOT SUPPORT WRGB OLED (Due to the sub pixel layout of WRGB - RGB QD-OLED or LCD (and variants thereof screens are fine)
*/
#pragma format A2B10G10R10_UNORM_PACK32
layout(push_constant) uniform Push
{
// User Settings
float hcrt_hdr;
float hcrt_colour_space;
float hcrt_max_nits;
float hcrt_paper_white_nits;
float hcrt_expand_gamut;
float hcrt_colour_accurate;
float hcrt_lcd_resolution;
float hcrt_lcd_subpixel;
float hcrt_red_vertical_convergence;
float hcrt_green_vertical_convergence;
float hcrt_blue_vertical_convergence;
float hcrt_red_horizontal_convergence;
float hcrt_green_horizontal_convergence;
float hcrt_blue_horizontal_convergence;
// Developer Settings
float hcrt_crt_screen_type;
float hcrt_crt_resolution;
// Vertical Settings
float hcrt_red_scanline_min;
float hcrt_red_scanline_max;
float hcrt_red_scanline_attack;
float hcrt_green_scanline_min;
float hcrt_green_scanline_max;
float hcrt_green_scanline_attack;
float hcrt_blue_scanline_min;
float hcrt_blue_scanline_max;
float hcrt_blue_scanline_attack;
// Horizontal Settings
float hcrt_red_beam_sharpness;
float hcrt_red_beam_attack;
float hcrt_green_beam_sharpness;
float hcrt_green_beam_attack;
float hcrt_blue_beam_sharpness;
float hcrt_blue_beam_attack;
} params;
layout(std140, set = 0, binding = 0) uniform UBO
{
mat4 MVP;
vec4 SourceSize;
vec4 OriginalSize;
vec4 OutputSize;
uint FrameCount;
float hcrt_r709_gamma_out;
float hcrt_srgb_gamma_out;
float hcrt_p3_gamma_out;
float hcrt_r709_gamma_cutoff;
float hcrt_srgb_gamma_cutoff;
float hcrt_h_size;
float hcrt_v_size;
float hcrt_h_cent;
float hcrt_v_cent;
float hcrt_pin_phase;
float hcrt_pin_amp;
} global;
#include "include/parameters.h"
#define HCRT_HDR params.hcrt_hdr
#define HCRT_OUTPUT_COLOUR_SPACE params.hcrt_colour_space
#define HCRT_MAX_NITS params.hcrt_max_nits
#define HCRT_PAPER_WHITE_NITS params.hcrt_paper_white_nits
#define HCRT_EXPAND_GAMUT params.hcrt_expand_gamut
#define HCRT_R709_GAMMA_OUT global.hcrt_r709_gamma_out
#define HCRT_SRGB_GAMMA_OUT global.hcrt_srgb_gamma_out
#define HCRT_P3_GAMMA_OUT global.hcrt_p3_gamma_out
#define HCRT_R709_GAMMA_CUTOFF global.hcrt_r709_gamma_cutoff
#define HCRT_SRGB_GAMMA_CUTOFF global.hcrt_srgb_gamma_cutoff
#define HCRT_COLOUR_ACCURATE params.hcrt_colour_accurate
#define HCRT_LCD_RESOLUTION params.hcrt_lcd_resolution
#define HCRT_LCD_SUBPIXEL params.hcrt_lcd_subpixel
#define HCRT_RED_VERTICAL_CONVERGENCE params.hcrt_red_vertical_convergence
#define HCRT_GREEN_VERTICAL_CONVERGENCE params.hcrt_green_vertical_convergence
#define HCRT_BLUE_VERTICAL_CONVERGENCE params.hcrt_blue_vertical_convergence
#define HCRT_RED_HORIZONTAL_CONVERGENCE params.hcrt_red_horizontal_convergence
#define HCRT_GREEN_HORIZONTAL_CONVERGENCE params.hcrt_green_horizontal_convergence
#define HCRT_BLUE_HORIZONTAL_CONVERGENCE params.hcrt_blue_horizontal_convergence
#define HCRT_CRT_SCREEN_TYPE params.hcrt_crt_screen_type
#define HCRT_CRT_RESOLUTION params.hcrt_crt_resolution
#define HCRT_RED_SCANLINE_MIN params.hcrt_red_scanline_min
#define HCRT_RED_SCANLINE_MAX params.hcrt_red_scanline_max
#define HCRT_RED_SCANLINE_ATTACK params.hcrt_red_scanline_attack
#define HCRT_GREEN_SCANLINE_MIN params.hcrt_green_scanline_min
#define HCRT_GREEN_SCANLINE_MAX params.hcrt_green_scanline_max
#define HCRT_GREEN_SCANLINE_ATTACK params.hcrt_green_scanline_attack
#define HCRT_BLUE_SCANLINE_MIN params.hcrt_blue_scanline_min
#define HCRT_BLUE_SCANLINE_MAX params.hcrt_blue_scanline_max
#define HCRT_BLUE_SCANLINE_ATTACK params.hcrt_blue_scanline_attack
#define HCRT_RED_BEAM_SHARPNESS params.hcrt_red_beam_sharpness
#define HCRT_RED_BEAM_ATTACK params.hcrt_red_beam_attack
#define HCRT_GREEN_BEAM_SHARPNESS params.hcrt_green_beam_sharpness
#define HCRT_GREEN_BEAM_ATTACK params.hcrt_green_beam_attack
#define HCRT_BLUE_BEAM_SHARPNESS params.hcrt_blue_beam_sharpness
#define HCRT_BLUE_BEAM_ATTACK params.hcrt_blue_beam_attack
#define HCRT_H_SIZE global.hcrt_h_size
#define HCRT_V_SIZE global.hcrt_v_size
#define HCRT_H_CENT global.hcrt_h_cent
#define HCRT_V_CENT global.hcrt_v_cent
#define HCRT_PIN_PHASE global.hcrt_pin_phase
#define HCRT_PIN_AMP global.hcrt_pin_amp
#define COMPAT_TEXTURE(c, d) texture(c, d)
#pragma stage vertex
layout(location = 0) in vec4 Position;
layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec2 vTexCoord;
void main()
{
gl_Position = global.MVP * Position;
vTexCoord = TexCoord * vec2(1.00001); // To resolve rounding issues when sampling
}
#pragma stage fragment
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D SourceSDR;
layout(set = 0, binding = 3) uniform sampler2D SourceHDR;
#define kChannelMask 3
#define kFirstChannelShift 2
#define kSecondChannelShift 4
#define kThirdChannelShift 6
#define kRedId 0
#define kGreenId 1
#define kBlueId 2
#define kRed (1 | (kRedId << kFirstChannelShift))
#define kGreen (1 | (kGreenId << kFirstChannelShift))
#define kBlue (1 | (kBlueId << kFirstChannelShift))
#define kMagenta (2 | (kRedId << kFirstChannelShift) | (kBlueId << kSecondChannelShift))
#define kYellow (2 | (kRedId << kFirstChannelShift) | (kGreenId << kSecondChannelShift))
#define kCyan (2 | (kGreenId << kFirstChannelShift) | (kBlueId << kSecondChannelShift))
#define kWhite (3 | (kRedId << kFirstChannelShift) | (kGreenId << kSecondChannelShift) | (kBlueId << kThirdChannelShift))
#define kBlack 0
#define kRedChannel vec3(1.0, 0.0, 0.0)
#define kGreenChannel vec3(0.0, 1.0, 0.0)
#define kBlueChannel vec3(0.0, 0.0, 1.0)
const vec3 kColourMask[3] = { kRedChannel, kGreenChannel, kBlueChannel };
#define kApertureGrille 0
#define kShadowMask 1
#define kSlotMask 2
#define kBlackWhiteMask 3
#define kBGRAxis 3
#define kTVLAxis 4
#define kResolutionAxis 3
// APERTURE GRILLE MASKS
const float kApertureGrilleMaskSize[kResolutionAxis * kTVLAxis] = {
4.0f, 2.0f, 1.0f, 1.0f , // 1080p: 300 TVL, 600 TVL, 800 TVL, 1000 TVL
7.0f, 4.0f, 3.0f, 2.0f , // 4K: 300 TVL, 600 TVL, 800 TVL, 1000 TVL
13.0f, 7.0f, 5.0f, 4.0f }; // 8K: 300 TVL, 600 TVL, 800 TVL, 1000 TVL
// SHADOW MASKS
const float kShadowMaskSizeX[kResolutionAxis * kTVLAxis] = { 6.0f, 2.0f, 1.0f, 1.0f , 12.0f, 6.0f, 2.0f, 2.0f , 12.0f, 12.0f, 6.0f, 6.0f };
const float kShadowMaskSizeY[kResolutionAxis * kTVLAxis] = { 4.0f, 2.0f, 1.0f, 1.0f , 8.0f, 4.0f, 2.0f, 2.0f , 8.0f, 8.0f, 4.0f, 4.0f };
// SLOT MASKS
const float kSlotMaskSizeX[kResolutionAxis * kTVLAxis] = { 4.0f, 2.0f, 1.0f, 1.0f , 7.0f, 4.0f, 3.0f, 2.0f , 7.0f, 7.0f, 5.0f, 4.0f }; //1080p: 300 TVL, 600 TVL, 800 TVL, 1000 TVL 4K: 300 TVL, 600 TVL, 800 TVL, 1000 TVL 8K: 300 TVL, 600 TVL, 800 TVL, 1000 TVL
const float kSlotMaskSizeY[kResolutionAxis * kTVLAxis] = { 4.0f, 4.0f, 1.0f, 1.0f , 8.0f, 6.0f, 4.0f, 4.0f , 6.0f, 6.0f, 4.0f, 4.0f }; //1080p: 300 TVL, 600 TVL, 800 TVL, 1000 TVL 4K: 300 TVL, 600 TVL, 800 TVL, 1000 TVL 8K: 300 TVL, 600 TVL, 800 TVL, 1000 TVL
#include "include/scanline_generation.h"
#include "include/gamma_correct.h"
#define k1080p 0
#define k4K 1
#define k8K 2
#define k300TVL 0
#define k600TVL 1
#define k800TVL 2
#define k1000TVL 3
void main()
{
const uint screen_type = uint(HCRT_CRT_SCREEN_TYPE);
const uint crt_resolution = uint(HCRT_CRT_RESOLUTION);
const uint lcd_resolution = uint(HCRT_LCD_RESOLUTION);
const uint lcd_subpixel_layout = uint(HCRT_LCD_SUBPIXEL);
const vec2 source_size = global.SourceSize.xy;
const vec2 output_size = global.OutputSize.xy;
vec2 tex_coord = vTexCoord - vec2(0.5f);
tex_coord = tex_coord * vec2(1.0f + (HCRT_PIN_PHASE * tex_coord.y), 1.0f);
tex_coord = tex_coord * vec2(HCRT_H_SIZE, HCRT_V_SIZE);
tex_coord = tex_coord + vec2(0.5f);
tex_coord = tex_coord + (vec2(HCRT_H_CENT, HCRT_V_CENT) / output_size);
const vec2 current_position = vTexCoord * output_size;
uint colour_mask = 0;
switch(screen_type)
{
case kApertureGrille:
{
uint mask = uint(floor(mod(current_position.x, kApertureGrilleMaskSize[(lcd_resolution * kTVLAxis) + crt_resolution])));
switch(lcd_resolution)
{
case k1080p:
{
switch(crt_resolution)
{
case k300TVL:
{
#define kRGBX (kRed << 0) | (kGreen << 4) | (kBlue << 8) | (kBlack << 12)
#define kRBGX (kRed << 0) | (kBlue << 4) | (kGreen << 8) | (kBlack << 12)
#define kBGRX (kBlue << 0) | (kGreen << 4) | (kRed << 8) | (kBlack << 12)
const uint rgb_mask[kBGRAxis] = { kRGBX, kRBGX, kBGRX };
colour_mask = (rgb_mask[lcd_subpixel_layout] >> (mask * 4)) & 0xF;
#undef kRGBX
#undef kRBGX
#undef kBGRX
break;
}
case k600TVL:
{
#define kMG (kMagenta << 0) | (kGreen << 6)
#define kYB (kYellow << 0) | (kBlue << 6)
#define kGM (kGreen << 0) | (kMagenta << 6)
const uint rgb_mask[kBGRAxis] = { kMG, kYB, kGM };
colour_mask = (rgb_mask[lcd_subpixel_layout] >> (mask * 6)) & 0x3F;
#undef kMG
#undef kYB
#undef kGM
break;
}
case k800TVL:
{
colour_mask = kWhite;
break;
}
case k1000TVL:
{
colour_mask = kWhite;
break;
}
default:
{
break;
}
}
break;
}
case k4K:
{
switch(crt_resolution)
{
case k300TVL:
{
#define kRRGGBBX (kRed << 0) | (kRed << 4) | (kGreen << 8) | (kGreen << 12) | (kBlue << 16) | (kBlue << 20) | (kBlack << 24)
#define kRRBBGGX (kRed << 0) | (kRed << 4) | (kBlue << 8) | (kBlue << 12) | (kGreen << 16) | (kGreen << 20) | (kBlack << 24)
#define kBBGGRRX (kBlue << 0) | (kBlue << 4) | (kGreen << 8) | (kGreen << 12) | (kRed << 16) | (kRed << 20) | (kBlack << 24)
const uint rgb_mask[kBGRAxis] = { kRRGGBBX, kRRBBGGX, kBBGGRRX };
colour_mask = (rgb_mask[lcd_subpixel_layout] >> (mask * 4)) & 0xF;
#undef kRRGGBBX
#undef kRRBBGGX
#undef kBBGGRRX
break;
}
case k600TVL:
{
#define kRGBX (kRed << 0) | (kGreen << 4) | (kBlue << 8) | (kBlack << 12)
#define kRBGX (kRed << 0) | (kBlue << 4) | (kGreen << 8) | (kBlack << 12)
#define kBGRX (kBlue << 0) | (kGreen << 4) | (kRed << 8) | (kBlack << 12)
const uint rgb_mask[kBGRAxis] = { kRGBX, kRBGX, kBGRX };
colour_mask = (rgb_mask[lcd_subpixel_layout] >> (mask * 4)) & 0xF;
#undef kRGBX
#undef kRBGX
#undef kBGRX
break;
}
case k800TVL:
{
#define kBGR (kBlue << 0) | (kGreen << 4) | (kRed << 8)
#define kGBR (kGreen << 0) | (kBlue << 4) | (kRed << 8)
#define kRGB (kRed << 0) | (kGreen << 4) | (kBlue << 8)
const uint rgb_mask[kBGRAxis] = { kBGR, kGBR, kRGB };
colour_mask = (rgb_mask[lcd_subpixel_layout] >> (mask * 4)) & 0xF;
#undef kRGB
#undef kGBR
#undef kBGR
break;
}
case k1000TVL:
{
#define kMG (kMagenta << 0) | (kGreen << 6)
#define kYB (kYellow << 0) | (kBlue << 6)
#define kGM (kGreen << 0) | (kMagenta << 6)
const uint rgb_mask[kBGRAxis] = { kMG, kYB, kGM };
colour_mask = (rgb_mask[lcd_subpixel_layout] >> (mask * 6)) & 0x3F;
#undef kMG
#undef kYB
#undef kGM
break;
}
default:
{
break;
}
}
break;
}
case k8K:
{
switch(crt_resolution)
{
case k300TVL:
{
#define kMaxApertureGrilleSize 13
#define kRRRRGGGGBBBBX kRed, kRed, kRed, kRed, kGreen, kGreen, kGreen, kGreen, kBlue, kBlue, kBlue, kBlue, kBlack
#define kRRRRBBBBGGGGX kRed, kRed, kRed, kRed, kBlue, kBlue, kBlue, kBlue, kGreen, kGreen, kGreen, kGreen, kBlack
#define kBBBBGGGGRRRRX kBlue, kBlue, kBlue, kBlue, kGreen, kGreen, kGreen, kGreen, kRed, kRed, kRed, kRed, kBlack
const uint kApertureGrilleMasks8K300TVL[kBGRAxis * kMaxApertureGrilleSize] =
{
kRRRRGGGGBBBBX, kRRRRBBBBGGGGX, kBBBBGGGGRRRRX
};
colour_mask = kApertureGrilleMasks8K300TVL[(lcd_subpixel_layout * kMaxApertureGrilleSize) + mask];
#undef kMaxApertureGrilleSize
#undef kRRRRGGGGBBBBX
#undef kRRRRBBBBGGGGX
#undef kBBBBGGGGRRRRX
break;
}
case k600TVL:
{
#define kRRGGBBX (kRed << 0) | (kRed << 4) | (kGreen << 8) | (kGreen << 12) | (kBlue << 16) | (kBlue << 20) | (kBlack << 24)
#define kRRBBGGX (kRed << 0) | (kRed << 4) | (kBlue << 8) | (kBlue << 12) | (kGreen << 16) | (kGreen << 20) | (kBlack << 24)
#define kBBGGRRX (kBlue << 0) | (kBlue << 4) | (kGreen << 8) | (kGreen << 12) | (kRed << 16) | (kRed << 20) | (kBlack << 24)
const uint rgb_mask[kBGRAxis] = { kRRGGBBX, kRRBBGGX, kBBGGRRX };
colour_mask = (rgb_mask[lcd_subpixel_layout] >> (mask * 4)) & 0xF;
#undef kRRGGBBX
#undef kRRBBGGX
#undef kBBGGRRX
break;
}
case k800TVL:
{
#define kRYCBX (kRed << 0) | (kYellow << 6) | (kCyan << 12) | (kBlue << 18) | (kBlack << 24)
#define kRMCGX (kRed << 0) | (kMagenta << 6) | (kCyan << 12) | (kGreen << 18) | (kBlack << 24)
#define kBCYRX (kBlue << 0) | (kCyan << 6) | (kYellow << 12) | (kRed << 18) | (kBlack << 24)
const uint rgb_mask[kBGRAxis] = { kRYCBX, kRMCGX, kBCYRX };
colour_mask = (rgb_mask[lcd_subpixel_layout] >> (mask * 6)) & 0x3F;
#undef kRYCBX
#undef kRMCGX
#undef kBCYRX
break;
}
case k1000TVL:
{
#define kRGBX (kRed << 0) | (kGreen << 4) | (kBlue << 8) | (kBlack << 12)
#define kRBGX (kRed << 0) | (kBlue << 4) | (kGreen << 8) | (kBlack << 12)
#define kBGRX (kBlue << 0) | (kGreen << 4) | (kRed << 8) | (kBlack << 12)
const uint rgb_mask[kBGRAxis] = { kRGBX, kRBGX, kBGRX };
colour_mask = (rgb_mask[lcd_subpixel_layout] >> (mask * 4)) & 0xF;
#undef kRGBX
#undef kRBGX
#undef kBGRX
break;
}
default:
{
break;
}
}
break;
}
default:
{
break;
}
}
break;
}
case kShadowMask:
{
uint shadow_y = uint(floor(mod(current_position.y, kShadowMaskSizeY[(lcd_resolution * kTVLAxis) + crt_resolution])));
uint mask = uint(floor(mod(current_position.x, kShadowMaskSizeX[(lcd_resolution * kTVLAxis) + crt_resolution])));
switch(lcd_resolution)
{
case k1080p:
{
switch(crt_resolution)
{
case k300TVL:
{
#define kGRRBBG (kGreen << 0) | (kRed << 4) | (kRed << 8) | (kBlue << 12) | (kBlue << 16) | (kGreen << 20)
#define kBBGGRR (kBlue << 0) | (kBlue << 4) | (kGreen << 8) | (kGreen << 12) | (kRed << 16) | (kRed << 20)
#define kBRRGGB (kBlue << 0) | (kRed << 4) | (kRed << 8) | (kGreen << 12) | (kGreen << 16) | (kBlue << 20)
#define kGGBBRR (kGreen << 0) | (kGreen << 4) | (kBlue << 8) | (kBlue << 12) | (kRed << 16) | (kRed << 20)
#define kGBBRRG (kGreen << 0) | (kBlue << 4) | (kBlue << 8) | (kRed << 12) | (kRed << 16) | (kGreen << 20)
#define kRRGGBB (kRed << 0) | (kRed << 4) | (kGreen << 8) | (kGreen << 12) | (kBlue << 16) | (kBlue << 20)
/*
kGRRBBG
kGRRBBG
kBBGGRR
kBBGGRR
kBRRGGB
kBRRGGB
kGGBBRR
kGGBBRR
kGBBRRG
kGBBRRG
kRRGGBB
kRRGGBB
*/
const uint rgb_mask[kBGRAxis * 2] = { kGRRBBG, kBBGGRR, kBRRGGB, kGGBBRR, kGBBRRG, kRRGGBB };
if(shadow_y < 2)
{
colour_mask = (rgb_mask[(lcd_subpixel_layout * 2) + 0] >> (mask * 4)) & 0xF;
}
else
{
colour_mask = (rgb_mask[(lcd_subpixel_layout * 2) + 1] >> (mask * 4)) & 0xF;
}
#undef kGRRBBG
#undef kBBGGRR
#undef kBRRGGB
#undef kGGBBRR
#undef kGBBRRG
#undef kRRGGBB
break;
}
case k600TVL:
{
#define kMG (kMagenta << 0) | (kGreen << 6)
#define kGM (kGreen << 0) | (kMagenta << 6)
#define kYB (kYellow << 0) | (kBlue << 6)
#define kBY (kBlue << 0) | (kYellow << 6)
/*
kMG
kGM
kYB
kBY
kGM
kMG
*/
const uint rgb_mask[kBGRAxis * 2] = { kMG, kGM, kYB, kBY, kGM, kMG };
if(shadow_y < 1)
{
colour_mask = (rgb_mask[(lcd_subpixel_layout * 2) + 0] >> (mask * 6)) & 0x3F;
}
else
{
colour_mask = (rgb_mask[(lcd_subpixel_layout * 2) + 1] >> (mask * 6)) & 0x3F;
}
#undef kMG
#undef kGM
#undef kYB
#undef kBY
break;
}
case k800TVL:
{
colour_mask = kWhite;
break;
}
case k1000TVL:
{
colour_mask = kWhite;
break;
}
default:
{
break;
}
}
break;
}
case k4K:
{
switch(crt_resolution)
{
case k300TVL:
{
#define kMaxShadowMaskSizeX 12
#define kMaxShadowMaskSizeY 8
#define kGGRRRRBBBBGG kGreen, kGreen, kRed, kRed, kRed, kRed, kBlue, kBlue, kBlue, kBlue, kGreen, kGreen
#define kBBBBGGGGRRRR kBlue, kBlue, kBlue, kBlue, kGreen, kGreen, kGreen, kGreen, kRed, kRed, kRed, kRed
#define kBBRRRRGGGGBB kBlue, kBlue, kRed, kRed, kRed, kRed, kGreen, kGreen, kGreen, kGreen, kBlue, kBlue
#define kGGGGBBBBRRRR kGreen, kGreen, kGreen, kGreen, kBlue, kBlue, kBlue, kBlue, kRed, kRed, kRed, kRed
#define kGGBBBBRRRRGG kGreen, kGreen, kBlue, kBlue, kBlue, kBlue, kRed, kRed, kRed, kRed, kGreen, kGreen
#define kRRRRGGGGBBBB kRed, kRed, kRed, kRed, kGreen, kGreen, kGreen, kGreen, kBlue, kBlue, kBlue, kBlue
/*
kGGRRRRBBBBGG
kGGRRRRBBBBGG
kGGRRRRBBBBGG
kGGRRRRBBBBGG
kBBBBGGGGRRRR
kBBBBGGGGRRRR
kBBBBGGGGRRRR
kBBBBGGGGRRRR
kBBRRRRGGGGBB
kBBRRRRGGGGBB
kBBRRRRGGGGBB
kBBRRRRGGGGBB
kGGGGBBBBRRRR
kGGGGBBBBRRRR
kGGGGBBBBRRRR
kGGGGBBBBRRRR
kGGBBBBRRRRGG
kGGBBBBRRRRGG
kGGBBBBRRRRGG
kGGBBBBRRRRGG
kRRRRGGGGBBBB
kRRRRGGGGBBBB
kRRRRGGGGBBBB
kRRRRGGGGBBBB
*/
if(shadow_y < 4)
{
const uint rgb_mask[kBGRAxis * kMaxShadowMaskSizeX] = { kGGRRRRBBBBGG, kBBRRRRGGGGBB, kGGBBBBRRRRGG };
colour_mask = rgb_mask[(lcd_subpixel_layout * kMaxShadowMaskSizeX) + mask];
}
else
{
const uint rgb_mask[kBGRAxis * kMaxShadowMaskSizeX] = { kBBBBGGGGRRRR, kGGGGBBBBRRRR, kRRRRGGGGBBBB };
colour_mask = rgb_mask[(lcd_subpixel_layout * kMaxShadowMaskSizeX) + mask];
}
#undef kMaxShadowMaskSizeX
#undef kMaxShadowMaskSizeY
#undef kGGRRRRBBBBGG
#undef kBBBBGGGGRRRR
#undef kBBRRRRGGGGBB
#undef kGGGGBBBBRRRR
#undef kGGBBBBRRRRGG
#undef kRRRRGGGGBBBB
break;
}
case k600TVL:
{
#define kGRRBBG (kGreen << 0) | (kRed << 4) | (kRed << 8) | (kBlue << 12) | (kBlue << 16) | (kGreen << 20)
#define kBBGGRR (kBlue << 0) | (kBlue << 4) | (kGreen << 8) | (kGreen << 12) | (kRed << 16) | (kRed << 20)
#define kBRRGGB (kBlue << 0) | (kRed << 4) | (kRed << 8) | (kGreen << 12) | (kGreen << 16) | (kBlue << 20)
#define kGGBBRR (kGreen << 0) | (kGreen << 4) | (kBlue << 8) | (kBlue << 12) | (kRed << 16) | (kRed << 20)
#define kGBBRRG (kGreen << 0) | (kBlue << 4) | (kBlue << 8) | (kRed << 12) | (kRed << 16) | (kGreen << 20)
#define kRRGGBB (kRed << 0) | (kRed << 4) | (kGreen << 8) | (kGreen << 12) | (kBlue << 16) | (kBlue << 20)
/*
kGRRBBG
kGRRBBG
kBBGGRR
kBBGGRR
kBRRGGB
kBRRGGB
kGGBBRR
kGGBBRR
kGBBRRG
kGBBRRG
kRRGGBB
kRRGGBB
*/
const uint rgb_mask[kBGRAxis * 2] = { kGRRBBG, kBBGGRR, kBRRGGB, kGGBBRR, kGBBRRG, kRRGGBB };
if(shadow_y < 2)
{
colour_mask = (rgb_mask[(lcd_subpixel_layout * 2) + 0] >> (mask * 4)) & 0xF;
}
else
{
colour_mask = (rgb_mask[(lcd_subpixel_layout * 2) + 1] >> (mask * 4)) & 0xF;
}
#undef kGRRBBG
#undef kBBGGRR
#undef kBRRGGB
#undef kGGBBRR
#undef kGBBRRG
#undef kRRGGBB
break;
}
case k800TVL:
{
#define kMG (kMagenta << 0) | (kGreen << 6)
#define kGM (kGreen << 0) | (kMagenta << 6)
#define kYB (kYellow << 0) | (kBlue << 6)
#define kBY (kBlue << 0) | (kYellow << 6)
/*
kMG
kGM
kYB
kBY
kGM
kMG
*/
const uint rgb_mask[kBGRAxis * 2] = { kMG, kGM, kYB, kBY, kGM, kMG };
if(shadow_y < 1)
{
colour_mask = (rgb_mask[(lcd_subpixel_layout * 2) + 0] >> (mask * 6)) & 0x3F;
}
else
{
colour_mask = (rgb_mask[(lcd_subpixel_layout * 2) + 1] >> (mask * 6)) & 0x3F;
}
#undef kMG
#undef kGM
#undef kYB
#undef kBY
break;
}
case k1000TVL:
{
#define kMG (kMagenta << 0) | (kGreen << 6)
#define kGM (kGreen << 0) | (kMagenta << 6)
#define kYB (kYellow << 0) | (kBlue << 6)
#define kBY (kBlue << 0) | (kYellow << 6)
/*
kMG
kGM
kYB
kBY
kGM
kMG
*/
const uint rgb_mask[kBGRAxis * 2] = { kMG, kGM, kYB, kBY, kGM, kMG };
if(shadow_y < 1)
{
colour_mask = (rgb_mask[(lcd_subpixel_layout * 2) + 0] >> (mask * 6)) & 0x3F;
}
else
{
colour_mask = (rgb_mask[(lcd_subpixel_layout * 2) + 1] >> (mask * 6)) & 0x3F;
}
#undef kMG
#undef kGM
#undef kYB
#undef kBY
break;
}
default:
{
break;
}
}
break;
}
case k8K:
{
switch(crt_resolution)
{
case k300TVL:
{
#define kMaxShadowMaskSizeX 12
#define kMaxShadowMaskSizeY 8
#define kGGRRRRBBBBGG kGreen, kGreen, kRed, kRed, kRed, kRed, kBlue, kBlue, kBlue, kBlue, kGreen, kGreen
#define kBBBBGGGGRRRR kBlue, kBlue, kBlue, kBlue, kGreen, kGreen, kGreen, kGreen, kRed, kRed, kRed, kRed
#define kBBRRRRGGGGBB kBlue, kBlue, kRed, kRed, kRed, kRed, kGreen, kGreen, kGreen, kGreen, kBlue, kBlue
#define kGGGGBBBBRRRR kGreen, kGreen, kGreen, kGreen, kBlue, kBlue, kBlue, kBlue, kRed, kRed, kRed, kRed
#define kGGBBBBRRRRGG kGreen, kGreen, kBlue, kBlue, kBlue, kBlue, kRed, kRed, kRed, kRed, kGreen, kGreen
#define kRRRRGGGGBBBB kRed, kRed, kRed, kRed, kGreen, kGreen, kGreen, kGreen, kBlue, kBlue, kBlue, kBlue
/*
kGGRRRRBBBBGG
kGGRRRRBBBBGG
kGGRRRRBBBBGG
kGGRRRRBBBBGG
kBBBBGGGGRRRR
kBBBBGGGGRRRR
kBBBBGGGGRRRR
kBBBBGGGGRRRR
kBBRRRRGGGGBB
kBBRRRRGGGGBB
kBBRRRRGGGGBB
kBBRRRRGGGGBB
kGGGGBBBBRRRR
kGGGGBBBBRRRR
kGGGGBBBBRRRR
kGGGGBBBBRRRR
kGGBBBBRRRRGG
kGGBBBBRRRRGG
kGGBBBBRRRRGG
kGGBBBBRRRRGG
kRRRRGGGGBBBB
kRRRRGGGGBBBB
kRRRRGGGGBBBB
kRRRRGGGGBBBB
*/
if(shadow_y < 4)
{
const uint rgb_mask[kBGRAxis * kMaxShadowMaskSizeX] = { kGGRRRRBBBBGG, kBBRRRRGGGGBB, kGGBBBBRRRRGG };
colour_mask = rgb_mask[(lcd_subpixel_layout * kMaxShadowMaskSizeX) + mask];
}
else
{
const uint rgb_mask[kBGRAxis * kMaxShadowMaskSizeX] = { kBBBBGGGGRRRR, kGGGGBBBBRRRR, kRRRRGGGGBBBB };
colour_mask = rgb_mask[(lcd_subpixel_layout * kMaxShadowMaskSizeX) + mask];
}
#undef kMaxShadowMaskSizeX
#undef kMaxShadowMaskSizeY
#undef kGGRRRRBBBBGG
#undef kBBBBGGGGRRRR
#undef kBBRRRRGGGGBB
#undef kGGGGBBBBRRRR
#undef kGGBBBBRRRRGG
#undef kRRRRGGGGBBBB
break;
}
case k600TVL:
{
#define kMaxShadowMaskSizeX 12
#define kMaxShadowMaskSizeY 8
#define kGGRRRRBBBBGG kGreen, kGreen, kRed, kRed, kRed, kRed, kBlue, kBlue, kBlue, kBlue, kGreen, kGreen
#define kBBBBGGGGRRRR kBlue, kBlue, kBlue, kBlue, kGreen, kGreen, kGreen, kGreen, kRed, kRed, kRed, kRed
#define kBBRRRRGGGGBB kBlue, kBlue, kRed, kRed, kRed, kRed, kGreen, kGreen, kGreen, kGreen, kBlue, kBlue
#define kGGGGBBBBRRRR kGreen, kGreen, kGreen, kGreen, kBlue, kBlue, kBlue, kBlue, kRed, kRed, kRed, kRed
#define kGGBBBBRRRRGG kGreen, kGreen, kBlue, kBlue, kBlue, kBlue, kRed, kRed, kRed, kRed, kGreen, kGreen
#define kRRRRGGGGBBBB kRed, kRed, kRed, kRed, kGreen, kGreen, kGreen, kGreen, kBlue, kBlue, kBlue, kBlue
/*
kGGRRRRBBBBGG
kGGRRRRBBBBGG
kGGRRRRBBBBGG
kGGRRRRBBBBGG
kBBBBGGGGRRRR
kBBBBGGGGRRRR
kBBBBGGGGRRRR
kBBBBGGGGRRRR
kBBRRRRGGGGBB
kBBRRRRGGGGBB
kBBRRRRGGGGBB
kBBRRRRGGGGBB
kGGGGBBBBRRRR
kGGGGBBBBRRRR
kGGGGBBBBRRRR
kGGGGBBBBRRRR
kGGBBBBRRRRGG
kGGBBBBRRRRGG
kGGBBBBRRRRGG
kGGBBBBRRRRGG
kRRRRGGGGBBBB
kRRRRGGGGBBBB
kRRRRGGGGBBBB
kRRRRGGGGBBBB
*/
if(shadow_y < 4)
{
const uint rgb_mask[kBGRAxis * kMaxShadowMaskSizeX] = { kGGRRRRBBBBGG, kBBRRRRGGGGBB, kGGBBBBRRRRGG };
colour_mask = rgb_mask[(lcd_subpixel_layout * kMaxShadowMaskSizeX) + mask];
}
else
{
const uint rgb_mask[kBGRAxis * kMaxShadowMaskSizeX] = { kBBBBGGGGRRRR, kGGGGBBBBRRRR, kRRRRGGGGBBBB };
colour_mask = rgb_mask[(lcd_subpixel_layout * kMaxShadowMaskSizeX) + mask];
}
#undef kMaxShadowMaskSizeX
#undef kMaxShadowMaskSizeY
#undef kGGRRRRBBBBGG
#undef kBBBBGGGGRRRR
#undef kBBRRRRGGGGBB
#undef kGGGGBBBBRRRR
#undef kGGBBBBRRRRGG
#undef kRRRRGGGGBBBB
break;
}
case k800TVL:
{
#define kGRRBBG (kGreen << 0) | (kRed << 4) | (kRed << 8) | (kBlue << 12) | (kBlue << 16) | (kGreen << 20)
#define kBBGGRR (kBlue << 0) | (kBlue << 4) | (kGreen << 8) | (kGreen << 12) | (kRed << 16) | (kRed << 20)
#define kBRRGGB (kBlue << 0) | (kRed << 4) | (kRed << 8) | (kGreen << 12) | (kGreen << 16) | (kBlue << 20)
#define kGGBBRR (kGreen << 0) | (kGreen << 4) | (kBlue << 8) | (kBlue << 12) | (kRed << 16) | (kRed << 20)
#define kGBBRRG (kGreen << 0) | (kBlue << 4) | (kBlue << 8) | (kRed << 12) | (kRed << 16) | (kGreen << 20)
#define kRRGGBB (kRed << 0) | (kRed << 4) | (kGreen << 8) | (kGreen << 12) | (kBlue << 16) | (kBlue << 20)
/*
kGRRBBG
kGRRBBG
kBBGGRR
kBBGGRR
kBRRGGB
kBRRGGB
kGGBBRR
kGGBBRR
kGBBRRG
kGBBRRG
kRRGGBB
kRRGGBB
*/
const uint rgb_mask[kBGRAxis * 2] = { kGRRBBG, kBBGGRR, kBRRGGB, kGGBBRR, kGBBRRG, kRRGGBB };
if(shadow_y < 2)
{
colour_mask = (rgb_mask[(lcd_subpixel_layout * 2) + 0] >> (mask * 4)) & 0xF;
}
else
{
colour_mask = (rgb_mask[(lcd_subpixel_layout * 2) + 1] >> (mask * 4)) & 0xF;
}
#undef kGRRBBG
#undef kBBGGRR
#undef kBRRGGB
#undef kGGBBRR
#undef kGBBRRG
#undef kRRGGBB
break;
}
case k1000TVL:
{
#define kGRRBBG (kGreen << 0) | (kRed << 4) | (kRed << 8) | (kBlue << 12) | (kBlue << 16) | (kGreen << 20)
#define kBBGGRR (kBlue << 0) | (kBlue << 4) | (kGreen << 8) | (kGreen << 12) | (kRed << 16) | (kRed << 20)
#define kBRRGGB (kBlue << 0) | (kRed << 4) | (kRed << 8) | (kGreen << 12) | (kGreen << 16) | (kBlue << 20)
#define kGGBBRR (kGreen << 0) | (kGreen << 4) | (kBlue << 8) | (kBlue << 12) | (kRed << 16) | (kRed << 20)
#define kGBBRRG (kGreen << 0) | (kBlue << 4) | (kBlue << 8) | (kRed << 12) | (kRed << 16) | (kGreen << 20)
#define kRRGGBB (kRed << 0) | (kRed << 4) | (kGreen << 8) | (kGreen << 12) | (kBlue << 16) | (kBlue << 20)
/*
kGRRBBG