View difference between Paste ID: kTtt8iEJ and 9YqWv0Jp
SHOW: | | - or go back to the newest paste.
1
/*
2
3
	CRT - Guest - NTSC
4
5
	Copyright (C) 2018-2026 guest(r)
6
7
	Sega MS Blue Lift and Sega MD Pallete Fix fixes inspired by Azurfel
8
9
	contrast_sigmoid_inv function Copyright (C) 2020-2023 Dogway (Jose Linares)
10
11
	Incorporates many good ideas and suggestions from Dr. Venom.
12
13
	I would also like give thanks to many Libretro forums members for continuous feedback, suggestions and using the shader.
14
15
	This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
16
	as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
17
18
	This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19
	without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20
	See the GNU General Public License for more details.
21
22
	You should have received a copy of the GNU General Public License along with this program; if not,
23
	write to the Free Software Foundation, Inc, 59 Temple Place - STE 330, Boston, MA 02111-1307, USA.
24
25
	Ported to ReShade by DevilSingh with some help from guest(r)
26
27
*/
28
29
// ============================================================================
30
// crt-black_crush-koko (ReShade port by Jobima)
31
// ============================================================================
32
33
/////////////////////////////  GPL LICENSE NOTICE  /////////////////////////////
34
//
35
//  crt-black_crush-koko
36
//  Copyright (C) 2024 Antonio Orefice <[email protected]>
37
//
38
//  This program is free software; you can redistribute it and/or modify it
39
//  under the terms of the GNU General Public License as published by the Free
40
//  Software Foundation; either version 3 of the License, or any later version.
41
//
42
////////////////////////////////////////////////////////////////////////////////
43
44
uniform float bth <
45
	ui_category = "Afterglow Settings";
46
	ui_type = "drag";
47
	ui_min = 1.0;
48
	ui_max = 125.0;
49
	ui_step = 1.0;
50
	ui_label = "Afterglow Effect Threshold";
51
> = 10.0;
52
53
uniform float PR <
54
	ui_category = "Afterglow Settings";
55
	ui_type = "drag";
56
	ui_min = 0.0;
57
	ui_max = 0.5;
58
	ui_step = 0.01;
59
	ui_label = "Persistence Red";
60
> = 0.32;
61
62
uniform float PG <
63
	ui_category = "Afterglow Settings";
64
	ui_type = "drag";
65
	ui_min = 0.0;
66
	ui_max = 0.5;
67
	ui_step = 0.01;
68
	ui_label = "Persistence Green";
69
> = 0.32;
70
71
uniform float PB <
72
	ui_category = "Afterglow Settings";
73
	ui_type = "drag";
74
	ui_min = 0.0;
75
	ui_max = 0.5;
76
	ui_step = 0.01;
77
	ui_label = "Persistence Blue";
78
> = 0.32;
79
80
uniform float AS <
81
	ui_category = "Afterglow Settings";
82
	ui_type = "drag";
83
	ui_min = 0.0;
84
	ui_max = 0.6;
85
	ui_step = 0.01;
86
	ui_label = "Afterglow Strength";
87
> = 0.1;
88
89
uniform float ST <
90
	ui_category = "Afterglow Settings";
91
	ui_type = "drag";
92
	ui_min = 0.0;
93
	ui_max = 1.0;
94
	ui_step = 0.01;
95
	ui_label = "Afterglow saturation";
96
> = 0.5;
97
98
uniform float CS <
99
	ui_category = "Color Tweaks";
100
	ui_type = "drag";
101
	ui_min = 0.0;
102
	ui_max = 5.0;
103
	ui_step = 1.0;
104
	ui_label = "Display Gamut: sRGB | Modern | DCI | Adobe | Rec. 2020 | P3";
105
> = 0.0;
106
107
uniform float CP <
108
	ui_category = "Color Tweaks";
109
	ui_type = "drag";
110
	ui_min = -1.0;
111
	ui_max = 5.0;
112
	ui_step = 1.0;
113
	ui_label = "CRT Profile: EBU | P22 | SMPTE-C | Philips | Trinitron";
114
> = 0.0;
115
116
uniform float TNTC <
117
	ui_category = "Color Tweaks";
118
	ui_type = "drag";
119
	ui_min = 0.0;
120
	ui_max = 4.0;
121
	ui_step = 1.0;
122
	ui_label = "LUT Colors: NTSC-J | Trinitron | Nec MultiSync | NTSC 1953";
123
> = 0.0;
124
125
uniform float LUTLOW <
126
	ui_category = "Color Tweaks";
127
	ui_type = "drag";
128
	ui_min = 0.0;
129
	ui_max = 50.0;
130
	ui_step = 1.0;
131
	ui_label = "Fix LUT Dark Range";
132
> = 5.0;
133
134
uniform float LUTBR <
135
	ui_category = "Color Tweaks";
136
	ui_type = "drag";
137
	ui_min = 0.0;
138
	ui_max = 1.0;
139
	ui_step = 0.01;
140
	ui_label = "Fix LUT Brightness";
141
> = 1.0;
142
143
uniform float LS <
144
	ui_category = "Color Tweaks";
145
	ui_type = "drag";
146
	ui_min = 16.0;
147
	ui_max = 64.0;
148
	ui_step = 16.0;
149
	ui_label = "LUT Size";
150
> = 32.0;
151
152
uniform float WP <
153
	ui_category = "Color Tweaks";
154
	ui_type = "drag";
155
	ui_min = -100.0;
156
	ui_max = 100.0;
157
	ui_step = 5.0;
158
	ui_label = "Color Temperature %";
159
> = 0.0;
160
161
uniform float wp_saturation <
162
	ui_category = "Color Tweaks";
163
	ui_type = "drag";
164
	ui_min = 0.0;
165
	ui_max = 2.0;
166
	ui_step = 0.05;
167
	ui_label = "Saturation Adjustment";
168
> = 0.95;
169
170
uniform float pre_bb <
171
	ui_category = "Color Tweaks";
172
	ui_type = "drag";
173
	ui_min = 0.0;
174
	ui_max = 2.0;
175
	ui_step = 0.01;
176
	ui_label = "Brightness Adjustment";
177
> = 1.0;
178
179
uniform float contra <
180
	ui_category = "Color Tweaks";
181
	ui_type = "drag";
182
	ui_min = -2.0;
183
	ui_max = 2.0;
184
	ui_step = 0.05;
185
	ui_label = "Contrast Adjustment";
186
> = 0.2;
187
188
uniform float pre_gc <
189
	ui_category = "Color Tweaks";
190
	ui_type = "drag";
191
	ui_min = 0.5;
192
	ui_max = 1.75;
193
	ui_step = 0.025;
194
	ui_label = "Gamma Correct Adjustment";
195
> = 1.025;
196
197
uniform float sega_fix <
198
	ui_category = "Color Tweaks";
199
	ui_type = "drag";
200
	ui_min = 0.0;
201
	ui_max = 1.0;
202
	ui_step = 1.0;
203
	ui_label = "Sega Brightness Fix";
204
> = 0.0;
205
206
uniform float segams <
207
	ui_category = "Color Tweaks";
208
	ui_type = "drag";
209
	ui_min = 0.0;
210
	ui_max = 1.0;
211
	ui_step = 1.0;
212
	ui_label = "Sega MS Blue Lift";
213
> = 0.0;
214
215
uniform float segapal <
216
	ui_category = "Color Tweaks";
217
	ui_type = "drag";
218
	ui_min = 0.0;
219
	ui_max = 1.0;
220
	ui_step = 1.0;
221
	ui_label = "Sega MD Pallete Fix";
222
> = 0.0;
223
224
uniform float BP <
225
	ui_category = "Color Tweaks";
226
	ui_type = "drag";
227
	ui_min = -100.0;
228
	ui_max = 0.0;
229
	ui_step = 1.0;
230
	ui_label = "Lower Black Level";
231
> = 0.0;
232
233
uniform float BP1 <
234
	ui_category = "Color Tweaks";
235
	ui_type = "drag";
236
	ui_min = 0.0;
237
	ui_max = 25.0;
238
	ui_step = 1.0;
239
	ui_label = "Raise Black Level";
240
> = 0.0;
241
242
uniform float vigstr <
243
	ui_category = "Color Tweaks";
244
	ui_type = "drag";
245
	ui_min = 0.0;
246
	ui_max = 2.0;
247
	ui_step = 0.05;
248
	ui_label = "Vignette Strength";
249
> = 0.0;
250
251
uniform float vigdef <
252
	ui_category = "Color Tweaks";
253
	ui_type = "drag";
254
	ui_min = 0.5;
255
	ui_max = 3.0;
256
	ui_step = 0.1;
257
	ui_label = "Vignette Size";
258
> = 1.0;
259
260
uniform float interr <
261
	ui_category = "Interlacing Options";
262
	ui_type = "drag";
263
	ui_min = 0.0;
264
	ui_max = 800.0;
265
	ui_step = 25.0;
266
	ui_label = "Interlace Trigger Resolution";
267
> = 400.0;
268
269
uniform float interm <
270
	ui_category = "Interlacing Options";
271
	ui_type = "drag";
272
	ui_min = 0.0;
273
	ui_max = 6.0;
274
	ui_step = 1.0;
275
	ui_label = "Interlace Mode: 0:OFF | 1-3,6:Normal | 4-5:Interpolation";
276
> = 4.0;
277
278
uniform float iscanb <
279
	ui_category = "Interlacing Options";
280
	ui_type = "drag";
281
	ui_min = 0.0;
282
	ui_max = 1.0;
283
	ui_step = 0.05;
284
	ui_label = "Interlacing Scanline Effect ('Laced Brightness)";
285
> = 0.2;
286
287
uniform float intres <
288
	ui_category = "Resolution/Scaling Options";
289
	ui_type = "drag";
290
	ui_min = 0.0;
291
	ui_max = 10.0;
292
	ui_step = 0.5;
293
	ui_label = "Internal Resolution Y: 0.5...y-dowsample divider";
294
> = 0.0;
295
296
uniform float downsample_levelx <
297
	ui_category = "Resolution/Scaling Options";
298
	ui_type = "drag";
299
	ui_min = 0.0;
300
	ui_max = 2.0;
301
	ui_step = 0.05;
302
	ui_label = "Downsampling-X (High-res content, pre-scalers)";
303
> = 0.0;
304
305
uniform float downsample_levely <
306
	ui_category = "Resolution/Scaling Options";
307
	ui_type = "drag";
308
	ui_min = 0.0;
309
	ui_max = 2.0;
310
	ui_step = 0.05;
311
	ui_label = "Downsampling-Y (High-res content, pre-scalers)";
312
> = 0.0;
313
314
uniform float iscans <
315
	ui_category = "Resolution/Scaling Options";
316
	ui_type = "drag";
317
	ui_min = 0.0;
318
	ui_max = 1.0;
319
	ui_step = 0.05;
320
	ui_label = "Interlacing (Scanline) Saturation";
321
> = 0.25;
322
323
uniform float hiscan <
324
	ui_category = "Resolution/Scaling Options";
325
	ui_type = "drag";
326
	ui_min = 0.0;
327
	ui_max = 1.0;
328
	ui_step = 1.0;
329
	ui_label = "High Resolution Scanlines (prepend a scaler...)";
330
> = 0.0;
331
332
uniform float filter_res <
333
	ui_category = "Resolution/Scaling Options";
334
	ui_type = "drag";
335
	ui_min = 0.5;
336
	ui_max = 8.0;
337
	ui_step = 0.05;
338
	ui_label = "Horizontal Filtering Resolution";
339
> = 1.0;
340
341
uniform float speedup <
342
	ui_category = "Resolution/Scaling Options";
343
	ui_type = "drag";
344
	ui_min = 1.0;
345
	ui_max = 4.0;
346
	ui_step = 1.0;
347
	ui_label = "Speedup w. higher Internal Res.";
348
> = 1.0;
349
350
uniform float auto_res <
351
	ui_category = "Resolution/Scaling Options";
352
	ui_type = "drag";
353
	ui_min = 0.0;
354
	ui_max = 1.0;
355
	ui_step = 1.0;
356
	ui_label = "SNES/Amiga Hi-Res Auto Mode";
357
> = 0.0;
358
359
uniform float chr_freq <
360
	ui_category = "NTSC Settings";
361
	ui_type = "drag";
362
	ui_min = 1.0;
363
	ui_max = 2.0;
364
	ui_step = 1.0;
365
	ui_label = "Chroma Frequency: Default : Pixel Count";
366
> = 1.0;
367
368
uniform float cust_artifacting <
369
	ui_category = "NTSC Settings";
370
	ui_type = "drag";
371
	ui_min = 0.0;
372
	ui_max = 5.0;
373
	ui_step = 0.1;
374
	ui_label = "NTSC Artifacting Value";
375
> = 0.2;
376
377
uniform float cust_fringing <
378
	ui_category = "NTSC Settings";
379
	ui_type = "drag";
380
	ui_min = 0.0;
381
	ui_max = 5.0;
382
	ui_step = 0.1;
383
	ui_label = "NTSC Fringing Value";
384
> = 0.1;
385
386
uniform float ntsc_fields <
387
	ui_category = "NTSC Settings";
388
	ui_type = "drag";
389
	ui_min = -1.0;
390
	ui_max = 1.0;
391
	ui_step = 1.0;
392
	ui_label = "NTSC Merge Fields: Auto | No | Yes";
393
> = -1.0;
394
395
uniform float ntsc_phase <
396
	ui_category = "NTSC Settings";
397
	ui_type = "drag";
398
	ui_min = 1.0;
399
	ui_max = 5.0;
400
	ui_step = 1.0;
401
	ui_label = "NTSC Phase: Auto | 2 Phase | 3 Phase | Mixed | PCE";
402
> = 1.0;
403
404
uniform float nscale <
405
	ui_category = "NTSC Settings";
406
	ui_type = "drag";
407
	ui_min = 0.2;
408
	ui_max = 5.0;
409
	ui_step = 0.05;
410
	ui_label = "NTSC Filter (Resolution) Scaling";
411
> = 1.27;
412
413
uniform float ntsc_dith <
414
	ui_category = "NTSC Settings";
415
	ui_type = "drag";
416
	ui_min = -0.01;
417
	ui_max = 2.5;
418
	ui_step = 0.01;
419
	ui_label = "NTSC De-dithering Booster: -0.01 : Auto | 0.0 : OFF";
420
> = -0.01;
421
422
uniform float ntsc_sat <
423
	ui_category = "NTSC Settings";
424
	ui_type = "drag";
425
	ui_min = 0.0;
426
	ui_max = 2.0;
427
	ui_step = 0.01;
428
	ui_label = "NTSC Color Saturation";
429
> = 1.07;
430
431
uniform float ntsc_brt <
432
	ui_category = "NTSC Settings";
433
	ui_type = "drag";
434
	ui_min = 0.0;
435
	ui_max = 1.5;
436
	ui_step = 0.01;
437
	ui_label = "NTSC Brightness";
438
> = 1.0;
439
440
uniform float ntsc_gamma <
441
	ui_category = "NTSC Settings";
442
	ui_type = "drag";
443
	ui_min = 0.25;
444
	ui_max = 2.5;
445
	ui_step = 0.025;
446
	ui_label = "NTSC Filtering Gamma Correction";
447
> = 1.125;
448
449
uniform float ntsc_rainbow <
450
	ui_category = "NTSC Settings";
451
	ui_type = "drag";
452
	ui_min = 0.0;
453
	ui_max = 3.0;
454
	ui_step = 1.0;
455
	ui_label = "NTSC Coloring/Rainbow Effect (2-phase)";
456
> = 2.0;
457
458
uniform float ntsc_taps <
459
	ui_category = "NTSC Settings";
460
	ui_type = "drag";
461
	ui_min = 6.0;
462
	ui_max = 32.0;
463
	ui_step = 1.0;
464
	ui_label = "NTSC # of Taps (Filter Width)";
465
> = 16.0;
466
467
uniform float ntsc_charp1 <
468
	ui_category = "NTSC Settings";
469
	ui_type = "drag";
470
	ui_min = 0.0;
471
	ui_max = 10.0;
472
	ui_step = 0.5;
473
	ui_label = "NTSC Preserve 'Edge' Colors (2-phase)";
474
> = 5.0;
475
476
uniform float ntsc_charp2 <
477
	ui_category = "NTSC Settings";
478
	ui_type = "drag";
479
	ui_min = 0.0;
480
	ui_max = 10.0;
481
	ui_step = 0.5;
482
	ui_label = "NTSC Preserve 'Edge' Colors (3-phase)";
483
> = 3.0;
484
485
uniform float ntsc_cscale1 <
486
	ui_category = "NTSC Settings";
487
	ui_type = "drag";
488
	ui_min = 0.2;
489
	ui_max = 5.00;
490
	ui_step = 0.05;
491
	ui_label = "NTSC Chroma Scaling/Bleeding (2-phase)";
492
> = 1.5;
493
494
uniform float ntsc_cscale2 <
495
	ui_category = "NTSC Settings";
496
	ui_type = "drag";
497
	ui_min = 0.2;
498
	ui_max = 2.5;
499
	ui_step = 0.05;
500
	ui_label = "NTSC Chroma Scaling/Bleeding (3-phase)";
501
> = 1.0;
502
503
uniform float ntsc_ring <
504
	ui_category = "NTSC Settings";
505
	ui_type = "drag";
506
	ui_min = 0.0;
507
	ui_max = 1.0;
508
	ui_step = 0.1;
509
	ui_label = "NTSC Anti-Ringing";
510
> = 0.9;
511
512
uniform float ntsc_shrp <
513
	ui_category = "NTSC Settings";
514
	ui_type = "drag";
515
	ui_min = -10.0;
516
	ui_max = 10.0;
517
	ui_step = 0.5;
518
	ui_label = "NTSC Sharpness (Adaptive)";
519
> = -2.5;
520
521
uniform float ntsc_fonts <
522
	ui_category = "NTSC Settings";
523
	ui_type = "drag";
524
	ui_min = 0.25;
525
	ui_max = 0.75;
526
	ui_step = 0.01;
527
	ui_label = "NTSC Preserve Fonts (0.25 = OFF)";
528
> = 0.45;
529
530
uniform float ntsc_shpe <
531
	ui_category = "NTSC Settings";
532
	ui_type = "drag";
533
	ui_min = 0.5;
534
	ui_max = 1.0;
535
	ui_step = 0.025;
536
	ui_label = "NTSC Sharpness Shape";
537
> = 0.5;
538
539
uniform float RFNOISE <
540
	ui_category = "RF Noise Options";
541
	ui_type = "drag";
542
	ui_min = 0.0;
543
	ui_max = 1.0;
544
	ui_step = 0.01;
545
	ui_label = "NTSC RF Noise Frequency";
546
> = 0.30;
547
548
uniform float RFNOISE1 <
549
	ui_category = "RF Noise Options";
550
	ui_type = "drag";
551
	ui_min = 0.0;
552
	ui_max = 0.7;
553
	ui_step = 0.01;
554
	ui_label = "NTSC RF Noise Luma+";
555
> = 0.01;
556
557
uniform float RFNOISE2 <
558
	ui_category = "RF Noise Options";
559
	ui_type = "drag";
560
	ui_min = 0.0;
561
	ui_max = 0.7;
562
	ui_step = 0.01;
563
	ui_label = "NTSC RF Noise Chroma+";
564
> = 0.01;
565
566
uniform float CSHARPEN <
567
	ui_category = "FSharpen";
568
	ui_type = "drag";
569
	ui_min = 0.0;
570
	ui_max = 5.0;
571
	ui_step = 0.1;
572
	ui_label = "FSharpen - Sharpen Strength";
573
> = 0.5;
574
575
uniform float CCONTR <
576
	ui_category = "FSharpen";
577
	ui_type = "drag";
578
	ui_min = 0.0;
579
	ui_max = 0.25;
580
	ui_step = 0.01;
581
	ui_label = "FSharpen - Sharpen (+ Deb) Contrast";
582
> = 0.05;
583
584
uniform float CDETAILS <
585
	ui_category = "FSharpen";
586
	ui_type = "drag";
587
	ui_min = 0.0;
588
	ui_max = 1.0;
589
	ui_step = 0.05;
590
	ui_label = "FSharpen - Details sharpened";
591
> = 0.25;
592
593
uniform float NDEBLUR <
594
	ui_category = "FSharpen";
595
	ui_type = "drag";
596
	ui_min = 1.0;
597
	ui_max = 8.0;
598
	ui_step = 0.25;
599
	ui_label = "FSharpen - Deblur Strength";
600
> = 1.5;
601
602
uniform float DSMART <
603
	ui_category = "FSharpen";
604
	ui_type = "drag";
605
	ui_min = 0.0;
606
	ui_max = 1.0;
607
	ui_step = 1.0;
608
	ui_label = "FSharpen - Smart 'Dithering' Deblur";
609
> = 1.0;
610
611
uniform float DREDGE <
612
	ui_category = "FSharpen";
613
	ui_type = "drag";
614
	ui_min = 0.7;
615
	ui_max = 1.0;
616
	ui_step = 0.01;
617
	ui_label = "FSharpen - Deblur Edges Falloff";
618
> = 0.92;
619
620
uniform float DSHARP <
621
	ui_category = "FSharpen";
622
	ui_type = "drag";
623
	ui_min = 0.0;
624
	ui_max = 4.0;
625
	ui_step = 0.2;
626
	ui_label = "FSharpen - Deblur Extra Sharpen";
627
> = 1.0;
628
629
uniform float ADPT_BLK_RANGE <
630
	ui_category = "crt-black_crush-koko";
631
    ui_type = "slider";
632
    ui_label = "CRT Black Crush (<0: Darker gamma, >0: Black Crush)";
633
    ui_min = -2.0;
634
    ui_max =  2.0;
635
    ui_step = 0.1;
636
> = 0.05;
637
638
uniform float lsmooth <
639
	ui_category = "Raster Bloom Options";
640
	ui_type = "drag";
641
	ui_min = 0.5;
642
	ui_max = 1.0;
643
	ui_step = 0.01;
644
	ui_label = "Raster Bloom Effect Smoothing";
645
> = 0.75;
646
647
uniform float lsdev <
648
	ui_category = "Raster Bloom Options";
649
	ui_type = "drag";
650
	ui_min = -0.25;
651
	ui_max = 0.25;
652
	ui_step = 0.01;
653
	ui_label = "Raster Bloom Smoothing Bright Deviation";
654
> = 0.05;
655
656
uniform float OS <
657
	ui_category = "Raster Bloom Options";
658
	ui_type = "drag";
659
	ui_min = 0.0;
660
	ui_max = 2.0;
661
	ui_step = 1.0;
662
	ui_label = "R. Bloom Overscan Mode";
663
> = 1.0;
664
665
uniform float blm_2 <
666
	ui_category = "Raster Bloom Options";
667
	ui_type = "drag";
668
	ui_min = 0.0;
669
	ui_max = 20.0;
670
	ui_step = 1.0;
671
	ui_label = "Raster bloom %";
672
> = 1.0;
673
674
uniform float gamma_i <
675
	ui_category = "Gamma Options";
676
	ui_type = "drag";
677
	ui_min = 1.0;
678
	ui_max = 5.0;
679
	ui_step = 0.05;
680
	ui_label = "Gamma Input";
681
> = 2.20;
682
683
uniform float gamma_o <
684
	ui_category = "Gamma Options";
685
	ui_type = "drag";
686
	ui_min = 1.0;
687
	ui_max = 5.0;
688
	ui_step = 0.05;
689
	ui_label = "Gamma out";
690
> = 2.20;
691
692
uniform float HSHARPNESS <
693
	ui_category = "Filtering Options";
694
	ui_type = "drag";
695
	ui_min = 1.0;
696
	ui_max = 8.0;
697
	ui_step = 0.05;
698
	ui_label = "Horizontal Filter Range";
699
> = 1.55;
700
701
uniform float LIGMA_H <
702
	ui_category = "Filtering Options";
703
	ui_type = "drag";
704
	ui_min = 0.15;
705
	ui_max = 1.0;
706
	ui_step = 0.01;
707
	ui_label = "Horizontal Blur Sigma";
708
> = 0.55;
709
710
uniform float S_SHARP <
711
	ui_category = "Filtering Options";
712
	ui_type = "drag";
713
	ui_min = 0.0;
714
	ui_max = 3.0;
715
	ui_step = 0.05;
716
	ui_label = "Substractive Sharpness";
717
> = 0.4;
718
719
uniform float MAXS <
720
	ui_category = "Filtering Options";
721
	ui_type = "drag";
722
	ui_min = 0.0;
723
	ui_max = 0.3;
724
	ui_step = 0.01;
725
	ui_label = "Maximum Sharpness";
726
> = 0.05;
727
728
uniform float SSRNG <
729
	ui_category = "Filtering Options";
730
	ui_type = "drag";
731
	ui_min = 0.0;
732
	ui_max = 4.0;
733
	ui_step = 0.05;
734
	ui_label = "Substractive Sharpness Ringing";
735
> = 0.15;
736
737
uniform float spike <
738
	ui_category = "Filtering Options";
739
	ui_type = "drag";
740
	ui_min = 0.0;
741
	ui_max = 2.0;
742
	ui_step = 0.1;
743
	ui_label = "Scanline Spike Removal";
744
> = 0.9;
745
746
uniform float m_glow <
747
	ui_category = "Magic Glow Settings";
748
	ui_type = "drag";
749
	ui_min = 0.0;
750
	ui_max = 2.0;
751
	ui_step = 1.0;
752
	ui_label = "Ordinary Glow | Magic Glow";
753
> = 2.0;
754
755
uniform float m_glow_cutoff <
756
	ui_category = "Magic Glow Settings";
757
	ui_type = "drag";
758
	ui_min = 0.0;
759
	ui_max = 0.4;
760
	ui_step = 0.01;
761
	ui_label = "Magic Glow Cutoff";
762
> = 0.12;
763
764
uniform float m_glow_low <
765
	ui_category = "Magic Glow Settings";
766
	ui_type = "drag";
767
	ui_min = 0.0;
768
	ui_max = 7.0;
769
	ui_step = 0.05;
770
	ui_label = "Magic Glow Low Strength";
771
> = 5.00;
772
773
uniform float m_glow_high <
774
	ui_category = "Magic Glow Settings";
775
	ui_type = "drag";
776
	ui_min = 0.0;
777
	ui_max = 7.0;
778
	ui_step = 0.1;
779
	ui_label = "Magic Glow High Strength";
780
> = 5.0;
781
782
uniform float m_glow_dist <
783
	ui_category = "Magic Glow Settings";
784
	ui_type = "drag";
785
	ui_min = 0.2;
786
	ui_max = 4.0;
787
	ui_step = 0.05;
788
	ui_label = "Magic Glow Distribution";
789
> = 0.7;
790
791
uniform float m_glow_mask <
792
	ui_category = "Magic Glow Settings";
793
	ui_type = "drag";
794
	ui_min = 0.0;
795
	ui_max = 2.0;
796
	ui_step = 0.025;
797
	ui_label = "Magic Glow Mask Strength";
798
> = 0.6;
799
800
uniform float FINE_GAUSS <
801
	ui_category = "Magic Glow Settings";
802
	ui_type = "drag";
803
	ui_min = -1.0;
804
	ui_max = 5.0;
805
	ui_step = 1.0;
806
	ui_label = "Fine Glow/M.Glow Sampling";
807
> = 5.0;
808
809
uniform float SIZEH <
810
	ui_category = "Glow Pass Settings";
811
	ui_type = "drag";
812
	ui_min = 1.0;
813
	ui_max = 50.0;
814
	ui_step = 1.0;
815
	ui_label = "Horizontal Glow Radius";
816
> = 6.0;
817
818
uniform float SIGMA_H <
819
	ui_category = "Glow Pass Settings";
820
	ui_type = "drag";
821
	ui_min = 0.2;
822
	ui_max = 15.0;
823
	ui_step = 0.05;
824
	ui_label = "Horizontal Glow Sigma";
825
> = 1.2;
826
827
uniform float SIZEV <
828
	ui_category = "Glow Pass Settings";
829
	ui_type = "drag";
830
	ui_min = 1.0;
831
	ui_max = 50.0;
832
	ui_step = 1.0;
833
	ui_label = "Vertical Glow Radius";
834
> = 6.0;
835
836
uniform float SIGMA_V <
837
	ui_category = "Glow Pass Settings";
838
	ui_type = "drag";
839
	ui_min = 0.2;
840
	ui_max = 15.0;
841
	ui_step = 0.05;
842
	ui_label = "Vertical Glow Sigma";
843
> = 1.2;
844
845
uniform float FINE_BLOOM <
846
	ui_category = "Bloom/Halation (Glow) Pass Settings";
847
	ui_type = "drag";
848
	ui_min = -1.0;
849
	ui_max = 5.0;
850
	ui_step = 1.0;
851
	ui_label = "Fine Bloom/Halation Sampling";
852
> = 3.0;
853
854
uniform float SIZEX <
855
	ui_category = "Bloom/Halation (Glow) Pass Settings";
856
	ui_type = "drag";
857
	ui_min = 1.0;
858
	ui_max = 50.0;
859
	ui_step = 1.0;
860
	ui_label = "Horizontal Bloom/Halation Radius";
861
> = 3.0;
862
863
uniform float SIGMA_X <
864
	ui_category = "Bloom/Halation (Glow) Pass Settings";
865
	ui_type = "drag";
866
	ui_min = 0.25;
867
	ui_max = 3.0;
868
	ui_step = 0.01;
869
	ui_label = "Horizontal Bloom/Halation Sigma";
870
> = 0.75;
871
872
uniform float SIZEY <
873
	ui_category = "Bloom/Halation (Glow) Pass Settings";
874
	ui_type = "drag";
875
	ui_min = 1.0;
876
	ui_max = 50.0;
877
	ui_step = 1.0;
878
	ui_label = "Vertical Bloom/Halation Radius";
879
> = 3.0;
880
881
uniform float SIGMA_Y <
882
	ui_category = "Bloom/Halation (Glow) Pass Settings";
883
	ui_type = "drag";
884
	ui_min = 0.25;
885
	ui_max = 15.0;
886
	ui_step = 0.025;
887
	ui_label = "Vertical Bloom/Halation Sigma";
888
> = 0.60;
889
890
uniform float glow <
891
	ui_category = "Brightness Settings";
892
	ui_type = "drag";
893
	ui_min = -2.0;
894
	ui_max = 2.0;
895
	ui_step = 0.01;
896
	ui_label = "(Magic) Glow Strength";
897
> = 0.10;
898
899
uniform float blm_1 <
900
	ui_category = "Brightness Settings";
901
	ui_type = "drag";
902
	ui_min = -2.0;
903
	ui_max = 2.0;
904
	ui_step = 0.05;
905
	ui_label = "Bloom Strength";
906
> = 0.10;
907
908
uniform float mask_bloom <
909
	ui_category = "Brightness Settings";
910
	ui_type = "drag";
911
	ui_min = -2.0;
912
	ui_max = 2.0;
913
	ui_step = 0.05;
914
	ui_label = "Mask Bloom";
915
> = 0.5;
916
917
uniform float bloom_dist <
918
	ui_category = "Brightness Settings";
919
	ui_type = "drag";
920
	ui_min = -2.0;
921
	ui_max = 3.0;
922
	ui_step = 0.05;
923
	ui_label = "Bloom Distribution";
924
> = 0.05;
925
926
uniform float halation <
927
	ui_category = "Brightness Settings";
928
	ui_type = "drag";
929
	ui_min = -2.0;
930
	ui_max = 2.0;
931
	ui_step = 0.025;
932
	ui_label = "Halation Strength";
933
> = -0.1;
934
935
uniform float b_mask <
936
	ui_category = "Brightness Settings";
937
	ui_type = "drag";
938
	ui_min = -1.0;
939
	ui_max = 1.0;
940
	ui_step = 0.025;
941
	ui_label = "Bloom Mask Strength";
942
> = -0.1;
943
944
uniform float h_mask <
945
	ui_category = "Brightness Settings";
946
	ui_type = "drag";
947
	ui_min = -1.0;
948
	ui_max = 1.0;
949
	ui_step = 0.025;
950
	ui_label = "Halation Mask Strength";
951
> = -0.75;
952
953
uniform float gamma_c <
954
	ui_category = "Brightness Settings";
955
	ui_type = "drag";
956
	ui_min = 0.5;
957
	ui_max = 2.0;
958
	ui_step = 0.025;
959
	ui_label = "Gamma correct";
960
> = 1.025;
961
962
uniform float gamma_d <
963
	ui_category = "Brightness Settings";
964
	ui_type = "drag";
965
	ui_min = 1.0;
966
	ui_max = 2.0;
967
	ui_step = 0.025;
968
	ui_label = "Complementary Gamma Correct";
969
> = 1.15;
970
971
uniform float brightboost1 <
972
	ui_category = "Brightness Settings";
973
	ui_type = "drag";
974
	ui_min = 0.25;
975
	ui_max = 10.0;
976
	ui_step = 0.05;
977
	ui_label = "Bright Boost Dark Pixels";
978
> = 1.4;
979
980
uniform float brightboost2 <
981
	ui_category = "Brightness Settings";
982
	ui_type = "drag";
983
	ui_min = 0.25;
984
	ui_max = 3.0;
985
	ui_step = 0.025;
986
	ui_label = "Bright Boost Bright Pixels";
987
> = 1.1;
988
989
uniform float clp <
990
	ui_category = "Brightness Settings";
991
	ui_type = "drag";
992
	ui_min = -1.0;
993
	ui_max = 1.0;
994
	ui_step = 0.05;
995
	ui_label = "Clip Saturated Color Beams";
996
> = 0.25;
997
998
uniform float bloomsamp <
999
	ui_category = "Brightness Settings";
1000
	ui_type = "drag";
1001
	ui_min = 0.0;
1002
	ui_max = 2.0;
1003
	ui_step = 1.0;
1004
	ui_label = "Bloom Pixel Sampling";
1005
> = 2.0;
1006
1007
uniform float gsl <
1008
	ui_category = "Scanline Options";
1009
	ui_type = "drag";
1010
	ui_min = -1.0;
1011
	ui_max = 2.0;
1012
	ui_step = 1.0;
1013
	ui_label = "Scanline Type";
1014
> = 2.0;
1015
1016
uniform float scanline1 <
1017
	ui_category = "Scanline Options";
1018
	ui_type = "drag";
1019
	ui_min = -20.0;
1020
	ui_max = 40.0;
1021
	ui_step = 0.5;
1022
	ui_label = "Scanline Beam Shape Center";
1023
> = 8.0;
1024
1025
uniform float scanline2 <
1026
	ui_category = "Scanline Options";
1027
	ui_type = "drag";
1028
	ui_min = 0.0;
1029
	ui_max = 70.0;
1030
	ui_step = 1.0;
1031
	ui_label = "Scanline Beam Shape Edges";
1032
> = 4.0;
1033
1034
uniform float beam_min <
1035
	ui_category = "Scanline Options";
1036
	ui_type = "drag";
1037
	ui_min = 0.25;
1038
	ui_max = 10.0;
1039
	ui_step = 0.05;
1040
	ui_label = "Scanline Shape Dark Pixels";
1041
> = 3.0;
1042
1043
uniform float beam_max <
1044
	ui_category = "Scanline Options";
1045
	ui_type = "drag";
1046
	ui_min = 0.2;
1047
	ui_max = 3.5;
1048
	ui_step = 0.025;
1049
	ui_label = "Scanline Shape Bright Pixels";
1050
> = 1.0;
1051
1052
uniform float tds <
1053
	ui_category = "Scanline Options";
1054
	ui_type = "drag";
1055
	ui_min = 0.0;
1056
	ui_max = 1.0;
1057
	ui_step = 1.0;
1058
	ui_label = "Thinner Dark Scanlines";
1059
> = 0.0;
1060
1061
uniform float beam_size <
1062
	ui_category = "Scanline Options";
1063
	ui_type = "drag";
1064
	ui_min = 0.0;
1065
	ui_max = 1.0;
1066
	ui_step = 0.05;
1067
	ui_label = "Increased Bright Scanline Beam";
1068
> = 0.5;
1069
1070
uniform float scans <
1071
	ui_category = "Scanline Options";
1072
	ui_type = "drag";
1073
	ui_min = 0.0;
1074
	ui_max = 6.0;
1075
	ui_step = 0.1;
1076
	ui_label = "Scanline Saturation / Mask Falloff";
1077
> = 0.7;
1078
1079
uniform float scan_falloff <
1080
	ui_category = "Scanline Options";
1081
	ui_type = "drag";
1082
	ui_min = 0.1;
1083
	ui_max = 2.0;
1084
	ui_step = 0.025;
1085
	ui_label = "Scanline Falloff";
1086
> = 0.2;
1087
1088
uniform float ssharp <
1089
	ui_category = "Scanline Options";
1090
	ui_type = "drag";
1091
	ui_min = 0.0;
1092
	ui_max = 0.5;
1093
	ui_step = 0.01;
1094
	ui_label = "Smart Sharpen Scanlines";
1095
> = 0.01;
1096
1097
uniform float scangamma <
1098
	ui_category = "Scanline Options";
1099
	ui_type = "drag";
1100
	ui_min = 0.5;
1101
	ui_max = 5.0;
1102
	ui_step = 0.05;
1103
	ui_label = "Scanline Gamma";
1104
> = 2.4;
1105
1106
uniform float rolling_scan <
1107
	ui_category = "Scanline Options";
1108
	ui_type = "drag";
1109
	ui_min = -1.0;
1110
	ui_max = 1.0;
1111
	ui_step = 0.01;
1112
	ui_label = "Rolling Scanlines";
1113
> = 0.0;
1114
1115
uniform float no_scanlines <
1116
	ui_category = "Scanline Options";
1117
	ui_type = "drag";
1118
	ui_min = 0.0;
1119
	ui_max = 1.5;
1120
	ui_step = 0.05;
1121
	ui_label = "No-scanline Mode";
1122
> = 0.0;
1123
1124
uniform float IOS <
1125
	ui_category = "Screen Options";
1126
	ui_type = "drag";
1127
	ui_min = 0.0;
1128
	ui_max = 4.0;
1129
	ui_step = 1.0;
1130
	ui_label = "Integer Scaling: Odd:Y | Even:'X'+Y";
1131
> = 0.0;
1132
1133
uniform float warpx <
1134
	ui_category = "Screen Options";
1135
	ui_type = "drag";
1136
	ui_min = 0.0;
1137
	ui_max = 0.25;
1138
	ui_step = 0.01;
1139
	ui_label = "Curvature X (Default 0.03)";
1140
> = 0.0;
1141
1142
uniform float warpy <
1143
	ui_category = "Screen Options";
1144
	ui_type = "drag";
1145
	ui_min = 0.0;
1146
	ui_max = 0.25;
1147
	ui_step = 0.01;
1148
	ui_label = "Curvature Y (Default 0.04)";
1149
> = 0.0;
1150
1151
uniform float c_shape <
1152
	ui_category = "Screen Options";
1153
	ui_type = "drag";
1154
	ui_min = 0.05;
1155
	ui_max = 0.6;
1156
	ui_step = 0.05;
1157
	ui_label = "Curvature Shape";
1158
> = 0.25;
1159
1160
uniform float cbulge <
1161
	ui_category = "Screen Options";
1162
	ui_type = "drag";
1163
	ui_min = 0.0;
1164
	ui_max = 1.0;
1165
	ui_step = 0.05;
1166
	ui_label = "Curvature 3D Effect";
1167
> = 0.25;
1168
1169
uniform float overscanx <
1170
	ui_category = "Screen Options";
1171
	ui_type = "drag";
1172
	ui_min = -200.0;
1173
	ui_max = 200.0;
1174
	ui_step = 1.0;
1175
	ui_label = "Overscan X original Pixels";
1176
> = 0.0;
1177
1178
uniform float overscany <
1179
	ui_category = "Screen Options";
1180
	ui_type = "drag";
1181
	ui_min = -200.0;
1182
	ui_max = 200.0;
1183
	ui_step = 1.0;
1184
	ui_label = "Overscan Y original Pixels";
1185
> = 0.0;
1186
1187
uniform float VShift <
1188
	ui_category = "Screen Options";
1189
	ui_type = "drag";
1190
	ui_min = -200.0;
1191
	ui_max = 200.0;
1192
	ui_step = 1.0;
1193
	ui_label = "Vertical shift Y original pixels";
1194
> = 0.0;
1195
1196
uniform float csize <
1197
	ui_category = "Screen Options";
1198
	ui_type = "drag";
1199
	ui_min = 0.0;
1200
	ui_max = 0.35;
1201
	ui_step = 0.01;
1202
	ui_label = "Corner Size";
1203
> = 0.0;
1204
1205
uniform float bsize <
1206
	ui_category = "Screen Options";
1207
	ui_type = "drag";
1208
	ui_min = 0.0;
1209
	ui_max = 2.0;
1210
	ui_step = 0.01;
1211
	ui_label = "Border Size";
1212
> = 0.0;
1213
1214
uniform float sborder <
1215
	ui_category = "Screen Options";
1216
	ui_type = "drag";
1217
	ui_min = 0.25;
1218
	ui_max = 2.0;
1219
	ui_step = 0.05;
1220
	ui_label = "Border Intensity";
1221
> = 0.75;
1222
1223
uniform float barspeed <
1224
	ui_category = "Screen Options";
1225
	ui_type = "drag";
1226
	ui_min = 5.0;
1227
	ui_max = 200.0;
1228
	ui_step = 1.0;
1229
	ui_label = "Hum Bar Speed";
1230
> = 50.0;
1231
1232
uniform float barintensity <
1233
	ui_category = "Screen Options";
1234
	ui_type = "drag";
1235
	ui_min = -1.0;
1236
	ui_max = 1.0;
1237
	ui_step = 0.01;
1238
	ui_label = "Hum Bar Intensity";
1239
> = 0.0;
1240
1241
uniform float bardir <
1242
	ui_category = "Screen Options";
1243
	ui_type = "drag";
1244
	ui_min = 0.0;
1245
	ui_max = 1.0;
1246
	ui_step = 1.0;
1247
	ui_label = "Hum Bar Direction";
1248
> = 0.0;
1249
1250
uniform float shadow_msk <
1251
	ui_category = "CRT Mask Options";
1252
	ui_type = "drag";
1253
	ui_min = -1.0;
1254
	ui_max = 14.0;
1255
	ui_step = 1.0;
1256
	ui_label = "CRT Mask: 0:CGWG | 1-4:Lottes | 5-14:'Trinitron'";
1257
> = 6.0;
1258
1259
uniform float maskstr <
1260
	ui_category = "CRT Mask Options";
1261
	ui_type = "drag";
1262
	ui_min = -0.5;
1263
	ui_max = 1.0;
1264
	ui_step = 0.025;
1265
	ui_label = "Mask Strength (0, 5-14)";
1266
> = 0.7;
1267
1268
uniform float mcut <
1269
	ui_category = "CRT Mask Options";
1270
	ui_type = "drag";
1271
	ui_min = 0.0;
1272
	ui_max = 2.0;
1273
	ui_step = 0.05;
1274
	ui_label = "Mask 5-14 Low Strength";
1275
> = 1.05;
1276
1277
uniform float maskboost <
1278
	ui_category = "CRT Mask Options";
1279
	ui_type = "drag";
1280
	ui_min = 1.0;
1281
	ui_max = 3.0;
1282
	ui_step = 0.05;
1283
	ui_label = "CRT Mask Boost";
1284
> = 2.0;
1285
1286
uniform float masksize <
1287
	ui_category = "CRT Mask Options";
1288
	ui_type = "drag";
1289
	ui_min = 1.0;
1290
	ui_max = 4.0;
1291
	ui_step = 1.0;
1292
	ui_label = "CRT Mask Size";
1293
> = 1.0;
1294
1295
uniform float mask_zoom <
1296
	ui_category = "CRT Mask Options";
1297
	ui_type = "drag";
1298
	ui_min = -10.0;
1299
	ui_max = 6.0;
1300
	ui_step = 1.0;
1301
	ui_label = "CRT Mask Zoom (+ mask width)";
1302
> = 0.0;
1303
1304
uniform float zoom_mask <
1305
	ui_category = "CRT Mask Options";
1306
	ui_type = "drag";
1307
	ui_min = 0.0;
1308
	ui_max = 1.0;
1309
	ui_step = 0.05;
1310
	ui_label = "CRT Mask Zoom Sharpen (needs Mask Zoom)";
1311
> = 0.0;
1312
1313
uniform float mshift <
1314
	ui_category = "CRT Mask Options";
1315
	ui_type = "drag";
1316
	ui_min = 0.0;
1317
	ui_max = 1.0;
1318
	ui_step = 0.5;
1319
	ui_label = "(Transform to) Shadow Mask";
1320
> = 0.5;
1321
1322
uniform float mask_layout <
1323
	ui_category = "CRT Mask Options";
1324
	ui_type = "drag";
1325
	ui_min = 0.0;
1326
	ui_max = 1.0;
1327
	ui_step = 1.0;
1328
	ui_label = "Mask Layout Sequence: RGB or BGR (check LCD panel)";
1329
> = 0.0;
1330
1331
uniform float laysh <
1332
	ui_category = "CRT Mask Options";
1333
	ui_type = "drag";
1334
	ui_min = -1.0;
1335
	ui_max = 1.0;
1336
	ui_step = 1.0;
1337
	ui_label = "Mask Layout Shift: GBR, RGB, BRG | GRB, RBG, BGR";
1338
> = 0.0;
1339
1340
uniform float mask_drk <
1341
	ui_category = "CRT Mask Options";
1342
	ui_type = "drag";
1343
	ui_min = 0.0;
1344
	ui_max = 2.0;
1345
	ui_step = 0.05;
1346
	ui_label = "Lottes maskDark";
1347
> = 0.5;
1348
1349
uniform float mask_lgt <
1350
	ui_category = "CRT Mask Options";
1351
	ui_type = "drag";
1352
	ui_min = 0.0;
1353
	ui_max = 2.0;
1354
	ui_step = 0.05;
1355
	ui_label = "Lottes maskBright";
1356
> = 1.5;
1357
1358
uniform float mask_gamma <
1359
	ui_category = "CRT Mask Options";
1360
	ui_type = "drag";
1361
	ui_min = 1.0;
1362
	ui_max = 5.0;
1363
	ui_step = 0.05;
1364
	ui_label = "Mask gamma";
1365
> = 2.4;
1366
1367
uniform float slotmask1 <
1368
	ui_category = "CRT Mask Options";
1369
	ui_type = "drag";
1370
	ui_min = 0.0;
1371
	ui_max = 1.0;
1372
	ui_step = 0.05;
1373
	ui_label = "Slot Mask Strength Bright Pixels";
1374
> = 0.1;
1375
1376
uniform float slotmask2 <
1377
	ui_category = "CRT Mask Options";
1378
	ui_type = "drag";
1379
	ui_min = 0.0;
1380
	ui_max = 1.0;
1381
	ui_step = 0.05;
1382
	ui_label = "Slot Mask Strength Dark Pixels";
1383
> = 0.2;
1384
1385
uniform float slotwidth <
1386
	ui_category = "CRT Mask Options";
1387
	ui_type = "drag";
1388
	ui_min = 0.0;
1389
	ui_max = 16.0;
1390
	ui_step = 1.0;
1391
	ui_label = "Slot Mask Width (0:Auto)";
1392
> = 0.0;
1393
1394
uniform float double_slot <
1395
	ui_category = "CRT Mask Options";
1396
	ui_type = "drag";
1397
	ui_min = 1.0;
1398
	ui_max = 4.0;
1399
	ui_step = 1.0;
1400
	ui_label = "Slot Mask Height: 2x1 or 4x1...";
1401
> = 2.0;
1402
1403
uniform float slotms <
1404
	ui_category = "CRT Mask Options";
1405
	ui_type = "drag";
1406
	ui_min = 1.0;
1407
	ui_max = 4.0;
1408
	ui_step = 1.0;
1409
	ui_label = "Slot Mask Thickness";
1410
> = 1.0;
1411
1412
uniform float smoothmask <
1413
	ui_category = "CRT Mask Options";
1414
	ui_type = "drag";
1415
	ui_min = 0.0;
1416
	ui_max = 2.0;
1417
	ui_step = 0.25;
1418
	ui_label = "Smooth Masks in bright scanlines";
1419
> = 0.25;
1420
1421
uniform float smask_mit <
1422
	ui_category = "CRT Mask Options";
1423
	ui_type = "drag";
1424
	ui_min = 0.0;
1425
	ui_max = 1.0;
1426
	ui_step = 0.05;
1427
	ui_label = "Mitigate Slot Mask Interaction";
1428
> = 0.5;
1429
1430
uniform float bmask <
1431
	ui_category = "CRT Mask Options";
1432
	ui_type = "drag";
1433
	ui_min = 0.0;
1434
	ui_max = 0.25;
1435
	ui_step = 0.01;
1436
	ui_label = "Base (black) Mask Strength";
1437
> = 0.001;
1438
1439
uniform float mclip <
1440
	ui_category = "CRT Mask Options";
1441
	ui_type = "drag";
1442
	ui_min = 0.0;
1443
	ui_max = 1.0;
1444
	ui_step = 0.025;
1445
	ui_label = "Preserve Mask Strength";
1446
> = 0.05;
1447
1448
uniform float pr_scan <
1449
	ui_category = "CRT Mask Options";
1450
	ui_type = "drag";
1451
	ui_min = 0.0;
1452
	ui_max = 1.0;
1453
	ui_step = 0.025;
1454
	ui_label = "Preserve Scanline Properties";
1455
> = 0.125;
1456
1457
uniform float edgemask <
1458
	ui_category = "CRT Mask Options";
1459
	ui_type = "drag";
1460
	ui_min = 0.0;
1461
	ui_max = 1.0;
1462
	ui_step = 0.1;
1463
	ui_label = "Mitigate Mask on Edges";
1464
> = 0.5;
1465
1466
uniform float dctypex <
1467
	ui_category = "Deconvergence Options";
1468
	ui_type = "drag";
1469
	ui_min = 0.0;
1470
	ui_max = 0.75;
1471
	ui_step = 0.05;
1472
	ui_label = "Deconvergence Type X: 0:static | Other:dynamic";
1473
> = 0.15;
1474
1475
uniform float dctypey <
1476
	ui_category = "Deconvergence Options";
1477
	ui_type = "drag";
1478
	ui_min = 0.0;
1479
	ui_max = 0.75;
1480
	ui_step = 0.05;
1481
	ui_label = "Deconvergence Type Y: 0:Static | Other:Dynamic";
1482
> = 0.15;
1483
1484
uniform float deconrx <
1485
	ui_category = "Deconvergence Options";
1486
	ui_type = "drag";
1487
	ui_min = -15.0;
1488
	ui_max = 15.0;
1489
	ui_step = 0.25;
1490
	ui_label = "Horizontal Deconvergence Red Range";
1491
> = 1.0;
1492
1493
uniform float decongx <
1494
	ui_category = "Deconvergence Options";
1495
	ui_type = "drag";
1496
	ui_min = -15.0;
1497
	ui_max = 15.0;
1498
	ui_step = 0.25;
1499
	ui_label = "Horizontal Deconvergence Green Range";
1500
> = 0.0;
1501
1502
uniform float deconbx <
1503
	ui_category = "Deconvergence Options";
1504
	ui_type = "drag";
1505
	ui_min = -15.0;
1506
	ui_max = 15.0;
1507
	ui_step = 0.25;
1508
	ui_label = "Horizontal Deconvergence Blue Range";
1509
> = -0.75;
1510
1511
uniform float deconry <
1512
	ui_category = "Deconvergence Options";
1513
	ui_type = "drag";
1514
	ui_min = -15.0;
1515
	ui_max = 15.0;
1516
	ui_step = 0.25;
1517
	ui_label = "Vertical Deconvergence Red Range";
1518
> = 0.5;
1519
1520
uniform float decongy <
1521
	ui_category = "Deconvergence Options";
1522
	ui_type = "drag";
1523
	ui_min = -15.0;
1524
	ui_max = 15.0;
1525
	ui_step = 0.25;
1526
	ui_label = "Vertical Deconvergence Green Range";
1527
> = -0.25;
1528
1529
uniform float deconby <
1530
	ui_category = "Deconvergence Options";
1531
	ui_type = "drag";
1532
	ui_min = -15.0;
1533
	ui_max = 15.0;
1534
	ui_step = 0.25;
1535
	ui_label = "Vertical Deconvergence Blue Range";
1536
> = 0.0;
1537
1538
uniform float decons <
1539
	ui_category = "Deconvergence Options";
1540
	ui_type = "drag";
1541
	ui_min = 0.0;
1542
	ui_max = 3.0;
1543
	ui_step = 0.1;
1544
	ui_label = "Deconvergence Strength";
1545
> = 1.2;
1546
1547
uniform float addnoised <
1548
	ui_category = "Noise Options";
1549
	ui_type = "drag";
1550
	ui_min = -1.0;
1551
	ui_max = 1.0;
1552
	ui_step = 0.02;
1553
	ui_label = "Add Noise";
1554
> = 0.02;
1555
1556
uniform float noiseresd <
1557
	ui_category = "Noise Options";
1558
	ui_type = "drag";
1559
	ui_min = 1.0;
1560
	ui_max = 10.0;
1561
	ui_step = 1.0;
1562
	ui_label = "Noise Resolution";
1563
> = 2.0;
1564
1565
uniform float noisetype <
1566
	ui_category = "Noise Options";
1567
	ui_type = "drag";
1568
	ui_min = 0.0;
1569
	ui_max = 1.0;
1570
	ui_step = 1.0;
1571
	ui_label = "Noise Type: Colored | Luma";
1572
> = 0.0;
1573
1574
uniform float post_br <
1575
	ui_category = "Post Effects";
1576
	ui_type = "drag";
1577
	ui_min = 0.25;
1578
	ui_max = 5.0;
1579
	ui_step = 0.01;
1580
	ui_label = "Post Brightness";
1581
> = 1.03;
1582
1583
uniform float oimage <
1584
	ui_category = "Post Effects";
1585
	ui_type = "drag";
1586
	ui_min = 0.0;
1587
	ui_max = 1.0;
1588
	ui_step = 0.25;
1589
	ui_label = "Show Original Image";
1590
> = 0.0;
1591
1592
#include "ReShade.fxh"
1593
1594
#define TexSize float2(Resolution_X,Resolution_Y)
1595
#define IptSize float2(800.00000000,600.00000000)
1596
#define BoxSize float2(AspectSize_X,AspectSize_Y)
1597
#define OptSize float4(BUFFER_SCREEN_SIZE,1.0/BUFFER_SCREEN_SIZE)
1598
#define OrgSize float4(TexSize,1.0/TexSize)
1599
#define SrcSize float4(IptSize,1.0/IptSize)
1600
#define NewSize float4(BoxSize,1.0/BoxSize)
1601
#define fuxcoord (texcoord*1.00001)
1602
#define scans 1.5*scans
1603
#define eps 1e-8
1604
#define wts float((bloomsamp < 0.5) ? -10.0 : -12.5)
1605
#define pii 3.14159265
1606
#define fracoord (fuxcoord*NewSize.xy)
1607
#define texCD(c,d) tex2Dlod(c,float4(d,0,0))
1608
#define LumSize float4(2.0*TexSize.x,1.0*TexSize.y,1.0/(2.0*TexSize.x),1.0/(1.0*TexSize.y))
1609
#define rgb_m float3x3(0.2989,0.5870,0.1140,0.5959,-0.2744,-0.3216,0.2115,-0.5229,0.3114)
1610
#define yiq_m float3x3(1.0000,0.9560,0.6210,1.0000,-0.2720,-0.6474,1.0000,-1.1060,1.7046)
1611
#define fetch_offset(dx) float3(texCD(JoNTSC_S03,tex_c+dx.xz).x+texCD(JoNTSC_S03,tex_c-dx.xz).x,texCD(JoNTSC_S03,tex_c+dx.yz).yz+texCD(JoNTSC_S03,tex_c-dx.yz).yz)
1612
1613
#ifndef Resolution_X
1614
#define Resolution_X 640
1615
#endif
1616
1617
#ifndef Resolution_Y
1618
#define Resolution_Y 480
1619
#endif
1620
1621
#ifndef AspectSize_X
1622
#define AspectSize_X 1440
1623
#endif
1624
1625
#ifndef AspectSize_Y
1626
#define AspectSize_Y 1080
1627
#endif
1628
1629
#ifndef OriginalFPS
1630
#define OriginalFPS 60
1631
#endif
1632
1633
#define JoNTSC_S00 ReShade::BackBuffer
1634
1635
texture JoNTSC_T0S{Width=1.0*Resolution_X;Height=Resolution_Y;Format=RGBA16F;};
1636
sampler JoNTSC_S0S{Texture=JoNTSC_T0S;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=POINT ;MinFilter=POINT ;MipFilter=POINT ;};
1637
1638
texture JoNTSC_T01{Width=1.0*Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
1639
sampler JoNTSC_S01{Texture=JoNTSC_T01;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1640
1641
texture JoNTSC_T02{Width=1.0*Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
1642
sampler JoNTSC_S02{Texture=JoNTSC_T02;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1643
1644
texture JoNTSC_T0I{Width=1.0*Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
1645
sampler JoNTSC_S0I{Texture=JoNTSC_T0I;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1646
1647
texture JoNTSC_T03{Width=4.0*Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
1648
sampler JoNTSC_S03{Texture=JoNTSC_T03;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=POINT ;MinFilter=POINT ;MipFilter=POINT ;};
1649
1650
texture JoNTSC_T04{Width=2.0*Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
1651
sampler JoNTSC_S04{Texture=JoNTSC_T04;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1652
1653
texture JoNTSC_T05{Width=2.0*Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
1654
sampler JoNTSC_S05{Texture=JoNTSC_T05;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1655
1656
texture JoNTSC_T06{Width=2.0*Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
1657
sampler JoNTSC_S06{Texture=JoNTSC_T06;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1658
1659
texture JBCrsh_T01{Width=2.0*Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
1660
sampler JBCrsh_S01{Texture=JBCrsh_T01;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=POINT ;MinFilter=POINT ;MipFilter=POINT ;};
1661
1662
texture JBCrsh_T02{Width=2.0*Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
1663
sampler JBCrsh_S02{Texture=JBCrsh_T02;AddressU=REPEAT;AddressV=REPEAT;AddressW=REPEAT;MagFilter=POINT ;MinFilter=POINT ;MipFilter=POINT ;};
1664
1665
texture JoNTSC_T07{Width=2.0*Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
1666
sampler JoNTSC_S07{Texture=JoNTSC_T07;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1667
1668
texture JoNTSC_T08{Width=2.0*Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
1669
sampler JoNTSC_S08{Texture=JoNTSC_T08;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1670
1671
texture JoNTSC_T09{Width=1.0*AspectSize_X;Height=Resolution_Y ;Format=RGBA16F;};
1672
sampler JoNTSC_S09{Texture=JoNTSC_T09;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1673
1674
texture JoNTSC_T10{Width=1.0*800.00000000;Height=Resolution_Y ;Format=RGBA16F;};
1675
sampler JoNTSC_S10{Texture=JoNTSC_T10;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1676
1677
texture JoNTSC_T11{Width=1.0*800.00000000;Height=600.00000000 ;Format=RGBA16F;};
1678
sampler JoNTSC_S11{Texture=JoNTSC_T11;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1679
1680
texture JoNTSC_T12{Width=1.0*800.00000000;Height=600.00000000 ;Format=RGBA16F;};
1681
sampler JoNTSC_S12{Texture=JoNTSC_T12;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1682
1683
texture JoNTSC_T13{Width=1.0*800.00000000;Height=600.00000000 ;Format=RGBA16F;};
1684
sampler JoNTSC_S13{Texture=JoNTSC_T13;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1685
1686
texture JoNTSC_T14{Width=1.0*AspectSize_X;Height=AspectSize_Y ;Format=RGBA16F;};
1687
sampler JoNTSC_S14{Texture=JoNTSC_T14;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1688
1689
texture JoNTSC_T15{Width=1.0*AspectSize_X;Height=AspectSize_Y ;Format=RGBA16F;};
1690
sampler JoNTSC_S15{Texture=JoNTSC_T15;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1691
1692
texture JoNTSC_001<source="CRT-LUT-1.png";>{Width=1024;Height=32;};
1693
sampler JoNTSC_L01{Texture=JoNTSC_001;};
1694
1695
texture JoNTSC_002<source="CRT-LUT-2.png";>{Width=1024;Height=32;};
1696
sampler JoNTSC_L02{Texture=JoNTSC_002;};
1697
1698
texture JoNTSC_003<source="CRT-LUT-3.png";>{Width=1024;Height=32;};
1699
sampler JoNTSC_L03{Texture=JoNTSC_003;};
1700
1701
texture JoNTSC_004<source="CRT-LUT-4.png";>{Width=1024;Height=32;};
1702
sampler JoNTSC_L04{Texture=JoNTSC_004;};
1703
1704
uniform int framecount<source="framecount";>;
1705
1706
float3 fix_lut(float3 lut,float3 ref)
1707
{
1708
	float r=length(ref);
1709
	float l=length(lut);
1710
	float m=max(max(ref.r,ref.g),ref.b);
1711
	ref=normalize(lut+0.0000001)*lerp(r,l,pow(m,1.25));
1712
	return lerp(lut,ref,LUTBR);
1713
}
1714
1715
float vignette(float2 pos)
1716
{
1717
	float b = vigdef * 0.125;
1718
	pos = abs(2.0*(pos - 0.5)); pos*=pos*pos;
1719
	float dist = pow(dot(pos,pos),0.05);
1720
	float res = lerp(0.0, 1.0, smoothstep(1.0, 1.0-b, dist));
1721
	return max(lerp(1.0, res, vigstr), 0.0);
1722
}
1723
1724
float contrast(float x)
1725
{
1726
	return max(lerp(x,smoothstep(0,1.0,x),contra),0.0);
1727
}
1728
1729
float3 pgc(float3 c)
1730
{
1731
	float mc = max(max(c.r,c.g),c.b);
1732
	float mg = pow(mc, 1.0/pre_gc);
1733
	return c * mg/(mc + 1e-8);  
1734
}
1735
1736
float contrast_sigmoid_inv(float imgColor, float cont, float pivot)
1737
{
1738
	cont = cont - 1.0; cont = cont*cont*cont;
1739
	float knee  = 1.0 / (1.0 + exp (cont *  pivot));
1740
	float shldr = 1.0 / (1.0 + exp (cont * (pivot - 1.0)));
1741
	imgColor = pivot - log(1.0 / (imgColor * (shldr - knee) + knee) - 1.0) / cont;
1742
	return imgColor;
1743
}
1744
1745
float dist(float3 A,float3 B)
1746
{
1747
	float r=0.5*(A.r+B.r);
1748
	float3 d=A-B;
1749
	float3 c=float3(2.+r,4.,3.-r);
1750
	return sqrt(dot(c*d,d))/3.;
1751
}
1752
1753
float3 plant(float3 tar,float r)
1754
{
1755
	float t=max(max(tar.r,tar.g),tar.b)+0.00001;
1756
	return tar*r/t;
1757
}
1758
1759
float3 fetch_pixel(float2 coord)
1760
{
1761
	float2 dx=float2(LumSize.z,0.0)*downsample_levelx;
1762
	float2 dy=float2(0.0,LumSize.w)*downsample_levely;
1763
	float2 d1=dx+dy;
1764
	float2 d2=dx-dy;
1765
	float sum=15.0;
1766
	float3 result=
1767
	3.0*texCD(JBCrsh_S02,coord   ).rgb+2.0*texCD(JBCrsh_S02,coord+dx).rgb+2.0*texCD(JBCrsh_S02,coord-dx).rgb+
1768
	2.0*texCD(JBCrsh_S02,coord+dy).rgb+2.0*texCD(JBCrsh_S02,coord-dy).rgb+    texCD(JBCrsh_S02,coord+d1).rgb+
1769
		texCD(JBCrsh_S02,coord-d1).rgb+    texCD(JBCrsh_S02,coord+d2).rgb+    texCD(JBCrsh_S02,coord-d2).rgb;
1770
	return result/sum;
1771
}
1772
1773
float gauss_h(float x)
1774
{
1775
	float sigma=1.0/(2.0*SIGMA_H*SIGMA_H);
1776
	return exp(-x*x*sigma);
1777
}
1778
1779
float gauss_v(float x)
1780
{
1781
	float sigma=1.0/(2.0*SIGMA_V*SIGMA_V);
1782
	return exp(-x*x*sigma);
1783
}
1784
1785
float bloom_h(float x)
1786
{
1787
	float SIGMA_X2 = SIGMA_X * SIZEX / 3.0;
1788
	float sigma=1.0/(2.0*SIGMA_X2*SIGMA_X2);
1789
	return exp(-x*x*sigma);
1790
}
1791
1792
float bloom_v(float x)
1793
{
1794
	float SIGMA_Y2 = SIGMA_Y * SIZEY / 3.0;
1795
	float sigma=1.0/(2.0*SIGMA_Y2*SIGMA_Y2);
1796
	return exp(-x*x*sigma);
1797
}
1798
1799
float crthd_h(float x,float y)
1800
{
1801
	return exp(-x*x*y);
1802
}
1803
1804
float mod(float x,float y)
1805
{
1806
	return x-y* floor(x/y);
1807
}
1808
1809
float st0(float x)
1810
{
1811
	return exp2(wts*x*x);
1812
}
1813
1814
float3 sw0(float x,float color,float scanline,float3 c)
1815
{
1816
	float3 xe=lerp(1.0.xxx+scans,1.0.xxx,c);
1817
	float tmp=lerp(beam_min,beam_max,color);
1818
	float ex=x*tmp;
1819
	ex=(gsl>-0.5)?ex*ex:lerp(ex*ex,ex*ex*ex,0.4);
1820
	return exp2(-scanline*ex*xe);
1821
}
1822
1823
float3 sw1(float x,float color,float scanline,float3 c)
1824
{
1825
	float3 xe=lerp(1.0.xxx+scans,1.0.xxx,c);
1826
	x=lerp(x,beam_min*x,max(x-0.4*color,0.0));
1827
	float tmp=lerp(1.2*beam_min,beam_max,color);
1828
	float ex=x*tmp;
1829
	return exp2(-scanline*ex*ex*xe);
1830
}
1831
1832
float3 sw2(float x,float color,float scanline,float3 c)
1833
{
1834
	float3 xe=lerp(1.0.xxx+scans,1.0.xxx,c);
1835
	float tmp=lerp((2.5-0.5*color)*beam_min,beam_max,color);
1836
	tmp=lerp(beam_max,tmp,pow(x,color+0.3));
1837
	float ex=x*tmp;
1838
	return exp2(-scanline*ex*ex*xe);
1839
}
1840
1841
float2 overscan(float2 pos,float dx,float dy)
1842
{
1843
	pos=pos*2.0-1.0;
1844
	pos*=float2(dx,dy);
1845
	return pos*0.5+0.5;
1846
}
1847
1848
float2 warp(float2 pos)
1849
{
1850
	pos=pos*2.0-1.0;
1851
	pos=lerp(pos,sign(pos)*pow(abs(pos),1.0+min(15.0*float2(warpy,warpx)*cbulge.xx,cbulge.xx)),0.075+0.125*(abs(pos)+pos*pos));
1852
	pos=lerp(pos,float2(pos.x*rsqrt(1.0-c_shape*pos.y*pos.y),pos.y*rsqrt(1.0-c_shape*pos.x*pos.x)),float2(warpx,warpy)/c_shape);
1853
	return pos*0.5+0.5;
1854
}
1855
1856
float3 gc1(float3 c)
1857
{
1858
	float mc=max(max(c.r,c.g),c.b);
1859
	float mg=pow(mc,1.0/gamma_c);
1860
	return c*mg/(mc+eps);
1861
}
1862
1863
float3 rgb2yiq(float3 r)
1864
{
1865
	return mul(rgb_m, r);
1866
}
1867
1868
float3 yiq2rgb(float3 y)
1869
{
1870
	return mul(yiq_m, y);
1871
}
1872
1873
float get_luma(float3 c)
1874
{
1875
	return dot(c,float3(0.2989, 0.5870, 0.1140));
1876
}
1877
1878
float swoothstep(float e0,float e1,float x)
1879
{
1880
	return clamp((x-e0)/(e1-e0),0.0,1.0);
1881
}
1882
1883
float3 crt_mask(float2 pos,float mx,float mb)
1884
{
1885
	float3 mask=mask_drk;
1886
	float3 one=1.0;
1887
	if(shadow_msk== 0.0)
1888
	{
1889
	float mc=1.0-max(maskstr,0.0);
1890
	pos.x=frac(pos.x*0.5);
1891
	if(pos.x<0.49)
1892
	{
1893
	mask.r=1.0;mask.g= mc;mask.b=1.0;
1894
	}else
1895
	{
1896
	mask.r= mc;mask.g=1.0;mask.b= mc;
1897
	}
1898
	}else
1899
	if(shadow_msk== 1.0)
1900
	{
1901
	float lane=mask_lgt;
1902
	float odd=0.0;
1903
	if(frac(pos.x/6.0)<0.49)odd=1.0;
1904
	if(frac((pos.y+odd)/2.0)<0.49)lane=mask_drk;
1905
	pos.x=floor(mod(pos.x,3.0));
1906
	if(pos.x<0.5)mask.r=mask_lgt;else
1907
	if(pos.x<1.5)mask.g=mask_lgt;else
1908
	mask.b= mask_lgt;
1909
	mask*=lane;
1910
	}else
1911
	if(shadow_msk== 2.0)
1912
	{
1913
	pos.x=floor(mod(pos.x,3.0));
1914
	if(pos.x<0.5)mask.r=mask_lgt;else
1915
	if(pos.x<1.5)mask.g=mask_lgt;else
1916
	mask.b= mask_lgt;
1917
	}else
1918
	if(shadow_msk== 3.0)
1919
	{
1920
	pos.x+=pos.y*3.0;
1921
	pos.x=frac(pos.x/6.0);
1922
	if(pos.x<0.3)mask.r=mask_lgt;else
1923
	if(pos.x<0.6)mask.g=mask_lgt;else
1924
	mask.b= mask_lgt;
1925
	}else
1926
	if(shadow_msk== 4.0)
1927
	{
1928
	pos.xy=floor(pos.xy*float2(1.0,0.5));
1929
	pos.x+=pos.y*3.0;
1930
	pos.x=frac(pos.x/6.0);
1931
	if(pos.x<0.3)mask.r=mask_lgt;else
1932
	if(pos.x<0.6)mask.g=mask_lgt;else
1933
	mask.b= mask_lgt;
1934
	}else
1935
	if(shadow_msk== 5.0)
1936
	{
1937
	mask=0.0;
1938
	pos.x=frac(pos.x/2.0);
1939
	if(pos.x<0.49)
1940
	{
1941
	mask.r=1.0;
1942
	mask.b=1.0;
1943
	}else
1944
	mask.g=1.0;
1945
	mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
1946
	}else
1947
	if(shadow_msk== 6.0)
1948
	{
1949
	mask=0.0;
1950
	pos.x=floor(mod(pos.x,3.0));
1951
	if(pos.x<0.5)mask.r=1.0;else
1952
	if(pos.x<1.5)mask.g=1.0;else
1953
	mask.b=1.0;
1954
	mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
1955
	}else
1956
	if(shadow_msk== 7.0)
1957
	{
1958
	mask=0.0;
1959
	pos.x=frac(pos.x/2.0);
1960
	if(pos.x<0.49)
1961
	{
1962
	mask=0.0.xxx;
1963
	}else
1964
	mask=1.0.xxx;
1965
	mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
1966
	}else
1967
	if(shadow_msk== 8.0)
1968
	{
1969
	mask=0.0;
1970
	pos.x=frac(pos.x/3.0);
1971
	if(pos.x<0.3)mask=0.0.xxx;else
1972
	if(pos.x<0.6)mask=1.0.xxx;else
1973
	mask=1.0.xxx;
1974
	mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
1975
	}else
1976
	if(shadow_msk== 9.0)
1977
	{
1978
	mask=0.0;
1979
	pos.x=frac(pos.x/3.0);
1980
	if(pos.x<0.3)mask   =0.0.xxx;else
1981
	if(pos.x<0.6)mask.rb=1.0.xx ;else
1982
	mask.g=1.0;
1983
	mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
1984
	}else
1985
	if(shadow_msk==10.0)
1986
	{
1987
	mask=0.0;
1988
	pos.x=frac(pos.x*0.25);
1989
	if(pos.x<0.2)mask  =0.0.xxx;else
1990
	if(pos.x<0.4)mask.r=1.0    ;else
1991
	if(pos.x<0.7)mask.g=1.0    ;else
1992
	mask.b=1.0;
1993
	mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
1994
	}else
1995
	if(shadow_msk==11.0)
1996
	{
1997
	mask=0.0;
1998
	pos.x=frac(pos.x*0.25);
1999
	if(pos.x<0.2)mask.r =1.0   ;else
2000
	if(pos.x<0.4)mask.rg=1.0.xx;else
2001
	if(pos.x<0.7)mask.gb=1.0.xx;else
2002
	mask.b=1.0;mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
2003
	}else
2004
	if(shadow_msk==12.0)
2005
	{
2006
	mask=0.0;
2007
	pos.x=floor(mod(pos.x,7.0));
2008
	if(pos.x<0.5)mask  =0.0.xxx;else
2009
	if(pos.x<2.5)mask.r=1.0    ;else
2010
	if(pos.x<4.5)mask.g=1.0    ;else
2011
	mask.b=1.0;
2012
	mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
2013
	}else
2014
	if(shadow_msk==13.0)
2015
	{
2016
	mask=0.0;
2017
	pos.x=floor(mod(pos.x,6.0));
2018
	if(pos.x<0.5)mask    =0.0.xxx;else
2019
	if(pos.x<1.5)mask.r  =1.0    ;else
2020
	if(pos.x<2.5)mask.rg =1.0.xx ;else
2021
	if(pos.x<3.5)mask.rgb=1.0.xxx;else
2022
	if(pos.x<4.5)mask.gb =1.0.xx ;else
2023
	mask.b=1.0;
2024
	mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
2025
	}else
2026
	{
2027
	mask=0.0;
2028
	pos.x=floor(mod(pos.x,5.0));
2029
	if(pos.x<0.5)mask    =0.0.xxx;else
2030
	if(pos.x<1.5)mask.r  =1.0    ;else
2031
	if(pos.x<2.5)mask.rg =1.0.xx ;else
2032
	if(pos.x<3.5)mask.gb =1.0.xx ;else
2033
	mask.b=1.0;
2034
	mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
2035
	}
2036
	if(mask_layout>0.5)mask=mask.rbg;
2037
	float maskmin=min(min(mask.r,mask.g),mask.b);
2038
	return (mask-maskmin)*(1.0+(maskboost-1.0)*mb)+maskmin;
2039
}
2040
2041
float slt_mask(float2 pos,float m,float swidth)
2042
{
2043
	if  ((slotmask1+slotmask2)==0.0)return 1.0;else
2044
	{
2045
	pos.y=floor(pos.y/slotms);
2046
	float mlen=swidth*2.0;
2047
	float px=floor( mod(pos.x, 0.99999*mlen));
2048
	float py=floor(frac(pos.y/(2.0*double_slot))*2.0*double_slot);
2049
	float slot_dark=lerp(1.0-slotmask2,1.0-slotmask1,m);
2050
	float slot=1.0;
2051
	if(py==0.0&&px<swidth) slot=slot_dark;else
2052
	if(py==double_slot&&px>=swidth) slot=slot_dark;
2053
	return slot;
2054
	}
2055
}
2056
2057
float humbars(float pos)
2058
{
2059
	if  (barintensity==0.0)return 1.0;else
2060
	{
2061
	pos=(barintensity>=0.0)?pos:(1.0-pos);
2062
	pos=frac(pos+ mod(float(framecount),barspeed)/(barspeed-1.0));
2063
	pos=(barintensity< 0.0)?pos:(1.0-pos);
2064
	return (1.0-barintensity)+barintensity*pos;
2065
	}
2066
}
2067
2068
float corner(float2 pos)
2069
{
2070
	pos=abs(2.0*(pos-0.50));
2071
	float2 aspect=float2(1.0,NewSize.x/NewSize.y);
2072
	float b=bsize*0.05+0.0005;pos.y=pos.y+b*(aspect.y-1.0);
2073
	float2 crn=max(csize.xx,2.0*b+0.0015);
2074
	float2 crp=max(pos-(1.0-crn*aspect),0.0)/aspect;float cd=sqrt(dot(crp,crp));
2075
	pos=max(pos,1.0-crn+cd);
2076
	float res=lerp(1.0,0.0,smoothstep(1.0-b,1.0,sqrt(max(pos.x,pos.y))));
2077
	return pow(res,sborder);
2078
}
2079
2080
float3 declip(float3 c,float b)
2081
{
2082
	float m=max(max(c.r,c.g),c.b);
2083
	if(m>b)c=c*b/m;
2084
	return c;
2085
}
2086
2087
float igc(float mc)
2088
{
2089
	return pow(mc,gamma_c);
2090
}
2091
2092
float3 gc2(float3 c,float w3)
2093
{
2094
	float mc=max(max(c.r,c.g),c.b);
2095
	float p=1.0/(1.0+(gamma_d-1.0)* lerp(0.375,1.0,w3));
2096
	float mg=pow(mc, p );
2097
	return c*mg/(mc+eps);
2098
}
2099
2100
float3 noise(float3 v)
2101
{
2102
	if(addnoised<0.0)v.z=-addnoised;else v.z= mod(v.z,6001.0)/1753.0;
2103
	v =frac(v)+frac(v*1e4)+frac(v*1e-4);
2104
	v+=float3(0.12345,0.6789,0.314159);
2105
	v =frac(v*dot(v,v)*123.456);
2106
	v =frac(v*dot(v,v)*123.456);
2107
	v =frac(v*dot(v,v)*123.456);
2108
	v =frac(v*dot(v,v)*123.456);
2109
	return v;
2110
}
2111
2112
float smothstep (float e0, float e1, float x)
2113
{
2114
   return clamp((x - e0) / (e1 - e0), 0.0, 1.0);
2115
}
2116
2117
float2 psrnd(float2 TexCoord, float FrameCount) {
2118
    float3 p = float3(TexCoord * 16758.5453, FrameCount);
2119
    float x = frac(sin(dot(p, float3(12.9898, 78.233, 3.183))) * 43758.5453);
2120
    float y = frac(sin(dot(p, float3(25.9796, 14.113, 11.271))) * 96321.9124);
2121
    return float2(x, y);
2122
}
2123
2124
float3 NoiseNP3(float2 TexCoord, float FrameCount) {
2125
float RFNOISE0 = RFNOISE*RFNOISE + 0.00001;
2126
    TexCoord = psrnd(TexCoord, FrameCount);
2127
    float3 p = float3(TexCoord * 758.5453, FrameCount);
2128
    float res1 = frac(sin(dot(p, float3(12.989835, 78.23341, 0.16453))) * 43758.54531);
2129
    float res2 = frac(sin(dot(p, float3(39.34679, 11.13523, 83.15573))) * 39459.32423);
2130
    float res3 = frac(sin(dot(p, float3(73.15691, 52.23504, 9.15197))) * 60493.84731);
2131
    float lns = float(abs(res1-0.5) < 0.2*RFNOISE0);
2132
    float cny = float(abs(res2-0.5) < 0.5*RFNOISE0);
2133
    float cnz = float(abs(res3-0.5) < 0.5*RFNOISE0);
2134
    lns = lns*smothstep(0.5-0.2*RFNOISE0, 0.5+0.2*RFNOISE0, res1) * 0.66 - 0.33*lns;
2135
    cny = cny*smothstep(0.5-0.5*RFNOISE0, 0.5+0.5*RFNOISE0, res2)  - 0.5*cny;
2136
    cnz = cnz*smothstep(0.5-0.5*RFNOISE0, 0.5+0.5*RFNOISE0, res3)  - 0.5*cnz;	
2137
    return float3(lns, cny, cnz);
2138
}
2139
2140
void bring_pixel(inout float3 c,inout float3 b,inout float3 g,float2 coord,float2 boord)
2141
{
2142
	float stepx=NewSize.z;
2143
	float stepy=NewSize.w;
2144
	float2 dx=float2(stepx,0.0);
2145
	float2 dy=float2(0.0,stepy);
2146
	float posx= 2.0*coord.x-1.0;
2147
	float posy= 2.0*coord.y-1.0;
2148
	if(dctypex>0.025)
2149
	{
2150
	posx= sign(posx)*pow(abs(posx),1.05-dctypex);
2151
	dx=posx*dx;
2152
	}
2153
	if(dctypey>0.025)
2154
	{
2155
	posy= sign(posy)*pow(abs(posy),1.05-dctypey);
2156
	dy=posy*dy;
2157
	}
2158
	float2 rc=deconrx*dx+deconry*dy;
2159
	float2 gc=decongx*dx+decongy*dy;
2160
	float2 bc=deconbx*dx+deconby*dy;
2161
	float r1=texCD(JoNTSC_S14,coord+rc).r;
2162
	float g1=texCD(JoNTSC_S14,coord+gc).g;
2163
	float b1=texCD(JoNTSC_S14,coord+bc).b;
2164
	float ds=decons;
2165
	float3 d=float3(r1,g1,b1);
2166
	c=clamp(lerp(c,d,ds),0.0,1.0);
2167
	r1=texCD(JoNTSC_S13,boord+rc).r;
2168
	g1=texCD(JoNTSC_S13,boord+gc).g;
2169
	b1=texCD(JoNTSC_S13,boord+bc).b;
2170
	d=float3(r1,g1,b1);
2171
	b=g=lerp(b,d,min(ds,1.0));
2172
	r1=texCD(JoNTSC_S11,boord+rc).r;
2173
	g1=texCD(JoNTSC_S11,boord+gc).g;
2174
	b1=texCD(JoNTSC_S11,boord+bc).b;
2175
	d=float3(r1,g1,b1);
2176
	g=lerp(g,d,min(ds,1.0));
2177
}
2178
2179
float3 scale_to_range(float3 x, float dmin, float dmax)
2180
{
2181
    return ( (dmax - dmin) * x ) + dmin; //Scales 0..1 range to a..b range
2182
}
2183
2184
2185
float3 adaptive_black(float3 c, float lum_in, float range, bool dark_crush)
2186
{
2187
    if (dark_crush)
2188
    {
2189
        // Black crush
2190
        return clamp(scale_to_range(c, -lum_in * range,1.0), 0.0,1.0);
2191
    }
2192
    else
2193
    {
2194
        // Increase gamma
2195
        float ga = 1.0 + lum_in * 2.0 * range;
2196
        return pow(c, float3(ga,ga,ga));
2197
    }
2198
}
2199
2200
float get_fps()
2201
{
2202
    // Direct port (frametime uniforms not available)
2203
    return OriginalFPS;
2204
}
2205
2206
static const float2 expanse=BoxSize/ (2*OptSize.xy);
2207
static const float2 capital=0.0/OptSize.xy+0.5;
2208
static const float coord_w=capital.x-expanse.x;
2209
static const float coord_e=capital.x+expanse.x;
2210
static const float coord_n=capital.y-expanse.y;
2211
static const float coord_s=capital.y+expanse.y;
2212
static const float2 correct=float2(coord_w,coord_n);
2213
2214
void CropProcessVS(in uint id:SV_VertexID,out float4 position:SV_Position,out float2 texcoord:TEXCOORD)
2215
{
2216
	#if __RENDERER__ <= 0x09300
2217
	texcoord.x=(id==1||id==3)?coord_e:coord_w;
2218
	texcoord.y=(id>1)?coord_s:coord_n;
2219
	position.x=(id==1||id==3)? 1:-1;
2220
	position.y=(id>1)?-1: 1;
2221
	position.zw=1;
2222
	#else
2223
	texcoord.x=(id&1)?coord_e:coord_w;
2224
	texcoord.y=(id&2)?coord_s:coord_n;
2225
	position.x=(id&1)? 1:-1;
2226
	position.y=(id&2)?-1: 1;
2227
	position.zw=1;
2228
	#endif
2229
}
2230
2231
float4 StockPassPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2232
{
2233
	return texCD(JoNTSC_S00,texcoord);
2234
}
2235
2236
float4 AfterglowPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2237
{
2238
	float2 dx=float2(OrgSize.z,0.0);
2239
	float2 dy=float2(0.0,OrgSize.w);
2240
	float w=1.0;
2241
	float3 color0=texCD(JoNTSC_S0S,texcoord   ).rgb;
2242
	float3 color1=texCD(JoNTSC_S0S,texcoord-dx).rgb;
2243
	float3 color2=texCD(JoNTSC_S0S,texcoord+dx).rgb;
2244
	float3 color3=texCD(JoNTSC_S0S,texcoord-dy).rgb;
2245
	float3 color4=texCD(JoNTSC_S0S,texcoord+dy).rgb;
2246
	float3 cr=(2.5*color0+color1+color2+color3+color4)/6.5;
2247
	float3 a=texCD(JoNTSC_S01,texcoord).rgb;
2248
	float b = bth/255.0;
2249
	float c = max(max(color0.r,color0.g),color0.b);
2250
	w = smoothstep(b, 2.0*b, c);
2251
	float3 result=lerp(max(lerp(cr,a,0.49+float3(PR,PG,PB))-0.5/255.0,0.0),cr,w);
2252
	return float4(result,w);
2253
}
2254
2255
float4 PreShaderPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2256
{
2257
	const float3x3 File0=float3x3(0.412391, 0.212639,0.019331, 0.357584,0.715169, 0.119195, 0.180481,0.072192,0.950532);
2258
	const float3x3 File1=float3x3(0.430554, 0.222004,0.020182, 0.341550,0.706655, 0.129553, 0.178352,0.071341,0.939322);
2259
	const float3x3 File2=float3x3(0.396686, 0.210299,0.006131, 0.372504,0.713766, 0.115356, 0.181266,0.075936,0.967571);
2260
	const float3x3 File3=float3x3(0.393521, 0.212376,0.018739, 0.365258,0.701060, 0.111934, 0.191677,0.086564,0.958385);
2261
	const float3x3 File4=float3x3(0.392258, 0.209410,0.016061, 0.351135,0.725680, 0.093636, 0.166603,0.064910,0.850324);
2262
	const float3x3 File5=float3x3(0.377923, 0.195679,0.010514, 0.317366,0.722319, 0.097826, 0.207738,0.082002,1.076960);
2263
	const float3x3 ToRGB=float3x3(3.240970,-0.969244,0.055630,-1.537383,1.875968,-0.203977,-0.498611,0.041555,1.056972);
2264
	const float3x3 ToMDN=float3x3(2.791723,-0.894766,0.041678,-1.173165,1.815586,-0.130886,-0.440973,0.032000,1.002034);
2265
	const float3x3 ToDCI=float3x3(2.973422,-0.867605,0.045031,-1.110433,1.843757,-0.095697,-0.480247,0.024743,1.201215);
2266
	const float3x3 ToADB=float3x3(2.041588,-0.969244,0.013444,-0.565007,1.875968,-0.118360,-0.344731,0.041555,1.015175);
2267
	const float3x3 ToREC=float3x3(1.716651,-0.666684,0.017640,-0.355671,1.616481,-0.042771,-0.253366,0.015769,0.942103);
2268
	const float3x3 ToP3=float3x3(2.493509,-0.829473,0.0358512,-0.931388,1.762630,-0.0761839,-0.402712,0.023624,0.9570296);
2269
	const float3x3 D65_to_D55=float3x3(0.4850339153,0.2500956126,0.0227359648,0.3488957224,0.6977914447,0.1162985741,0.1302823568,0.0521129427,0.6861537456);
2270
	const float3x3 D65_to_D93=float3x3(0.3412754080,0.1759701322,0.0159972847,0.3646170520,0.7292341040,0.1215390173,0.2369894093,0.0947957637,1.2481442225);
2271
	float4 imgColor=texCD(JoNTSC_S0S,texcoord);
2272
	float4 aftrglow=texCD(JoNTSC_S01,texcoord);
2273
	float w=1.0-aftrglow.w;
2274
	float l=length(aftrglow.rgb);
2275
	aftrglow.rgb=AS*w*normalize(pow(aftrglow.rgb+0.01,ST))*l;
2276
	float bp=w*BP1/255.0;
2277
	if(sega_fix>0.5) imgColor.rgb=imgColor.rgb*(255.0/239.0);
2278
	if(segams>0.5) { imgColor.b=(abs(imgColor.b - 0.375) < 0.125) ? 0.4078431372549019607843137254902 : imgColor.b; }
2279
	imgColor.rgb=min(imgColor.rgb,1.0);
2280
	if (segapal > 0.5) {
2281
	imgColor.r = contrast_sigmoid_inv(imgColor.r,2.578419881,0.520674); 
2282
	imgColor.g = contrast_sigmoid_inv(imgColor.g,2.578419881,0.520674); 
2283
	imgColor.b = contrast_sigmoid_inv(imgColor.b,2.578419881,0.520674); }
2284
   
2285
	imgColor.rgb = min(imgColor.rgb, 1.0);
2286
	float3 color=imgColor.rgb;
2287
	if(int(TNTC)==0) {color.rgb=imgColor.rgb;}else
2288
	{
2289
	float lutlow=LUTLOW/255.0;float invs=1.0/LS;
2290
	float3 lut_ref=imgColor.rgb+lutlow*(1.0-pow(imgColor.rgb,0.333.xxx));
2291
	float lutb=lut_ref.b*(1.0-0.5*invs);
2292
	lut_ref.rg=lut_ref.rg*(1.0-invs)+0.5*invs;
2293
	float tile1=ceil(lutb*(LS-1.0));
2294
	float tile0=max(tile1-1.0,0.0);
2295
	float f=frac(lutb*(LS-1.0));if(f==0.0)f=1.0;
2296
	float2 coord1=float2(tile0+lut_ref.r,lut_ref.g)*float2(invs,1.0);
2297
	float2 coord2=float2(tile1+lut_ref.r,lut_ref.g)*float2(invs,1.0);
2298
	float4 color1,color2,res;
2299
	if(int(TNTC)==1)
2300
	{
2301
	color1=texCD(JoNTSC_L01,coord1);
2302
	color2=texCD(JoNTSC_L01,coord2);
2303
	res=lerp(color1,color2,f);
2304
	}else
2305
	if(int(TNTC)==2)
2306
	{
2307
	color1=texCD(JoNTSC_L02,coord1);
2308
	color2=texCD(JoNTSC_L02,coord2);
2309
	res=lerp(color1,color2,f);
2310
	}else
2311
	if(int(TNTC)==3)
2312
	{
2313
	color1=texCD(JoNTSC_L03,coord1);
2314
	color2=texCD(JoNTSC_L03,coord2);
2315
	res=lerp(color1,color2,f);
2316
	}else
2317
	if(int(TNTC)==4)
2318
	{
2319
	color1=texCD(JoNTSC_L04,coord1);
2320
	color2=texCD(JoNTSC_L04,coord2);
2321
	res=lerp(color1,color2,f);
2322
	}
2323
	res.rgb=fix_lut(res.rgb,imgColor.rgb);
2324
	color=lerp(imgColor.rgb,res.rgb,min(TNTC,1.0));
2325
	}
2326
	float3 c=clamp(color,0.0,1.0);
2327
	float3x3 m_o;
2328
	float p;
2329
	if(CS==0.0){p=2.2;m_o=ToRGB;}else
2330
	if(CS==1.0){p=2.2;m_o=ToMDN;}else
2331
	if(CS==2.0){p=2.6;m_o=ToDCI;}else
2332
	if(CS==3.0){p=2.2;m_o=ToADB;}else
2333
	if(CS==4.0){p=2.4;m_o=ToREC;}
2334
	if(CS==5.0){p=2.2;m_o=ToP3; }
2335
	color=pow(c,p);
2336
	float3x3 m_i;
2337
	if(CP==0.0){m_i=File0;}else
2338
	if(CP==1.0){m_i=File1;}else
2339
	if(CP==2.0){m_i=File2;}else
2340
	if(CP==3.0){m_i=File3;}else
2341
	if(CP==4.0){m_i=File4;}else
2342
	if(CP==5.0){m_i=File5;}
2343
	color=mul(color,m_i);
2344
	color=mul(color,m_o);
2345
	color=clamp(color,0.0,1.0);
2346
	color=pow(color,1.0/p);
2347
	if(CP==-1.0)color=c;
2348
	float3 solor1=plant(pow(color,wp_saturation),max(max(color.r,color.g),color.b));
2349
	float luma=dot(color,float3(0.299,0.587,0.114));
2350
	float3 solor2=lerp(luma,color,wp_saturation);
2351
	color=(wp_saturation>1.0)?solor1:solor2;
2352
	color=plant(color,contrast(max(max(color.r,color.g),color.b)));
2353
	p=2.2;
2354
	color=clamp(color,0.0,1.0);
2355
	color=pow(color,p);
2356
	float3 warmer=mul(color,D65_to_D55);
2357
	warmer=mul(warmer,ToRGB);
2358
	float3 cooler=mul(color,D65_to_D93);
2359
	cooler=mul(cooler,ToRGB);
2360
	float m=abs(WP)/100.0;
2361
	float3 comp=(WP<0.0)?cooler:warmer;
2362
	color=lerp(color,comp,m);
2363
	color=pow(max(color,0.0),1.0/p);
2364
	color=pgc(color);
2365
	float bp1 = min(BP, 0.0);
2366
	color = max(color + bp1/255.0, 0.0) / (1.0 + bp1/255.0*step(-bp1/255.0, max(max(color.r,color.g),color.b)));
2367
	color = color + aftrglow.rgb + bp;
2368
	color=min(color*pre_bb,1.0);
2369
	return float4(color,vignette(texcoord));
2370
}
2371
2372
float4 InterlacePS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2373
{
2374
    float3 c1=texCD(JoNTSC_S02,fuxcoord).rgb;
2375
    float3 c2=texCD(JoNTSC_S02,fuxcoord+float2(0.0,OrgSize.w)).rgb;
2376
    float3 c=c1;
2377
    float intera=1.0;
2378
    float m1=max(max(c1.r,c1.g),c1.b);
2379
    float m2=max(max(c2.r,c2.g),c2.b);
2380
    float3 df=abs(c1-c2);
2381
    float d=max(max(df.r,df.g),df.b);
2382
    if(interm==2.0) d=lerp(0.1*d,10.0*d,step(m1/(m2+0.0001),m2/(m1+0.0001)));
2383
    float r=m1;
2384
    float yres_div=1.0;if(intres>1.25)yres_div=intres;
2385
    bool hscans=(hiscan>0.5);
2386
    if(interr<=OrgSize.y/yres_div&&interm>0.5&&intres!=1.0&&intres!=0.5||hscans)
2387
    {
2388
    intera=0.25;
2389
    float liine_no=floor( mod(OrgSize.y*fuxcoord.y,2.0));
2390
    float frame_no=floor( mod(float(framecount),2.0));
2391
    float ii=abs(liine_no-frame_no);
2392
    if(interm< 3.5 || interm > 5.5)
2393
    {
2394
    if (interm == 6.0) c = lerp(c2, c1, ii); else
2395
    {
2396
    c2=plant(lerp(c2,c2*c2,iscans),max(max(c2.r,c2.g),c2.b));
2397
    r=max(m1*ii,(1.0-iscanb)*min(m1,m2));
2398
    c=plant(lerp(lerp(c1,c2,min(lerp(m1,1.0-m2,min(m1,1.0-m1))/(d+0.00001),1.0)),c1,ii),r);
2399
    if(interm==3.0) c=(1.0-0.5*iscanb)*lerp(c2,c1,ii);
2400
    }
2401
    }
2402
    if(interm==4.0){c=plant(lerp(c,c*c,0.5*iscans),max(max(c.r,c.g),c.b))*(1.0-0.5*iscanb);
2403
    }
2404
    if(interm==5.0){c=lerp(c2,c1,0.5);c=plant(lerp(c,c*c,0.5*iscans),max(max(c.r,c.g),c.b))*(1.0-0.5*iscanb);
2405
    }
2406
    if(hscans)c=c1;
2407
    }
2408
    return float4(c,intera);
2409
}
2410
2411
float4 Signal_1_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2412
{
2413
	float2 vtexcoord=texcoord*float2(speedup, 1.0);
2414
	float NOrgSize = (OrgSize.x < 400.0) ? OrgSize.x : OrgSize.x / max(round(OrgSize.x / 300.0), 1.0);
2415
	float phase = (ntsc_phase < 1.5) ? ((NOrgSize > 300.0 || (OrgSize.x > 400.0 && OrgSize.y > 250.0)) ? 2.0 : 3.0) : ((ntsc_phase > 2.5) ? 3.0 : 2.0);
2416
	if(ntsc_phase==4.0)phase=3.0; else if (ntsc_phase == 5.0) phase = 2.0;
2417
	float ntsc_sizex = (OrgSize.x < 400.0) ? OrgSize.x : (phase == 2.0) ? 320.0 : 256.0;
2418
	ntsc_sizex = (chr_freq < 1.5) ? ntsc_sizex : OrgSize.x;
2419
	float ntsc_sizey = OrgSize.y / max(round(OrgSize.y / 220.0), 1.0);
2420
	float2 pix_no = vtexcoord * float2(ntsc_sizex,ntsc_sizey) * float2(4.0, 1.0);
2421
	pix_no.y = round(pix_no.y);
2422
	float CHROMA_MOD_FREQ=(phase == 2.0 && ntsc_phase != 5.0) ? (4.0 * pii / 15.0) : ((NOrgSize <= 300.0 || phase == 3.0) ? (pii / 3.0) : (pii/2.0));
2423
	float ARTIFACT=cust_artifacting;
2424
	float FRINGING=cust_fringing;
2425
	float BRIGHTNESS=ntsc_brt;
2426
	float SATURATION=ntsc_sat;
2427
	float MERGE=0.0;
2428
	if(ntsc_fields== -1.0&&phase==3.0) MERGE=1.0;else
2429
	if(ntsc_fields== 0.0) MERGE=0.0;else
2430
	if(ntsc_fields== 1.0) MERGE=1.0;
2431
	float MIT = ntsc_taps;
2432
	MIT = smothstep(16.0, 8.0, MIT) * 0.325;
2433
	float3x3 mix_m = float3x3(BRIGHTNESS,FRINGING,FRINGING,ARTIFACT,2.0*SATURATION,0.0,ARTIFACT,0.0,2.0*SATURATION);
2434
	if (vtexcoord.x > 1.0) return 0.0.xxxx; else
2435
	{
2436
	float3 col0=texCD(JoNTSC_S0I, vtexcoord).rgb;
2437
	float3 yiq1=rgb2yiq(col0);
2438
	yiq1.x=pow(yiq1.x,ntsc_gamma);
2439
	float lum=yiq1.x;
2440
	float3 temp=yiq1;
2441
	float3 yiq2=yiq1;
2442
	float3 yiqs=yiq1;
2443
	float3 yiqz=yiq1;
2444
2445
	float res = nscale;
2446
2447
	if (abs(ntsc_dith) > 0.005 && OrgSize.y < 300.0 && (phase == 2.0 || ntsc_phase > 3.5))
2448
	{
2449
	float2 TexD = (floor(vtexcoord * OrgSize.xy) + 0.5)*OrgSize.zw;
2450
	float2 xx = float2(OrgSize.z, 0.0);
2451
2452
	float ca = get_luma(texCD(JoNTSC_S0I, TexD - xx - xx).rgb);
2453
	float c0 = get_luma(texCD(JoNTSC_S0I, TexD - xx).rgb);
2454
	float c1 = get_luma(texCD(JoNTSC_S0I, TexD     ).rgb);
2455
	float c2 = get_luma(texCD(JoNTSC_S0I, TexD + xx).rgb);
2456
	float cb = get_luma(texCD(JoNTSC_S0I, TexD + xx + xx).rgb);
2457
2458
	float line0  = smothstep(0.0075, 0.0, min(abs(c1-c0),abs(c2-c1)));
2459
	float line1  = max(smothstep(0.0075, 0.0, min(abs(ca-c0),abs(c2-cb))), line0);
2460
	float line2  = max(smothstep(0.0075, 0.0, min(abs(ca-c2),abs(c0-cb))), line1);
2461
	float nd = (ntsc_dith > 0.005) ? ntsc_dith : max(res-1.0, 0.0);
2462
	res /= 1.0 + (1.0-line2) * nd;
2463
	}
2464
2465
	if(MERGE>0.5)
2466
	{
2467
	float chroma_phase2=(phase<2.5)?pii*(mod(pix_no.y,2.0)+mod(float(framecount)+1,2.)):0.6667*pii*(mod(pix_no.y,3.0)+mod(float(framecount)+1,2.));
2468
	float mod_phase2=chroma_phase2+pix_no.x*CHROMA_MOD_FREQ;
2469
	float i_mod2=cos( mod_phase2 );
2470
	float q_mod2=sin( mod_phase2 );
2471
	yiq2.yz*=float2(i_mod2,q_mod2);
2472
	yiq2=mul(mix_m, yiq2);
2473
	yiq2.yz*=float2(i_mod2,q_mod2);
2474
	yiq2.yz =lerp(yiq2.yz,temp.yz,MIT);
2475
	if(res>1.025)
2476
	{
2477
	mod_phase2=chroma_phase2 + pix_no.x * CHROMA_MOD_FREQ * res;
2478
	i_mod2=cos(mod_phase2);
2479
	q_mod2=sin(mod_phase2);
2480
	yiqs.yz*=float2(i_mod2,q_mod2);
2481
	yiq2.x=dot(yiqs,mix_m[0]);
2482
	}
2483
	}
2484
	float chroma_phase1=(phase<2.5)?pii*(mod(pix_no.y,2.0)+mod(float(framecount)  ,2.)):0.6667*pii*(mod(pix_no.y,3.0)+mod(float(framecount)  ,2.));
2485
	float mod_phase1=chroma_phase1+pix_no.x*CHROMA_MOD_FREQ;
2486
	float i_mod1=cos( mod_phase1 );
2487
	float q_mod1=sin( mod_phase1 );
2488
	yiq1.yz*=float2(i_mod1,q_mod1);
2489
	yiq1=mul(mix_m, yiq1);
2490
	yiq1.yz*=float2(i_mod1,q_mod1);
2491
	yiq1.yz =lerp(yiq1.yz,temp.yz,MIT);
2492
	if(res>1.025)
2493
	{
2494
	mod_phase1=chroma_phase1 + pix_no.x*CHROMA_MOD_FREQ * res;
2495
	i_mod1=cos(mod_phase1);
2496
	q_mod1=sin(mod_phase1);
2497
	yiqz.yz*=float2(i_mod1,q_mod1);
2498
	yiq1.x=dot(yiqz,mix_m[0]);
2499
	}
2500
	if(ntsc_phase==4.0){yiq1.x=lum;yiq2.x=lum;}
2501
	if(MERGE>0.5){if(ntsc_rainbow<0.5||phase>2.5)yiq1=0.5*(yiq1+yiq2); else yiq1.x=0.5*(yiq1.x+yiq2.x);}
2502
	return float4(yiq1,lum);
2503
	}
2504
}
2505
2506
float4 Signal_2_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2507
{
2508
	float2 tex_c=texcoord+float2(0.5/speedup*OrgSize.z/4.0,0.0);
2509
	float NOrgSize = (OrgSize.x < 400.0) ? OrgSize.x : OrgSize.x / max(round(OrgSize.x / 300.0), 1.0);
2510
	float phase = (ntsc_phase < 1.5) ? ((NOrgSize > 300.0 || (OrgSize.x > 400.0 && OrgSize.y > 250.0)) ? 2.0 : 3.0) : ((ntsc_phase > 2.5) ? 3.0 : 2.0);
2511
	if (ntsc_phase == 4.0) phase = 3.0; else if (ntsc_phase == 5.0) phase = 2.0;
2512
	const int TAPS_2_phase=32;
2513
	const int TAPS_3_phase=24;
2514
	float luma_filter_2_phase[33]={
2515
   -0.000174844,-0.000205844,-0.000149453,-0.000051693, 0.000000000,-0.000066171,-0.000245058,-0.000432928,-0.000472644,-0.000252236, 0.000198929,
2516
    0.000687058, 0.000944112, 0.000803467, 0.000363199, 0.000013422, 0.000253402, 0.001339461, 0.002932972, 0.003983485, 0.003026683,-0.001102056,
2517
   -0.008373026,-0.016897700,-0.022914480,-0.021642347,-0.028863273, 0.027271957, 0.054921920, 0.098342579, 0.139044281, 0.168055832, 0.178571429};
2518
	float chroma_filter_2_phase[33]={
2519
   1.00000, 2.00000, 3.00000, 4.00000, 5.00000, 6.00000, 7.00000, 8.00000, 9.00000, 10.00000, 11.00000, 12.00000, 13.00000, 14.00000, 15.00000,
2520
   16.00000, 17.00000, 18.00000, 19.00000, 20.00000, 21.00000, 22.00000, 23.00000, 24.00000, 25.00000, 26.00000, 27.00000, 28.00000, 29.00000,
2521
   30.00000, 31.00000, 32.00000, 33.00000};
2522
	float chroma_filter_3_phase[33]={
2523
    0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000,
2524
    0.000000000, 0.000000000, 0.000000000,
2525
   -0.000118847,-0.000271306,-0.000502642,-0.000930833,-0.001451013,
2526
   -0.002064744,-0.002700432,-0.003241276,-0.003524948,-0.003350284,
2527
   -0.002491729,-0.000721149, 0.002164659, 0.006313635, 0.011789103,
2528
    0.018545660, 0.026414396, 0.035100710, 0.044196567, 0.053207202,
2529
    0.061590275, 0.068803602, 0.074356193, 0.077856564, 0.079052396};
2530
	if (tex_c.x * speedup > (1.00325)) discard;
2531
	float luma_filter_3_phase[33]={
2532
    0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000,
2533
    0.000000000, 0.000000000, 0.000000000,
2534
   -0.000012020,-0.000022146,-0.000013155,-0.000012020,-0.000049979,
2535
   -0.000113940,-0.000122150,-0.000005612, 0.000170516, 0.000237199,
2536
    0.000169640, 0.000285688, 0.000984574, 0.002018683, 0.002002275,
2537
   -0.005909882,-0.012049081,-0.018222860,-0.022606931, 0.002460860,
2538
    0.035868225, 0.084016453, 0.135563500, 0.175261268, 0.220176552};
2539
2540
	float res = nscale;
2541
   
2542
	if (abs(ntsc_dith) > 0.005 && OrgSize.y < 300.0 && (phase == 2.0 || ntsc_phase > 3.5))
2543
	{
2544
	float2 TexD = (floor(tex_c * OrgSize.xy) + 0.5)*OrgSize.zw;
2545
	float2 xx = float2(OrgSize.z, 0.0);
2546
2547
	float ca = texCD(JoNTSC_S03, TexD - xx - xx).a;
2548
	float c0 = texCD(JoNTSC_S03, TexD - xx).a;
2549
	float c1 = texCD(JoNTSC_S03, TexD     ).a;
2550
	float c2 = texCD(JoNTSC_S03, TexD + xx).a;
2551
	float cb = texCD(JoNTSC_S03, TexD + xx + xx).a;
2552
2553
	float line0  = smothstep(0.0075, 0.0, min(abs(c1-c0),abs(c2-c1)));
2554
	float line1  = max(smothstep(0.0075, 0.0, min(abs(ca-c0),abs(c2-cb))), line0);
2555
	float line2  = max(smothstep(0.0075, 0.0, min(abs(ca-c2),abs(c0-cb))), line1);
2556
	float nd = (ntsc_dith > 0.005) ? ntsc_dith : max(res-1.0, 0.0);
2557
	res /= 1.0 + (1.0-line2) * nd;
2558
	}
2559
2560
	float ntsc_sizex = (OrgSize.x < 400.0) ? OrgSize.x : (phase == 2.0) ? 320.0 : 256.0;
2561
	float2 one_x = 0.25 / ntsc_sizex.xx;
2562
	one_x.x = one_x.x / res / speedup;
2563
	one_x.y = one_x.y / speedup;
2564
   
2565
	float3 signal = float3(0.0, 0.0, 0.0);
2566
	if(ntsc_phase>3.5){luma_filter_3_phase=luma_filter_2_phase;}
2567
	float offset=0.0;int i=0; float j =0.0;
2568
	float3 wsum =0.0.xxx;
2569
	float3 sums=wsum;
2570
	float3 tmps=wsum;
2571
	if(phase<2.5)
2572
	{
2573
	one_x.y = one_x.y/ntsc_cscale1;
2574
	float3 dx = float3(one_x.x, one_x.y, 0.0);
2575
	float mit = 1.0;
2576
	float loob = ntsc_taps;
2577
	loob = max(loob, 8.0); mit = 1.0 + 0.04*pow(smothstep(16.0, 8.0, loob), 0.5);
2578
	float3 xd = dx; dx.x*=mit;
2579
	int loopstart = int(32.0 - loob);
2580
	int j = loopstart;
2581
	for(i=loopstart;i<32;i++)
2582
	{
2583
	offset = float(i-loopstart); xd.xy = (offset - loob)*dx.xy;
2584
	j = i - loopstart;
2585
	sums = fetch_offset(xd);
2586
	tmps = float3(luma_filter_2_phase[i], chroma_filter_2_phase[j].xx);
2587
	wsum=wsum+tmps;
2588
	signal+=sums*tmps;
2589
	}
2590
	j = int(loob);
2591
	tmps=float3(luma_filter_2_phase[TAPS_2_phase], chroma_filter_2_phase[j], chroma_filter_2_phase[j]);
2592
	wsum=wsum+wsum+tmps;
2593
	signal+=texCD(JoNTSC_S03,tex_c).xyz*tmps;
2594
	signal =signal/wsum;
2595
	}else
2596
	{
2597
	one_x.y=one_x.y/ntsc_cscale2;
2598
	float3 dx=float3(one_x.x,one_x.y,0.0);
2599
	float mit=1.0;
2600
	float loob=min(ntsc_taps,TAPS_3_phase); 
2601
	if(ntsc_phase>3.5){loob=max(loob,8.0); mit=1.0+0.04*pow(swoothstep(16.0,8.0,loob),0.5);}
2602
	float3 xd=dx; dx.x*=mit;
2603
	int loopstart=int(32.0-loob);
2604
	for(i=loopstart;i<32;i++)
2605
	{
2606
	offset=float(i-loopstart); xd.xy=(offset-loob)*dx.xy;
2607
	sums=fetch_offset(xd);
2608
	tmps=float3(luma_filter_3_phase[i], chroma_filter_3_phase[i].xx);
2609
	wsum=wsum+tmps;
2610
	signal+=sums*tmps;
2611
	}
2612
	tmps=float3(luma_filter_3_phase[TAPS_2_phase], chroma_filter_3_phase[TAPS_2_phase], chroma_filter_3_phase[TAPS_2_phase]);
2613
	wsum=wsum+wsum+tmps;
2614
	signal+=texCD(JoNTSC_S03,tex_c).xyz*tmps;
2615
	signal =signal/wsum;
2616
	}
2617
	signal.x=clamp( signal.x,0.0,1.0);
2618
	if(ntsc_ring>0.05)
2619
	{
2620
	float2 dx=float2(OrgSize.z/min(res,1.0)/speedup,0.0);
2621
	float a=texCD(JoNTSC_S03,tex_c-2.0*dx).a;
2622
	float b=texCD(JoNTSC_S03,tex_c-    dx).a;
2623
	float c=texCD(JoNTSC_S03,tex_c+2.0*dx).a;
2624
	float d=texCD(JoNTSC_S03,tex_c+    dx).a;
2625
	float e=texCD(JoNTSC_S03,tex_c       ).a;
2626
	signal.x=lerp(signal.x,clamp(signal.x,min(min(min(a,b),min(c,d)),e),max(max(max(a,b),max(c,d)),e)),ntsc_ring);
2627
	}
2628
	float x=get_luma(texCD(JoNTSC_S02, tex_c*float2(speedup, 1.0)).rgb);
2629
	return float4(signal,x);
2630
}
2631
2632
float4 Signal_3_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2633
{
2634
    float auto_rez = lerp(1.0, 0.5, clamp(auto_res * round(OrgSize.x/300.0)-1.0, 0.0, 1.0));
2635
    float2 vtex_c0=texcoord / float2(speedup, 1.0);
2636
    float2 vtex_c1=(floor(vtex_c0*OrgSize.xy)+0.5)*OrgSize.zw;
2637
    float2 vtex_c=texcoord+float2(0.5*(OrgSize.z/auto_rez)/4.0,0.0);
2638
    float NOrgSize = (OrgSize.x < 400.0) ? OrgSize.x : OrgSize.x / max(round(OrgSize.x / 300.0), 1.0);
2639
    float phase = (ntsc_phase < 1.5) ? ((NOrgSize > 300.0 || (OrgSize.x > 400.0 && OrgSize.y > 250.0)) ? 2.0 : 3.0) : ((ntsc_phase > 2.5) ? 3.0 : 2.0);
2640
    if (ntsc_phase == 4.0) phase = 3.0; else if (ntsc_phase == 5.0) phase = 2.0;
2641
2642
    float4 AdvSize= LumSize;
2643
2644
    if(speedup > 1.25 && ((OrgSize.y > 500.0 && AdvSize.y > 820.0) || AdvSize.y > 820.0))
2645
    {
2646
        float3 signal = texCD(JoNTSC_S04, vtex_c0).xyz;
2647
        signal.x = pow(signal.x, 1.0/ntsc_gamma);
2648
        return float4(clamp(yiq2rgb(signal), 0.0, 1.0), 1.0);
2649
    }
2650
    else
2651
    {
2652
2653
	float2 xx=float2(0.5000*OrgSize.z/auto_rez/speedup,0.0);
2654
	float2 dx=float2(0.0625*OrgSize.z/auto_rez/speedup,0.0);
2655
2656
	float2 tcoorb=(floor(OrgSize.xy*vtex_c)+0.5)*OrgSize.zw;
2657
	float2 tcoord=vtex_c-2.0*dx;
2658
	float2 vTex=vtex_c;
2659
	if (speedup > 1.25) { tcoorb = vtex_c1; tcoord = vtex_c0; vTex = vtex_c0; }
2660
	float3 ll1=texCD(JoNTSC_S04,tcoord+ xx).xyz;
2661
	float3 ll2=texCD(JoNTSC_S04,tcoord- xx).xyz;
2662
	float dy=0.0;
2663
	float2 yy = float2(0.0, OrgSize.w);
2664
	xx=float2(OrgSize.z/auto_rez/speedup,0.0);
2665
	float th=(phase<2.5)?0.025:0.0075;;
2666
	float ca=texCD(JoNTSC_S03,tcoorb-xx-xx).a;
2667
	float c0=texCD(JoNTSC_S03,tcoorb-xx   ).a;
2668
	float c1=texCD(JoNTSC_S03,tcoorb      ).a;
2669
	float c2=texCD(JoNTSC_S03,tcoorb+xx   ).a;
2670
	float cb=texCD(JoNTSC_S03,tcoorb+xx+xx).a;
2671
	float line0=    swoothstep(th,0.0,min(abs(c1-c0),abs(c2-c1)));
2672
	float line1=max(swoothstep(th,0.0,min(abs(ca-c0),abs(c2-cb))), line0 );
2673
	float line2=max(swoothstep(th,0.0,min(abs(ca-c2),abs(c0-cb))), line1 );
2674
2675
    float diffboost = 0.0;
2676
2677
    if (ntsc_fonts > 0.255)
2678
    {
2679
        float b1  = texCD(JoNTSC_S03, tcoorb - yy).a;
2680
        float d1  = texCD(JoNTSC_S03, tcoorb + yy).a;
2681
        float d2  = texCD(JoNTSC_S03, tcoorb + xx + yy).a;
2682
2683
        float maxdif = float(0.5 * (abs(c0-c1) + abs(c1-c2)) > (1.0 - ntsc_fonts)) * float(abs(c2-c0) < 0.05);
2684
        float linecb = swoothstep(0.1, 0.0, max(abs(c1-b1), abs(c1-d1)));
2685
        linecb = linecb * float(abs(c1-b1) < 0.05 || abs(c2-d2) < 0.05);
2686
2687
        b1 = texCD(JoNTSC_S04, tcoord         ).x;
2688
        d1 = texCD(JoNTSC_S04, tcoord - 9.0*yy).x;
2689
        d2 = texCD(JoNTSC_S04, tcoord + 9.0*yy).x;
2690
   
2691
        maxdif = maxdif * float((abs(d1-b1) > 0.2 || abs(d2-b1) > 0.2));
2692
2693
        float xdif1 = 0.0;
2694
        float xdif2 = 0.0;
2695
        float th   = 0.215;
2696
2697
        for (float i = 0.5; i < 10.5; i++)
2698
        {
2699
            float j = i + 1.0;
2700
            ca  = texCD(JoNTSC_S04, tcoord -  i*xx).x;
2701
            c0  = texCD(JoNTSC_S04, tcoord -  j*xx).x;
2702
            c2 = texCD(JoNTSC_S04, tcoord +  i*xx).x;
2703
            cb = texCD(JoNTSC_S04, tcoord +  j*xx).x;
2704
            xdif1 = max(abs(ca - c0) - th, xdif1);
2705
            xdif2 = max(abs(cb - c2) - th, xdif2);
2706
        }
2707
2708
        float linex   = swoothstep(0.0, 0.125, min(xdif1, xdif2));
2709
        diffboost     = min(linex * linecb * maxdif, 0.625);
2710
    }
2711
2712
    float3 ref = texCD(JoNTSC_S04, tcoord).xyz;
2713
    float2 org = ref.yz;
2714
	if( ntsc_rainbow>0.5&&(phase<2.5 || ntsc_phase == 5.0))
2715
	{
2716
	float ybool1=1.0;
2717
	if((ntsc_rainbow<1.5)&&bool(line0))ybool1=0.0;else
2718
	if((ntsc_rainbow<2.5)&&bool(line2))ybool1=0.0;
2719
2720
	float liine_no=floor( mod(OrgSize.y*vtex_c.y,2.0));
2721
	float frame_no=floor( mod(float(framecount),2.0));
2722
	float ii=abs(liine_no-frame_no);
2723
	dy=ii*OrgSize.w*ybool1;
2724
	float2 ref1 = texCD(JoNTSC_S04, tcoord + float2(0.0, -dy)).yz;
2725
				   
2726
	float2 ref2 = texCD(JoNTSC_S04, tcoord + float2(0.0,  dy)).yz;
2727
	float2 rdf1 = abs(org - ref1);
2728
	float2 rdf2 = abs(org - ref2);
2729
	rdf1        = rdf1 / max(rdf1 + rdf2, 0.0000001);
2730
2731
	ref.yz = lerp(ref1, ref2, rdf1);
2732
	}
2733
	float lum1=min(texCD(JoNTSC_S03,vTex-dx).a, texCD(JoNTSC_S03,vTex+dx).a);
2734
	float lum2=ref.x ;
2735
	float3 ll3=abs(ll1-ll2);
2736
	float di=max(max(max(ll3.x,ll3.y),max(ll3.z,abs(ll1.x*ll1.x-ll2.x*ll2.x))),diffboost);
2737
	float df=pow(di,0.125);
2738
	float lc=swoothstep(0.20,0.10,abs(lum2-lum1))*df;
2739
	float tmp1=swoothstep(0.05-0.03*lc,0.425-0.375*lc,di);
2740
	float tmp2=pow((tmp1+0.1)/1.1,0.25);
2741
	float sweight=lerp(tmp1,tmp2,line0);
2742
	float zweight=lerp(tmp1,tmp2,line2);
2743
	float3 signal=ref;
2744
	float ntzc_shrp= abs(ntsc_shrp);
2745
	if(ntzc_shrp>0.25 || ntsc_fonts > 0.255)
2746
	{
2747
	float mixer=zweight;
2748
	if(ntsc_shrp < -0.25)mixer=sweight; mixer*=max(0.1*ntzc_shrp, diffboost*1.25);
2749
	float lumix=lerp(lum2,lum1,mixer);
2750
	float lm1=lerp(lum2*lum2 ,lum1*lum1 ,mixer);lm1=sqrt(lm1);
2751
	float lm2=lerp(sqrt(lum2),sqrt(lum1),mixer);lm2=lm2* lm2 ;
2752
	float k1=abs(lumix-lm1)+0.00001;
2753
	float k2=abs(lumix-lm2)+0.00001;
2754
	signal.x=min((k2*lm1+k1*lm2)/(k1+k2),1.0);
2755
	signal.x=min(signal.x,max(ntsc_shpe*signal.x,lum2));
2756
	}
2757
	if((ntsc_charp1+ntsc_charp2)>0.25)
2758
	{
2759
	dx.x = 0.0625 * OrgSize.z/auto_rez;
2760
	float lcoord=OrgSize.x*(vtex_c.x+dx.x )-0.5;
2761
	float fpx=frac(lcoord);
2762
	lcoord =(floor(lcoord)+0.5)*OrgSize.z;
2763
	float mixer=sweight;
2764
	if(ntsc_shrp>0.25)mixer=zweight;
2765
	mixer =lerp(swoothstep(0.075,0.125,max(ll3.y,ll3.z)),swoothstep(0.015,0.0275,di),line2)*mixer;
2766
	mixer*=0.1*((phase<2.5)? ntsc_charp1:ntsc_charp2);
2767
	tcoord=float2(lcoord,tcoord.y);
2768
	float3 origin=rgb2yiq(lerp(texCD(JoNTSC_S02,tcoord).rgb,texCD(JoNTSC_S02,tcoord+16.0*dx).rgb,clamp(1.5*fpx-0.25,0.0,1.0)));
2769
	signal.yz=lerp(signal.yz,origin.yz,mixer);
2770
	}
2771
2772
    if ((RFNOISE1 + RFNOISE2) > 0.005)
2773
    {
2774
        float3 ns = NoiseNP3(vtex_c, float(framecount));
2775
        float Y   = lerp(0.375, 1.0, pow(signal.x, 0.2));
2776
2777
        signal.x = clamp(signal.x + RFNOISE1 * ns.x,  0.00, 1.00);
2778
        signal.y = clamp(signal.y + Y * RFNOISE2 * (0.325 + 1.325 * abs(signal.y)) * ns.y, -0.60, 0.60);
2779
        signal.z = clamp(signal.z + Y * RFNOISE2 * (0.325 + 1.325 * abs(signal.z)) * ns.z, -0.53, 0.53);
2780
    }
2781
	signal.x=pow(signal.x,1.0/ntsc_gamma);
2782
	signal=clamp(yiq2rgb(signal),0.0,1.0);
2783
    zweight = (phase == 2.0 || ntsc_phase > 3.5) ? zweight : 1.0;
2784
	return float4(signal,zweight);
2785
    }
2786
}
2787
2788
float4 SharpnessPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2789
{
2790
	float resmult = round(OrgSize.x / 300.0);
2791
	float2 g01=float2(-0.5*resmult*OrgSize.z,0.0);
2792
	float2 g21=float2( 0.5*resmult*OrgSize.z,0.0);
2793
	float3 c01=texCD(JoNTSC_S05,texcoord+g01).rgb;
2794
	float3 c21=texCD(JoNTSC_S05,texcoord+g21).rgb;
2795
	float3 c11=texCD(JoNTSC_S05,texcoord    ).rgb;
2796
	float3 b11=0.5*(c01+c21);
2797
	float contrazt=max(max(c11.r,c11.g),c11.b);
2798
	contrazt=lerp(2.0*CCONTR,CCONTR,contrazt);
2799
	float3 nim=min(min(c01,c21),c11);float3 mn1=min(nim,c11*(1.0-contrazt));
2800
	float3 xam=max(max(c01,c21),c11);float3 mx1=max(xam,c11*(1.0+contrazt));
2801
	float3 di0=pow(mx1-mn1+0.00001,0.75);
2802
	float3 sharpen=lerp(CSHARPEN*CDETAILS,CSHARPEN,di0);
2803
	float3 res=clamp(lerp(c11,b11,-sharpen),mn1,mx1);
2804
	if(NDEBLUR>1.125)
2805
	{
2806
	float2 toxcoord=(floor(OrgSize.xy*texcoord)+0.5)*OrgSize.zw;
2807
	float l01=get_luma(texCD(JoNTSC_S02,texcoord+2.0*g01).rgb);
2808
	float l21=get_luma(texCD(JoNTSC_S02,texcoord+2.0*g21).rgb);
2809
	float l11=get_luma(texCD(JoNTSC_S02,toxcoord        ).rgb);
2810
	float dth = texCD(JoNTSC_S05,texcoord).a;
2811
	float DEB = max(lerp(0.375*NDEBLUR, NDEBLUR, max(1.0-DSMART, dth)), 1.0);
2812
	float d11=min(min(l01,l21),l11);
2813
	l11=max(max(l01,l21),l11);
2814
	float lmn=min(min(get_luma(c01),get_luma(c21)),get_luma(c11));float ln1=min(lerp(d11,lmn,lmn),lmn);
2815
	float lmx=max(max(get_luma(c01),get_luma(c21)),get_luma(c11));float lx1=max(lerp(lmx,l11,lmx),lmx);
2816
	float r11=get_luma(res);
2817
	float di1=max((r11-ln1),0.0)+0.00001;di1=pow(di1,DEB);
2818
	float di2=max((lx1-r11),0.0)+0.00001;di2=pow(di2,DEB);
2819
	float ratio=di1/(di1+di2);
2820
	float zharpen=lerp(ln1,lx1,ratio);
2821
	zharpen=min(zharpen,max(DREDGE*zharpen,r11));
2822
	res=rgb2yiq(res);
2823
	d11=res.x;
2824
	res.x=zharpen;
2825
	res.x=clamp((1.0+ DSHARP)* res.x-DSHARP*d11,ln1*(1.0-contrazt),lx1*(1.0+contrazt));
2826
	res=max(yiq2rgb(res),0.0);
2827
	}
2828
	return float4(res,1.0);
2829
}
2830
2831
float4 PS_CRT_BlackCrush_AvgLum(float4 position:SV_Position,float2 texcoord:TEXCOORD) : SV_Target
2832
{
2833
    float vTsmooth = 0.8;
2834
    const float tsmooth_at_60 = 0.8;
2835
    const float tsmooth_at_30 = 0.65;
2836
    float t = get_fps() > 90 ? 0.95 : ((60.0 - get_fps()) / 30.0);
2837
    vTsmooth = lerp(tsmooth_at_60, tsmooth_at_30, t);
2838
2839-
    float3 c_current = texCD(JoNTSC_S06, texcoord).rgb;
2839+
    float3 c_current = tex2Dlod(JoNTSC_S06, float4(float2(0.5, 0.5), 20.0, 0.0)).rgb;
2840
    float lum_past = tex2Dlod(JBCrsh_S01, float4(float2(0.5,0.5), 20.0, 0)).a;
2841
    float lum_current = (c_current.r + c_current.g + c_current.b) / 3.0;
2842
2843
    if (framecount == 0.0) lum_past = lum_current;
2844
    float lum_avg = lerp(lum_current, lum_past, vTsmooth);
2845-
    return float4(c_current, lum_avg);
2845+
    return float4(texCD(JoNTSC_S06, texcoord).rgb, lum_avg);
2846
}
2847
2848
float4 PS_CRT_BlackCrush(float4 position:SV_Position,float2 texcoord:TEXCOORD) : SV_Target
2849
{
2850
    float lum = tex2Dlod(JBCrsh_S01, float4(float2(0.5,0.5), 20.0,0)).a;
2851-
    float3 c = texCD(JoNTSC_S06, texcoord).rgb;
2851+
    float3 c = texCD(JBCrsh_S01, texcoord).rgb;
2852
    c = adaptive_black(c, lum, abs(ADPT_BLK_RANGE),ADPT_BLK_RANGE > 0.0);
2853
2854
    return float4(c, 1.0);
2855
}
2856
2857
float4 LuminancePS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2858
{
2859
	float m=max(log2(LumSize.x),log2(LumSize.y));
2860
	m=floor(max(m,1.0))-1.0;
2861
	float2 dx=float2(1.0/LumSize.x,0.0);
2862
	float2 dy=float2(0.0,1.0/LumSize.y);
2863
	float2 x2=2.0*dx;
2864
	float2 y2=2.0*dy;
2865
	float ltotal=0.0;
2866
	ltotal+=length(tex2Dlod(JBCrsh_S02,float4(float2(0.3,0.3),m,0)).rgb);
2867
	ltotal+=length(tex2Dlod(JBCrsh_S02,float4(float2(0.3,0.7),m,0)).rgb);
2868
	ltotal+=length(tex2Dlod(JBCrsh_S02,float4(float2(0.7,0.3),m,0)).rgb);
2869
	ltotal+=length(tex2Dlod(JBCrsh_S02,float4(float2(0.7,0.7),m,0)).rgb);
2870
	ltotal*=0.25;
2871
	ltotal=pow(0.577350269*ltotal,0.7);
2872
	float lhistory=texCD(JoNTSC_S07,float2(0.5,0.5)).a;
2873
	ltotal=lerp(ltotal,lhistory,min(lerp(lsmooth, lsmooth + lsdev, ltotal),0.99));
2874
	float3 l1=texCD(JBCrsh_S02,fuxcoord.xy   ).rgb;
2875
	float3 r1=texCD(JBCrsh_S02,fuxcoord.xy+dx).rgb;
2876
	float3 l2=texCD(JBCrsh_S02,fuxcoord.xy-dx).rgb;
2877
	float3 r2=texCD(JBCrsh_S02,fuxcoord.xy+x2).rgb;
2878
	float c1=dist(l2,l1);
2879
	float c2=dist(l1,r1);
2880
	float c3=dist(r2,r1);
2881
	return float4(c1,c2,c3,ltotal);
2882
}
2883
2884
2885
float4 LinearizeNewPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2886
{
2887
    float3 c = texCD(JBCrsh_S02,fuxcoord).rgb;
2888
    if((downsample_levelx+downsample_levely)>0.025)
2889
    {
2890
    c=fetch_pixel(fuxcoord);
2891
    }
2892
    float intera = texCD(JoNTSC_S0I,fuxcoord).a;
2893
    float gamma_in=gamma_i;
2894
    c=pow(c,gamma_in);
2895
    if(fuxcoord.x>0.5)gamma_in=intera;else gamma_in=1.0/gamma_in;
2896
    return float4(c,gamma_in);
2897
}
2898
2899
float4 HGaussianPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2900
{
2901
	float FINE_GAUSS= (FINE_GAUSS>0.5)? FINE_GAUSS: lerp(0.75,0.50,-FINE_GAUSS);
2902
	float4 AdvSize=float4(OrgSize.x,OrgSize.y,OrgSize.z,OrgSize.w)*float4(FINE_GAUSS,FINE_GAUSS,1.0/FINE_GAUSS,1.0/FINE_GAUSS);
2903
	float f=frac(AdvSize.x*texcoord.x);
2904
	f=0.5-f;
2905
	float2 tex=floor(AdvSize.xy*texcoord)*AdvSize.zw+0.5*AdvSize.zw;
2906
	float3 color=0.0;
2907
	float2 dx=float2(AdvSize.z ,0.0);
2908
	float3 pixel;
2909
	float w;
2910
	float wsum=0.0;
2911
	float n=-SIZEH;
2912
	do
2913
	{
2914
	pixel=texCD(JoNTSC_S08,tex+n*dx).rgb;
2915
	if(m_glow>0.5)
2916
	{
2917
	pixel=max(pixel-m_glow_cutoff,0.0);
2918
	pixel=plant(pixel,max(max(max(pixel.r,pixel.g),pixel.b)-m_glow_cutoff,0.0));
2919
	}
2920
	w=gauss_h(n+f);
2921
	color=color+w*pixel;
2922
	wsum=wsum+w;
2923
	n=n+1.0;
2924
	}
2925
	while(n<=SIZEH);
2926
	color=color/wsum;
2927
	return float4(color,1.0);
2928
}
2929
2930
float4 VGaussianPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2931
{
2932
	float FINE_GAUSS= (FINE_GAUSS>0.5)? FINE_GAUSS: lerp(0.75,0.50,-FINE_GAUSS);
2933
	float4 AdvSize=float4(SrcSize.x,OrgSize.y,SrcSize.z,OrgSize.w)*float4(FINE_GAUSS,FINE_GAUSS,1.0/FINE_GAUSS,1.0/FINE_GAUSS);
2934
	float f=frac(AdvSize.y*texcoord.y);
2935
	f=0.5-f;
2936
	float2 tex=floor(AdvSize.xy*texcoord)*AdvSize.zw+0.5*AdvSize.zw;
2937
	float3 color=0.0;
2938
	float2 dy=float2(0.0,AdvSize.w );
2939
	float3 pixel;
2940
	float w;
2941
	float wsum=0.0;
2942
	float n=-SIZEV;
2943
	do
2944
	{
2945
	pixel=texCD(JoNTSC_S10,tex+n*dy).rgb;
2946
	w=gauss_v(n+f);
2947
	color=color+w*pixel;
2948
	wsum=wsum+w;
2949
	n=n+1.0;
2950
	}
2951
	while(n<=SIZEV);
2952
	color=color/wsum;
2953
	return float4(color,1.0);
2954
}
2955
2956
float4 BloomHorzPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2957
{
2958
	float FINE_BLOOM= (FINE_BLOOM>0.5)? FINE_BLOOM: lerp(0.75,0.50,-FINE_BLOOM);
2959
	float4 AdvSize=float4(OrgSize.x,OrgSize.y,OrgSize.z,OrgSize.w)*float4(FINE_BLOOM,FINE_BLOOM,1.0/FINE_BLOOM,1.0/FINE_BLOOM);
2960
	float f=frac(AdvSize.x*texcoord.x);
2961
	f=0.5-f;
2962
	float2 tex=floor(AdvSize.xy*texcoord)*AdvSize.zw+0.5*AdvSize.zw;
2963
	float4 color=0.0;
2964
	float2 dx=float2(AdvSize.z ,0.0);
2965
	float4 pixel;
2966
	float w;
2967
	float wsum=0.0;
2968
	float n=-SIZEX;
2969
	do
2970
	{
2971
	pixel=texCD(JoNTSC_S08,tex+n*dx);
2972
	w=bloom_h(n+f);
2973
	pixel.a =max(max(pixel.r,pixel.g),pixel.b);
2974
	pixel.a*=pixel.a*pixel.a;
2975
	color=color+w*pixel;
2976
	wsum=wsum+w;
2977
	n=n+1.0;
2978
	}
2979
	while(n<=SIZEX);
2980
	color=color/wsum;
2981
	return float4(color.rgb,pow(color.a,0.333333));
2982
}
2983
2984
float4 BloomVertPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2985
{
2986
	float FINE_BLOOM= (FINE_BLOOM>0.5)? FINE_BLOOM: lerp(0.75,0.50,-FINE_BLOOM);
2987
	float4 AdvSize=float4(SrcSize.x,OrgSize.y,SrcSize.z,OrgSize.w)*float4(FINE_BLOOM,FINE_BLOOM,1.0/FINE_BLOOM,1.0/FINE_BLOOM);
2988
	float f=frac(AdvSize.y*texcoord.y);
2989
	f=0.5-f;
2990
	float2 tex=floor(AdvSize.xy*texcoord)*AdvSize.zw+0.5*AdvSize.zw;
2991
	float4 color=0.0;
2992
	float2 dy=float2(0.0,AdvSize.w );
2993
	float4 pixel;
2994
	float w;
2995
	float wsum=0.0;
2996
	float n=-SIZEY;
2997
	do
2998
	{
2999
	pixel=texCD(JoNTSC_S12,tex+n*dy);
3000
	w=bloom_v(n+f);
3001
	pixel.a*=pixel.a*pixel.a;
3002
	color=color+w*pixel;
3003
	wsum=wsum+w;
3004
	n=n+1.0;
3005
	}
3006
	while(n<=SIZEY);
3007
	color=color/wsum;
3008
	return float4(color.rgb,pow(color.a,0.175000));
3009
}
3010
3011
float4 NTSC_TV1_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
3012
{
3013
	float f=frac(LumSize.x*fuxcoord.x);
3014
	f=0.5-f;
3015
	float2 tex=floor(LumSize.xy*fuxcoord)*LumSize.zw+0.5*LumSize.zw;
3016
	float3 color=0.0.xxx;
3017
	float solor=0.0;
3018
	float2 dx=float2(LumSize.z ,0.0);
3019
	float3 pixel;
3020
	float w=0.0;
3021
	float swum=0.0;
3022
	float wsum=0.0;
3023
	float3 cmax=0.0.xxx;
3024
	float3 cmin=1.0.xxx;
3025
	float xs=max(2.0*0.4, 1.0);
3026
	float hsharpness=HSHARPNESS*xs*filter_res;
3027
	float LIGMA_H2 = LIGMA_H * HSHARPNESS;
3028
	xs=1.0/(2.0*LIGMA_H2*LIGMA_H2*xs*xs*filter_res*filter_res);
3029
	float sharp=crthd_h(hsharpness,xs) *S_SHARP;
3030
	float ksharp = -2.0*hsharpness*xs*sharp;	
3031
	float maxsharp=MAXS;
3032
	float FPR=hsharpness;
3033
	float FPRi=1.0/hsharpness;
3034
	float fpx=0.0;
3035
	float sp=0.0;
3036
	float sw=0.0;
3037
	float ts=0.025;
3038
	float3 luma=float3(0.2126,0.7152,0.0722);
3039
	float LOOPSIZE=ceil(2.0*FPR);
3040
	float n=-LOOPSIZE;
3041
	do
3042
	{
3043
	pixel=texCD(JoNTSC_S08,tex+n*dx).rgb;
3044
	w=crthd_h(n+f,xs)-sharp;
3045
	fpx=clamp((abs(n+f)-FPR)*FPRi, 0.0, 1.0);
3046
	if(w<0.0)w=max(ksharp*fpx, maxsharp * ksharp * (1.0-fpx*fpx)); else
3047
	{
3048
	cmax=max(cmax,pixel);cmin=min(cmin,pixel);sw=w*(dot(pixel,luma)+ts);
3049
	sp=max(max(pixel.r,pixel.g),pixel.b);
3050
	solor=solor+sw*sp;
3051
	swum=swum+sw;
3052
	}
3053
	color=color+w*pixel;
3054
	wsum=wsum+w;
3055
	n=n+1.0;
3056
	}
3057
	while(n<=LOOPSIZE);
3058
	color=color/wsum;
3059
	solor=solor/swum;
3060
	color=clamp(lerp( clamp (color,cmin,cmax),color,SSRNG),0.0,1.0);
3061
	solor=clamp(lerp(max(max(color.r,color.g),color.b),solor,spike),0.0,1.0);
3062
	return float4(color,solor);
3063
}
3064
3065
float4 NTSC_TV2_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
3066
{
3067
	float gamma_in=1.0/texCD(JoNTSC_S08,float2(0.25,0.25)).a;
3068
	float lum=texCD(JoNTSC_S07,float2(0.5,0.5)).a;
3069
	float intera=texCD(JoNTSC_S08,float2(0.75,0.25)).a;
3070
	bool hscans=(hiscan>0.5);
3071
	bool inter6=(intera<0.35&&interm==6.0);
3072
	bool interb=(((intera<0.35&&!inter6)||(no_scanlines>0.025))&&!hscans);
3073
	float4 AdvSize= LumSize;
3074
	float SourceY=AdvSize.y;
3075
	float sy=1.0;
3076
	if( intres==1.0)sy=max(round(SourceY/224.0),1.0);
3077
	if( intres>0.25&&intres!=1.0)sy=intres;
3078
	if (inter6) sy*=2.0;
3079
	AdvSize*=float4(1.0,1.0/sy,1.0,sy);
3080
	float2 lexcoord=fuxcoord.xy;
3081
	if(IOS> 0.0&& !interb)
3082
	{
3083
	float2 ofactor= NewSize.xy/OrgSize.xy;
3084
	float2 ifactor=(IOS<2.5)? floor(ofactor):ceil(ofactor);
3085
	float2 diff=ofactor/ifactor;
3086
	float scan=diff.y;
3087
	lexcoord=overscan(lexcoord,scan,scan);
3088
	if(IOS==1.0||IOS==3.0) lexcoord=float2(fuxcoord.x,lexcoord.y);
3089
	}
3090
	float factor=1.0+(1.0-0.5*OS)*blm_2/100.0-lum*blm_2/100.0;
3091
	lexcoord=overscan(lexcoord,factor,factor);
3092
	lexcoord.y = lexcoord.y - VShift*OrgSize.w;
3093
	lexcoord=overscan(lexcoord,(OrgSize.x-overscanx)/OrgSize.x,(OrgSize.y-overscany)/OrgSize.y);
3094
	float2 pos = warp(lexcoord);
3095
	float ii = float(inter6)*(floor(mod(float(framecount), 2.0)));
3096
	float2 coffset = float2(0.5, 0.5 + 0.5*ii);
3097
	float2 ps=AdvSize.zw;
3098
	float2 OGL2Pos=pos*AdvSize.xy-coffset;
3099
	float2 fp=frac(OGL2Pos);
3100
	float2 dx=float2(ps.x,0.0);
3101
	float2 dy=float2(0.0,ps.y);
3102
	float f=fp.y;
3103
	float2 pC4=floor(OGL2Pos)*ps+0.5*ps; pC4.y = pC4.y + float(inter6)*0.25*dy.y;
3104
	pC4.x=pos.x;
3105
	if( intres==0.5<1.5)pC4.y=floor(pC4.y*OrgSize.y)*OrgSize.w+0.5*OrgSize.w;
3106
	if( interb&&no_scanlines<0.025|| hscans) pC4.y=pos.y;else
3107
	if( interb) pC4.y=pC4.y+smoothstep(0.40-0.5*no_scanlines,0.60+0.5*no_scanlines,f)*AdvSize.w;
3108
	float3 color1=texCD(JoNTSC_S09,pC4).rgb;
3109
	float3 solor1=texCD(JoNTSC_S09,pC4).aaa;
3110
	if(!interb)color1=pow(color1,scangamma/gamma_in);
3111
	pC4+=dy;
3112
	if( intres==0.5<1.5)pC4.y=floor((pos.y+0.33*dy.y)*OrgSize.y)*OrgSize.w+0.5*OrgSize.w;
3113
	float3 color2=texCD(JoNTSC_S09,pC4).rgb;
3114
	float3 solor2=texCD(JoNTSC_S09,pC4).aaa;
3115
	if(!interb)color2=pow(color2,scangamma/gamma_in);
3116
	float3 ctmp=color1;float w3=1.0;float3 color=color1;
3117
	float3 one=1.0;
3118
	if( hscans){color2=color1;solor2=solor1;}
3119
	if(!interb|| hscans)
3120
	{
3121
	float ssub = ssharp*abs(solor1.x-solor2.x);
3122
	float shape1=lerp(scanline1,scanline2 + ssub * solor1.x * 35.0,    f);
3123
	float shape2=lerp(scanline1,scanline2 + ssub * solor2.x * 35.0,1.0-f);
3124
	float wt1=st0(    f);
3125
	float wt2=st0(1.0-f);
3126
	float3 color0=color1*wt1+color2*wt2;
3127
	float3 solor0=solor1*wt1+solor2*wt2;
3128
	ctmp = color0/(wt1+wt2);
3129
	float3 stmp=solor0/(wt1+wt2);
3130
	if(abs(rolling_scan)>0.005){color1=ctmp;color2=ctmp;solor1=stmp;solor2=stmp;}
3131
	float3 w1,w2;
3132
	float3 cref1=lerp(stmp,solor1,beam_size);float creff1=pow(max(max(cref1.r,cref1.g),cref1.b),scan_falloff);
3133
	float3 cref2=lerp(stmp,solor2,beam_size);float creff2=pow(max(max(cref2.r,cref2.g),cref2.b),scan_falloff);
3134
	if(tds>0.5){shape1=lerp(scanline2,shape1,creff1);shape2=lerp(scanline2,shape2,creff2);}
3135
	float scanpix=OrgSize.y/NewSize.y;
3136
	float f1=frac(f-rolling_scan*float(framecount)*scanpix);
3137
	float f2=1.0-f1;
3138
	float m1=max(max(color1.r,color1.g),color1.b)+eps;
3139
	float m2=max(max(color2.r,color2.g),color2.b)+eps;
3140
	cref1=color1/m1;
3141
	cref2=color2/m2;
3142
	if(gsl< 0.5)
3143
	{w1=sw0(f1,creff1,shape1,cref1);w2=sw0(f2,creff2,shape2,cref2);}else
3144
	if(gsl==1.0)
3145
	{w1=sw1(f1,creff1,shape1,cref1);w2=sw1(f2,creff2,shape2,cref2);}else
3146
	{w1=sw2(f1,creff1,shape1,cref1);w2=sw2(f2,creff2,shape2,cref2);}
3147
	float3 w3=w1+w2;
3148
	float wf1=max(max(w3.r,w3.g),w3.b);
3149
	if(wf1>1.0){wf1=1.0/wf1;w1*=wf1,w2*=wf1;}
3150
	if(abs(clp)>0.005)
3151
	{
3152
	sy=m1; one=(clp>0.0)?w1:1.0.xxx;
3153
	float sat=1.0001-min(min(cref1.r,cref1.g),cref1.b);
3154
	color1=lerp(color1,plant(pow(color1,0.70.xxx-0.325*sat),sy),pow(sat,0.3333)*one*abs(clp));
3155
	sy=m2; one=(clp>0.0)?w2:1.0.xxx;
3156
	sat=1.0001-min(min(cref2.r,cref2.g),cref2.b);
3157
	color2=lerp(color2,plant(pow(color2,0.70.xxx-0.325*sat),sy),pow(sat,0.3333)*one*abs(clp));
3158
	}
3159
	color=gc1(color1)*w1+gc1(color2)*w2;
3160
	if (bloomsamp > 0.5) {	
3161
		float3 BloomS = texCD(JoNTSC_S13, pos).rgb;
3162
		BloomS = pow(BloomS, scangamma/gamma_in);
3163
		float cm = max(max(ctmp.r,ctmp.g),ctmp.b);
3164
		float bm = max(max(BloomS.r,BloomS.g),BloomS.b);
3165
		float bmix = clamp(max((cm-bm), (bm-cm)/(cm+0.25)-cm), 0.0, 1.0);
3166
		if (abs(clp) > 0.005)
3167
		{
3168
			sy = cm + eps; one = (clp > 0.0) ? min(w1+w2,1.0) : 1.0.xxx;
3169
			cref1 = plant(BloomS,1.0);
3170
			float sat = 1.0001-min(min(cref1.r,cref1.g),cref1.b);
3171
			BloomS = lerp(BloomS, plant(pow(BloomS, 0.70.xxx-0.325*sat),sy), pow(sat,0.3333)*one*abs(clp));
3172
		}
3173
		float3 Bloom1 = (color1*wt1 + color2*wt2)/(wt1+wt2);
3174
		BloomS = lerp(BloomS, Bloom1, min(3.0*abs(plant(sqrt(Bloom1),1.0) - plant(sqrt(BloomS),1.0)), 1.0));
3175
		bm = max(max(BloomS.r,BloomS.g),BloomS.b);
3176
		BloomS = plant(lerp(BloomS,Bloom1,bloomsamp-1.0), lerp(bm, 1.125*cm, bmix));
3177
		BloomS = gc1(BloomS)*(w1+w2);
3178
		color = min(lerp(color, BloomS, pow(cm, lerp(0.4, 0.2, pow(cm,0.375)))), max(BloomS,color));
3179
	}
3180
	color=min(color,1.0);
3181
	}
3182
	if( interb)
3183
	{
3184
	color=gc1(color1);
3185
	}
3186
	float colmx=max( max(ctmp.r,ctmp.g),ctmp.b);
3187
	if(!interb){color=pow(color,gamma_in/scangamma); colmx = pow(colmx, gamma_in/scangamma); }
3188
	return float4(color,colmx);
3189
}
3190
3191
float4 ChromaticPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
3192
{
3193
	float gamma_in=1.0/texCD(JoNTSC_S08,float2(0.25,0.25)).a;
3194
	float lum=texCD(JoNTSC_S07,float2(0.5,0.5)).a;
3195
	float intera=texCD(JoNTSC_S08,float2(0.75,0.25)).a;
3196
	bool inter6=(intera<0.35&&interm==6.0);
3197
	bool interb=(((intera<0.35&&!inter6)||(no_scanlines>0.025))&&!hiscan);
3198
	float2 lexcoord=fuxcoord.xy;
3199
	if(IOS> 0.0&& !interb)
3200
	{
3201
	float2 ofactor= NewSize.xy/OrgSize.xy;
3202
	float2 ifactor=(IOS<2.5)? floor(ofactor):ceil(ofactor);
3203
	float2 diff=ofactor/ifactor;
3204
	float scan=diff.y;
3205
	lexcoord=overscan(lexcoord,scan,scan);
3206
	if(IOS==1.0||IOS==3.0) lexcoord=float2(fuxcoord.x,lexcoord.y);
3207
	}
3208
	float factor=1.0+(1.0-0.5*OS)*blm_2/100.0-lum*blm_2/100.0;
3209
	lexcoord=overscan(lexcoord,factor,factor);
3210
	lexcoord.y=lexcoord.y - VShift*OrgSize.w;
3211
	lexcoord=overscan(lexcoord,(OrgSize.x-overscanx)/OrgSize.x,(OrgSize.y-overscany)/OrgSize.y);
3212
	float2 pos0= warp(fuxcoord);
3213
	float2 pos1= fuxcoord;
3214
	float2 pos = warp(lexcoord);
3215
	float2 posb = 2.0*(pos0-0.5);
3216
	if (blm_2 < 0.5) posb = max(abs(posb), abs(2.0*(pos-0.5)))*sign(posb);
3217
	posb = 0.5*posb + 0.5;
3218
	float3 color=texCD(JoNTSC_S14,pos1).rgb;
3219
	float3 Bloom=texCD(JoNTSC_S13,pos ).rgb;
3220
	float3 Glow =texCD(JoNTSC_S11,pos ).rgb;
3221
	if((abs(deconrx)+abs(deconry)+abs(decongx)+abs(decongy)+abs(deconbx)+abs(deconby))>0.2) bring_pixel(color,Bloom,Glow,pos1,pos);
3222
	float cm=igc(max(max(color.r,color.g),color.b));
3223
	float mx1=texCD(JoNTSC_S14,pos1   ).a;
3224
	float colmx=max(mx1,cm);
3225
	float w3=min((max((cm-0.0005)*1.0005,0.0)+0.0001)/(colmx+0.0005),1.0);if(interb)w3=1.0;
3226
	float2 dx=float2(0.001,0.0);
3227
	float mx0=texCD(JoNTSC_S14,pos1-dx).a;
3228
	float mx2=texCD(JoNTSC_S14,pos1+dx).a;
3229
	float mxg=max(max(mx0,mx1),max(mx2,cm));
3230
	float mx=pow(mxg,1.40/gamma_in);
3231
	float cx=pow(colmx,1.40/gamma_in);
3232
	dx=float2(OrgSize.z,0.0)*0.25;
3233
	mx0=texCD(JoNTSC_S14,pos1-dx).a;
3234
	mx2=texCD(JoNTSC_S14,pos1+dx).a;
3235
	float mb=(1.0-min(abs(mx0-mx2)/(0.5+mx1),1.0));
3236
	float3 orig1=color;
3237
	float3 one=1.0;
3238
	float3 cmask=one;
3239
	float3 dmask=one;
3240
	float3 emask=one;
3241
	float mwidths[15]={2.0,3.0,3.0,6.0,6.0,2.4,3.4,2.4,3.25,3.4,4.4,4.25,7.4,6.25,5.25};
3242
	float mwidth=mwidths[int(shadow_msk)];
3243
	float mask_compensate=frac(mwidth);
3244
	float mwidth0 = mwidth;
3245
	if(shadow_msk> -0.5)
3246
	{
3247
	float2 maskcoord= fracoord.xy+float2(laysh*masksize,0.0);
3248
	float2 scoord=maskcoord;
3249
	mwidth=floor(mwidth)*masksize;
3250
	float swidth=mwidth;
3251
	bool zoomed=(abs(mask_zoom)>0.75);
3252
	float mscale=1.0;
3253
	float2 maskcoord0=maskcoord;
3254
	maskcoord.y=floor(maskcoord.y/masksize);
3255
	mwidth0=max(mwidth+mask_zoom,2.0);
3256
	if( mshift> 0.25)
3257
	{
3258
	float stagg_lvl=1.0; if(frac(mshift)>0.25)stagg_lvl=2.0;
3259
	float next_line=float(floor(mod(maskcoord.y,2.0*stagg_lvl))<stagg_lvl);
3260
	maskcoord0.x=maskcoord0.x+next_line*0.5*mwidth0;
3261
	}
3262
	maskcoord=maskcoord0/masksize;
3263
	if(!zoomed)cmask=crt_mask(floor(maskcoord),mx,mb);else
3264
	{
3265
	mscale=mwidth0/mwidth;
3266
	float clerp= frac(maskcoord.x/mscale); if( zoom_mask>0.025 )clerp=clamp((1.0+zoom_mask)*clerp-0.5*zoom_mask,0.0,1.0);
3267
3268
	float coord = floor(maskcoord.x/mscale);
3269
	if (shadow_msk == 12.0 && mask_zoom == -2.0) coord = ceil(maskcoord.x/mscale);
3270
	cmask = lerp(crt_mask(float2(coord,maskcoord.y), mx, mb), crt_mask(float2(coord + 1.0, maskcoord.y), mx, mb), clerp);
3271
	}
3272
	float sm_offset=0.0;bool bsm_offset=(shadow_msk==0.0||shadow_msk==2.0||shadow_msk==5.0||shadow_msk==6.0||shadow_msk==8.0||shadow_msk==11.0);
3273
	if( zoomed)
3274
	{
3275
	if(mask_layout<0.5&&bsm_offset)sm_offset=1.0;else
3276
	if(bsm_offset)sm_offset=-1.0;
3277
	}
3278
	swidth=round(mwidth0); if (slotwidth > 0.5) swidth = slotwidth; float smask = 1.0;
3279
	smask =slt_mask(scoord+float2(sm_offset,0.0),mx,swidth);
3280
	smask =clamp(smask+lerp(smask_mit,0.0,w3*pow(colmx,0.3)),0.0,1.0);
3281
	emask =cmask;
3282
	cmask*=smask;
3283
	dmask =cmask;
3284
	if(abs(mask_bloom)>0.025)
3285
	{
3286
	float maxbl=max( max(max(Bloom.r,Bloom.g),Bloom.b),mxg);
3287
	maxbl=maxbl*max(lerp(1.0,2-colmx,bloom_dist),0.0);
3288
	if(mask_bloom>0.025) cmask= max(min(cmask +maxbl*mask_bloom,1),cmask); else
3289
	cmask=max(lerp(cmask,cmask*(1.0-0.5*maxbl)+plant(pow( Bloom,0.35.xxx),maxbl),-mask_bloom),cmask);
3290
	}
3291
	color=pow(color,mask_gamma/gamma_in);
3292
	color=color*cmask;
3293
	color=min(color,1.0);
3294
	color=pow(color,gamma_in/mask_gamma);
3295
	cmask=min(cmask,1.0);
3296
	dmask=min(dmask,1.0);
3297
	}
3298
	float dark_compensate=lerp(max(clamp(lerp(mcut,maskstr,mx),0.0,1.0)-1.0+ mask_compensate,0.0)+1.0,1.0,mx); if(shadow_msk< -0.5) dark_compensate=1.0;
3299
	float bb=lerp(brightboost1,brightboost2,mx)* dark_compensate; color*=bb;
3300
	float3 Ref=texCD(JoNTSC_S08,pos).rgb;
3301
	float maxb=texCD(JoNTSC_S13,pos).a;
3302
	float vig =texCD(JoNTSC_S02,clamp(pos,0.0+0.5*OrgSize.zw,1.0-0.5*OrgSize.zw)).a;
3303
	if(pr_scan > 0.025)
3304
	{
3305
		float mbl = max(max(Bloom.r,Bloom.g),Bloom.b);
3306
		Bloom = lerp(Bloom, lerp(Bloom, plant(orig1,mbl), min(2.5*(1.0-w3),1.0)), min(2.0*pr_scan, 1.0));
3307
	}	
3308
	float3 bcmask=lerp(one,dmask,b_mask);
3309
	float3 hcmask=lerp(one,dmask,h_mask);
3310
	float3 Bloomy=Bloom;
3311
	if(abs(blm_1)>0.025)
3312
	{
3313
	if(blm_1<-0.01)Bloomy=plant(Bloom,maxb);
3314
	Bloomy= min(Bloomy*(orig1+color),max(0.5*(colmx+orig1-color),0.001*Bloomy));
3315
	Bloomy=0.5*(Bloomy+lerp(Bloomy,lerp(colmx*orig1,Bloomy,0.5),1.0-color));
3316
	Bloomy= bcmask*Bloomy*max(lerp(1.0,2.0-colmx,bloom_dist),0);
3317
	color=pow(pow(color,mask_gamma/gamma_in)+abs(blm_1)*pow( Bloomy,mask_gamma/gamma_in),gamma_in/mask_gamma);
3318
	}
3319
	if(halation> 0.01)
3320
	{
3321
	Bloom= 0.5*(Bloom+Bloom*Bloom);float mbl=max(max(Bloom.r,Bloom.g),Bloom.b);float mxh=0.5*(colmx+colmx*colmx);
3322
	mbl=lerp(lerp(mxh,lerp( mxh,mbl,mbl),colmx),mbl,mb);
3323
	Bloom=plant(Bloom,lerp(sqrt(mbl*mxh),max((mbl-0.15*(1.0-colmx)),0.4*mxh),pow(colmx,0.25)))*lerp(0.425,1.0,colmx);
3324
	Bloom=(3.0-colmx-color)*plant(0.325+orig1/w3,0.5*(1.0+w3))*hcmask*Bloom;
3325
	color=pow(pow(color,mask_gamma/gamma_in)+ halation *pow( Bloom ,mask_gamma/gamma_in),gamma_in/mask_gamma);
3326
	}else
3327
	if(halation<-0.01)
3328
	{
3329
	float mbl=max(max(Bloom.r,Bloom.g),Bloom.b);
3330
	Bloom=plant(Bloom+Ref+orig1+Bloom*Bloom*Bloom,min(mbl*mbl,0.75));
3331
	Bloom = 2.0*lerp(1.0,w3,0.5*colmx)*hcmask*Bloom;
3332
	color = color -halation*Bloom;
3333
	}
3334
	color=min(color,1.0);
3335
	color=gc2(color,w3 );
3336
	if(smoothmask>0.125){float w4=pow(w3,0.425+0.3*smoothmask);w4=max(w4-0.175*colmx*smoothmask,0.2);color=lerp(min(color/w4,plant(orig1,1.0+0.175*colmx*smoothmask))*w4,color,w4);}
3337
	if(m_glow<0.5)Glow=lerp(Glow,0.25*color,colmx);else
3338
	{
3339
	float3 orig2=plant(orig1+0.001*Ref,1.0); maxb=max(max(Glow.r,Glow.g),Glow.b);
3340
	Bloom=plant(Glow,1.0);Ref=abs(orig2-Bloom);
3341
	mx0=max(max(orig2.r,orig2.g),orig2.b)-min(min(orig2.r,orig2.g),orig2.b);
3342
	mx2=max(max(Bloom.r,Bloom.g),Bloom.b)-min(min(Bloom.r,Bloom.g),Bloom.b);
3343
	Bloom=lerp(maxb*min(Bloom,orig2),lerp(lerp(Glow,max(max(Ref.r,Ref.g),Ref.b)*Glow,max(mx,mx0)),lerp(color,Glow,mx2),max(mx0,mx2)*Ref),min(sqrt((1.10-mx0)*(0.10+mx2)),1.0));
3344
	if(m_glow>1.5)Glow=lerp(0.5*Glow*Glow,Bloom,Bloom);
3345
	Glow=lerp(m_glow_low*Glow,m_glow_high*Bloom,pow(colmx,m_glow_dist/gamma_in));
3346
	}
3347
	if(m_glow<0.5)
3348
	{
3349
	if(glow >=0.0)color=color+0.5*Glow*glow;else color=color+abs(glow)*min(emask*emask,1.0)*Glow;}else
3350
	{
3351
	float3 fmask=clamp(lerp(one,dmask,m_glow_mask),0.0,1.0);
3352
	color=color+abs(glow)*fmask*Glow;
3353
	}
3354
	color=min(color,1.0);
3355
	if(edgemask>0.05)
3356
	{
3357
	mx0=texCD(JoNTSC_S14,pos1-dx).a;mx0=texCD(JoNTSC_S14,pos1-dx*(1.0-0.75*sqrt(mx0))).a;
3358
	mx2=texCD(JoNTSC_S14,pos1+dx).a;mx2=texCD(JoNTSC_S14,pos1+dx*(1.0-0.75*sqrt(mx2))).a;
3359
	float mx3=texCD(JoNTSC_S14,pos1-4.0*dx).a;
3360
	float mx4=texCD(JoNTSC_S14,pos1+4.0*dx).a;
3361
	mx4=max(pow(abs(mx3-mx4),0.55-0.40*cx),min(max(mx3,mx4)/min(0.1+cx,1.0),1.0));
3362
	mb=(1.0-abs(pow(mx0,1.0-0.65*mx2)-pow(mx2,1.0-0.65*mx0)));
3363
	mb=mx4*edgemask*(1.0001-mb*mb);float3 temp=lerp(color,orig1,mb);
3364
	color=max(temp+lerp(3.5*mb*lerp(1.625*temp,temp,cx),0.0.xxx,pow(color,0.75.xxx -0.5*colmx)),color);
3365
	}
3366
	color=color* lerp(1.0,lerp(0.5*(1.0+w3),w3,mx),pr_scan);
3367
	color=min(color,max(orig1,color)*lerp(one,dmask,mclip));
3368
	color=pow(color,1.0/gamma_o);
3369
	float q=0.6*sqrt(max(max(color.r,color.g),color.b))+0.4;
3370
	if(abs(addnoised)>0.01)
3371
	{
3372
	float3 noise0=noise(float3(floor(NewSize.xy*fuxcoord/noiseresd),float(framecount)));
3373
	if(noisetype<0.5)color=lerp(color,noise0,0.25*abs(addnoised)*q);else
3374
	color=min(color* lerp(1.0,1.5*noise0.x,0.5*abs(addnoised)),1.0);
3375
	}
3376
	colmx=max(max(orig1.r,orig1.g),orig1.b);
3377
	color=color+bmask*lerp(emask,0.125*(1.0-colmx)*color,min(20.0*colmx,1.0));
3378
	return lerp(float4(color*vig*humbars(lerp(pos.y, pos.x, bardir))*post_br*corner(posb), 1.0), 
3379
	            texCD(JoNTSC_S0S, (floor(pos1*OrgSize.xy)+0.5)*OrgSize.zw), step(pos1.x,oimage-0.00025));
3380
}
3381
3382
float4 RatioSizePS(float4 position : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
3383
{
3384
    const bool margins=float(texcoord.x>=coord_w&&texcoord.x<=coord_e&&texcoord.y>=coord_n&&texcoord.y<=coord_s);
3385
    const float2 boxcoord=((texcoord-correct)*OptSize.xy+0)/BoxSize;
3386
    const float4 boxcolor=texCD(JoNTSC_S15,boxcoord);
3387
    const float4 orgcolor=texCD(JoNTSC_S00,texcoord);
3388
    return lerp(orgcolor,float4(margins*boxcolor.rgb,boxcolor.a),float(margins));
3389
}
3390
3391
technique JobimaCRT_guest_advancedV8
3392
{
3393
	pass StockPass
3394
	{
3395
	VertexShader=CropProcessVS;
3396
	PixelShader=StockPassPS;
3397
	RenderTarget=JoNTSC_T0S;
3398
	PrimitiveTopology=TRIANGLESTRIP;
3399
	VertexCount=4;
3400
	}
3401
	pass Afterglow
3402
	{
3403
	VertexShader=PostProcessVS;
3404
	PixelShader=AfterglowPS;
3405
	RenderTarget=JoNTSC_T01;
3406
	}
3407
	pass PreShader
3408
	{
3409
	VertexShader=PostProcessVS;
3410
	PixelShader=PreShaderPS;
3411
	RenderTarget=JoNTSC_T02;
3412
	}
3413
	pass Interlace
3414
	{
3415
	VertexShader=PostProcessVS;
3416
	PixelShader=InterlacePS;
3417
	RenderTarget=JoNTSC_T0I;
3418
	}
3419
	pass NTSCPASS1
3420
	{
3421
	VertexShader=PostProcessVS;
3422
	PixelShader=Signal_1_PS;
3423
	RenderTarget=JoNTSC_T03;
3424
	}
3425
	pass NTSCPASS2
3426
	{
3427
	VertexShader=PostProcessVS;
3428
	PixelShader=Signal_2_PS;
3429
	RenderTarget=JoNTSC_T04;
3430
	}
3431
	pass NTSCPASS3
3432
	{
3433
	VertexShader=PostProcessVS;
3434
	PixelShader=Signal_3_PS;
3435
	RenderTarget=JoNTSC_T05;
3436
	}
3437
	pass Sharpness
3438
	{
3439
	VertexShader=PostProcessVS;
3440
	PixelShader=SharpnessPS;
3441
	RenderTarget=JoNTSC_T06;
3442
	}
3443
	pass BCAvgLum
3444
	{
3445
        VertexShader = PostProcessVS;
3446
        PixelShader  = PS_CRT_BlackCrush_AvgLum;
3447
        RenderTarget = JBCrsh_T01;
3448
	}
3449
	pass CRT_BlackCrush
3450
	{
3451
        VertexShader = PostProcessVS;
3452
        PixelShader  = PS_CRT_BlackCrush;
3453
        RenderTarget = JBCrsh_T02;
3454
	}
3455
	pass Luminance
3456
	{
3457
	VertexShader=PostProcessVS;
3458
	PixelShader=LuminancePS;
3459
	RenderTarget=JoNTSC_T07;
3460
	}
3461
	pass Linearize
3462
	{
3463
	VertexShader=PostProcessVS;
3464
	PixelShader=LinearizeNewPS;
3465
	RenderTarget=JoNTSC_T08;
3466
	}
3467
	pass CRT_Pass1
3468
	{
3469
	VertexShader=PostProcessVS;
3470
	PixelShader=NTSC_TV1_PS;
3471
	RenderTarget=JoNTSC_T09;
3472
	}
3473
	pass GaussianX
3474
	{
3475
	VertexShader=PostProcessVS;
3476
	PixelShader=HGaussianPS;
3477
	RenderTarget=JoNTSC_T10;
3478
	}
3479
	pass GaussianY
3480
	{
3481
	VertexShader=PostProcessVS;
3482
	PixelShader=VGaussianPS;
3483
	RenderTarget=JoNTSC_T11;
3484
	}
3485
	pass BloomHorz
3486
	{
3487
	VertexShader=PostProcessVS;
3488
	PixelShader=BloomHorzPS;
3489
	RenderTarget=JoNTSC_T12;
3490
	}
3491
	pass BloomVert
3492
	{
3493
	VertexShader=PostProcessVS;
3494
	PixelShader=BloomVertPS;
3495
	RenderTarget=JoNTSC_T13;
3496
	}
3497
	pass CRT_Pass2
3498
	{
3499
	VertexShader=PostProcessVS;
3500
	PixelShader=NTSC_TV2_PS;
3501
	RenderTarget=JoNTSC_T14;
3502
	}
3503
	pass Chromatic
3504
	{
3505
	VertexShader=PostProcessVS;
3506
	PixelShader=ChromaticPS;
3507
	RenderTarget=JoNTSC_T15;
3508
	}
3509
	pass RatioSize
3510
	{
3511
	VertexShader=PostProcessVS;
3512
	PixelShader=RatioSizePS;
3513
	}
3514
}