View difference between Paste ID: 8ZRvV34i and kTtt8iEJ
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 <
359+
uniform float ntsc_samp <
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";
365+
	ui_label = "Hi-Res Sampling Behaviour: Default | Old";
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 ;};
1660+
sampler JBCrsh_S01{Texture=JBCrsh_T01;AddressU=REPEAT;AddressV=REPEAT;AddressW=REPEAT;MagFilter=POINT ;MinFilter=POINT ;MipFilter=POINT ;};
1661
1662-
texture JBCrsh_T02{Width=2.0*Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
1662+
1663-
sampler JBCrsh_S02{Texture=JBCrsh_T02;AddressU=REPEAT;AddressV=REPEAT;AddressW=REPEAT;MagFilter=POINT ;MinFilter=POINT ;MipFilter=POINT ;};
1663+
1664
1665
texture JoNTSC_T08{Width=2.0*Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
1666
sampler JoNTSC_S08{Texture=JoNTSC_T08;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1667
1668
texture JoNTSC_T09{Width=1.0*AspectSize_X;Height=Resolution_Y ;Format=RGBA16F;};
1669
sampler JoNTSC_S09{Texture=JoNTSC_T09;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1670
1671
texture JoNTSC_T10{Width=1.0*800.00000000;Height=Resolution_Y ;Format=RGBA16F;};
1672
sampler JoNTSC_S10{Texture=JoNTSC_T10;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1673
1674
texture JoNTSC_T11{Width=1.0*800.00000000;Height=600.00000000 ;Format=RGBA16F;};
1675
sampler JoNTSC_S11{Texture=JoNTSC_T11;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1676
1677
texture JoNTSC_T12{Width=1.0*800.00000000;Height=600.00000000 ;Format=RGBA16F;};
1678
sampler JoNTSC_S12{Texture=JoNTSC_T12;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1679
1680
texture JoNTSC_T13{Width=1.0*800.00000000;Height=600.00000000 ;Format=RGBA16F;};
1681
sampler JoNTSC_S13{Texture=JoNTSC_T13;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1682
1683
texture JoNTSC_T14{Width=1.0*AspectSize_X;Height=AspectSize_Y ;Format=RGBA16F;};
1684
sampler JoNTSC_S14{Texture=JoNTSC_T14;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1685
1686
texture JoNTSC_T15{Width=1.0*AspectSize_X;Height=AspectSize_Y ;Format=RGBA16F;};
1687
sampler JoNTSC_S15{Texture=JoNTSC_T15;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
1688
1689
texture JoNTSC_001<source="CRT-LUT-1.png";>{Width=1024;Height=32;};
1690
sampler JoNTSC_L01{Texture=JoNTSC_001;};
1691
1692
texture JoNTSC_002<source="CRT-LUT-2.png";>{Width=1024;Height=32;};
1693
sampler JoNTSC_L02{Texture=JoNTSC_002;};
1694
1695
texture JoNTSC_003<source="CRT-LUT-3.png";>{Width=1024;Height=32;};
1696
sampler JoNTSC_L03{Texture=JoNTSC_003;};
1697
1698
texture JoNTSC_004<source="CRT-LUT-4.png";>{Width=1024;Height=32;};
1699
sampler JoNTSC_L04{Texture=JoNTSC_004;};
1700
1701
uniform int framecount<source="framecount";>;
1702
1703
float3 fix_lut(float3 lut,float3 ref)
1704
{
1705
	float r=length(ref);
1706
	float l=length(lut);
1707
	float m=max(max(ref.r,ref.g),ref.b);
1708
	ref=normalize(lut+0.0000001)*lerp(r,l,pow(m,1.25));
1709
	return lerp(lut,ref,LUTBR);
1710
}
1711
1712
float vignette(float2 pos)
1713
{
1714
	float b = vigdef * 0.125;
1715
	pos = abs(2.0*(pos - 0.5)); pos*=pos*pos;
1716
	float dist = pow(dot(pos,pos),0.05);
1717
	float res = lerp(0.0, 1.0, smoothstep(1.0, 1.0-b, dist));
1718
	return max(lerp(1.0, res, vigstr), 0.0);
1719
}
1720
1721
float contrast(float x)
1722
{
1723
	return max(lerp(x,smoothstep(0,1.0,x),contra),0.0);
1724
}
1725
1726
float3 pgc(float3 c)
1727
{
1728
	float mc = max(max(c.r,c.g),c.b);
1729
	float mg = pow(mc, 1.0/pre_gc);
1730
	return c * mg/(mc + 1e-8);  
1731
}
1732
1733
float contrast_sigmoid_inv(float imgColor, float cont, float pivot)
1734
{
1735
	cont = cont - 1.0; cont = cont*cont*cont;
1736
	float knee  = 1.0 / (1.0 + exp (cont *  pivot));
1737
	float shldr = 1.0 / (1.0 + exp (cont * (pivot - 1.0)));
1738
	imgColor = pivot - log(1.0 / (imgColor * (shldr - knee) + knee) - 1.0) / cont;
1739
	return imgColor;
1740
}
1741
1742
float dist(float3 A,float3 B)
1743
{
1744
	float r=0.5*(A.r+B.r);
1745
	float3 d=A-B;
1746
	float3 c=float3(2.+r,4.,3.-r);
1747
	return sqrt(dot(c*d,d))/3.;
1748
}
1749
1750
float3 plant(float3 tar,float r)
1751
{
1752
	float t=max(max(tar.r,tar.g),tar.b)+0.00001;
1753
	return tar*r/t;
1754
}
1755
1756
float3 fetch_pixel(float2 coord)
1757
{
1758
	float2 dx=float2(LumSize.z,0.0)*downsample_levelx;
1759
	float2 dy=float2(0.0,LumSize.w)*downsample_levely;
1760
	float2 d1=dx+dy;
1761
	float2 d2=dx-dy;
1762
	float sum=15.0;
1763
	float3 result=
1764
	3.0*texCD(JBCrsh_S01,coord   ).rgb+2.0*texCD(JBCrsh_S01,coord+dx).rgb+2.0*texCD(JBCrsh_S01,coord-dx).rgb+
1765
	2.0*texCD(JBCrsh_S01,coord+dy).rgb+2.0*texCD(JBCrsh_S01,coord-dy).rgb+    texCD(JBCrsh_S01,coord+d1).rgb+
1766
		texCD(JBCrsh_S01,coord-d1).rgb+    texCD(JBCrsh_S01,coord+d2).rgb+    texCD(JBCrsh_S01,coord-d2).rgb;
1767-
	3.0*texCD(JBCrsh_S02,coord   ).rgb+2.0*texCD(JBCrsh_S02,coord+dx).rgb+2.0*texCD(JBCrsh_S02,coord-dx).rgb+
1767+
1768-
	2.0*texCD(JBCrsh_S02,coord+dy).rgb+2.0*texCD(JBCrsh_S02,coord-dy).rgb+    texCD(JBCrsh_S02,coord+d1).rgb+
1768+
1769-
		texCD(JBCrsh_S02,coord-d1).rgb+    texCD(JBCrsh_S02,coord+d2).rgb+    texCD(JBCrsh_S02,coord-d2).rgb;
1769+
1770
float gauss_h(float x)
1771
{
1772
	float sigma=1.0/(2.0*SIGMA_H*SIGMA_H);
1773
	return exp(-x*x*sigma);
1774
}
1775
1776
float gauss_v(float x)
1777
{
1778
	float sigma=1.0/(2.0*SIGMA_V*SIGMA_V);
1779
	return exp(-x*x*sigma);
1780
}
1781
1782
float bloom_h(float x)
1783
{
1784
	float SIGMA_X2 = SIGMA_X * SIZEX / 3.0;
1785
	float sigma=1.0/(2.0*SIGMA_X2*SIGMA_X2);
1786
	return exp(-x*x*sigma);
1787
}
1788
1789
float bloom_v(float x)
1790
{
1791
	float SIGMA_Y2 = SIGMA_Y * SIZEY / 3.0;
1792
	float sigma=1.0/(2.0*SIGMA_Y2*SIGMA_Y2);
1793
	return exp(-x*x*sigma);
1794
}
1795
1796
float crthd_h(float x,float y)
1797
{
1798
	return exp(-x*x*y);
1799
}
1800
1801
float mod(float x,float y)
1802
{
1803
	return x-y* floor(x/y);
1804
}
1805
1806
float st0(float x)
1807
{
1808
	return exp2(wts*x*x);
1809
}
1810
1811
float3 sw0(float x,float color,float scanline,float3 c)
1812
{
1813
	float3 xe=lerp(1.0.xxx+scans,1.0.xxx,c);
1814
	float tmp=lerp(beam_min,beam_max,color);
1815
	float ex=x*tmp;
1816
	ex=(gsl>-0.5)?ex*ex:lerp(ex*ex,ex*ex*ex,0.4);
1817
	return exp2(-scanline*ex*xe);
1818
}
1819
1820
float3 sw1(float x,float color,float scanline,float3 c)
1821
{
1822
	float3 xe=lerp(1.0.xxx+scans,1.0.xxx,c);
1823
	x=lerp(x,beam_min*x,max(x-0.4*color,0.0));
1824
	float tmp=lerp(1.2*beam_min,beam_max,color);
1825
	float ex=x*tmp;
1826
	return exp2(-scanline*ex*ex*xe);
1827
}
1828
1829
float3 sw2(float x,float color,float scanline,float3 c)
1830
{
1831
	float3 xe=lerp(1.0.xxx+scans,1.0.xxx,c);
1832
	float tmp=lerp((2.5-0.5*color)*beam_min,beam_max,color);
1833
	tmp=lerp(beam_max,tmp,pow(x,color+0.3));
1834
	float ex=x*tmp;
1835
	return exp2(-scanline*ex*ex*xe);
1836
}
1837
1838
float2 overscan(float2 pos,float dx,float dy)
1839
{
1840
	pos=pos*2.0-1.0;
1841
	pos*=float2(dx,dy);
1842
	return pos*0.5+0.5;
1843
}
1844
1845
float2 warp(float2 pos)
1846
{
1847
	pos=pos*2.0-1.0;
1848
	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));
1849
	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);
1850
	return pos*0.5+0.5;
1851
}
1852
1853
float3 gc1(float3 c)
1854
{
1855
	float mc=max(max(c.r,c.g),c.b);
1856
	float mg=pow(mc,1.0/gamma_c);
1857
	return c*mg/(mc+eps);
1858
}
1859
1860
float3 rgb2yiq(float3 r)
1861
{
1862
	return mul(rgb_m, r);
1863
}
1864
1865
float3 yiq2rgb(float3 y)
1866
{
1867
	return mul(yiq_m, y);
1868
}
1869
1870
float get_luma(float3 c)
1871
{
1872
	return dot(c,float3(0.2989, 0.5870, 0.1140));
1873
}
1874
1875
float swoothstep(float e0,float e1,float x)
1876
{
1877
	return clamp((x-e0)/(e1-e0),0.0,1.0);
1878
}
1879
1880
float3 crt_mask(float2 pos,float mx,float mb)
1881
{
1882
	float3 mask=mask_drk;
1883
	float3 one=1.0;
1884
	if(shadow_msk== 0.0)
1885
	{
1886
	float mc=1.0-max(maskstr,0.0);
1887
	pos.x=frac(pos.x*0.5);
1888
	if(pos.x<0.49)
1889
	{
1890
	mask.r=1.0;mask.g= mc;mask.b=1.0;
1891
	}else
1892
	{
1893
	mask.r= mc;mask.g=1.0;mask.b= mc;
1894
	}
1895
	}else
1896
	if(shadow_msk== 1.0)
1897
	{
1898
	float lane=mask_lgt;
1899
	float odd=0.0;
1900
	if(frac(pos.x/6.0)<0.49)odd=1.0;
1901
	if(frac((pos.y+odd)/2.0)<0.49)lane=mask_drk;
1902
	pos.x=floor(mod(pos.x,3.0));
1903
	if(pos.x<0.5)mask.r=mask_lgt;else
1904
	if(pos.x<1.5)mask.g=mask_lgt;else
1905
	mask.b= mask_lgt;
1906
	mask*=lane;
1907
	}else
1908
	if(shadow_msk== 2.0)
1909
	{
1910
	pos.x=floor(mod(pos.x,3.0));
1911
	if(pos.x<0.5)mask.r=mask_lgt;else
1912
	if(pos.x<1.5)mask.g=mask_lgt;else
1913
	mask.b= mask_lgt;
1914
	}else
1915
	if(shadow_msk== 3.0)
1916
	{
1917
	pos.x+=pos.y*3.0;
1918
	pos.x=frac(pos.x/6.0);
1919
	if(pos.x<0.3)mask.r=mask_lgt;else
1920
	if(pos.x<0.6)mask.g=mask_lgt;else
1921
	mask.b= mask_lgt;
1922
	}else
1923
	if(shadow_msk== 4.0)
1924
	{
1925
	pos.xy=floor(pos.xy*float2(1.0,0.5));
1926
	pos.x+=pos.y*3.0;
1927
	pos.x=frac(pos.x/6.0);
1928
	if(pos.x<0.3)mask.r=mask_lgt;else
1929
	if(pos.x<0.6)mask.g=mask_lgt;else
1930
	mask.b= mask_lgt;
1931
	}else
1932
	if(shadow_msk== 5.0)
1933
	{
1934
	mask=0.0;
1935
	pos.x=frac(pos.x/2.0);
1936
	if(pos.x<0.49)
1937
	{
1938
	mask.r=1.0;
1939
	mask.b=1.0;
1940
	}else
1941
	mask.g=1.0;
1942
	mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
1943
	}else
1944
	if(shadow_msk== 6.0)
1945
	{
1946
	mask=0.0;
1947
	pos.x=floor(mod(pos.x,3.0));
1948
	if(pos.x<0.5)mask.r=1.0;else
1949
	if(pos.x<1.5)mask.g=1.0;else
1950
	mask.b=1.0;
1951
	mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
1952
	}else
1953
	if(shadow_msk== 7.0)
1954
	{
1955
	mask=0.0;
1956
	pos.x=frac(pos.x/2.0);
1957
	if(pos.x<0.49)
1958
	{
1959
	mask=0.0.xxx;
1960
	}else
1961
	mask=1.0.xxx;
1962
	mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
1963
	}else
1964
	if(shadow_msk== 8.0)
1965
	{
1966
	mask=0.0;
1967
	pos.x=frac(pos.x/3.0);
1968
	if(pos.x<0.3)mask=0.0.xxx;else
1969
	if(pos.x<0.6)mask=1.0.xxx;else
1970
	mask=1.0.xxx;
1971
	mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
1972
	}else
1973
	if(shadow_msk== 9.0)
1974
	{
1975
	mask=0.0;
1976
	pos.x=frac(pos.x/3.0);
1977
	if(pos.x<0.3)mask   =0.0.xxx;else
1978
	if(pos.x<0.6)mask.rb=1.0.xx ;else
1979
	mask.g=1.0;
1980
	mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
1981
	}else
1982
	if(shadow_msk==10.0)
1983
	{
1984
	mask=0.0;
1985
	pos.x=frac(pos.x*0.25);
1986
	if(pos.x<0.2)mask  =0.0.xxx;else
1987
	if(pos.x<0.4)mask.r=1.0    ;else
1988
	if(pos.x<0.7)mask.g=1.0    ;else
1989
	mask.b=1.0;
1990
	mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
1991
	}else
1992
	if(shadow_msk==11.0)
1993
	{
1994
	mask=0.0;
1995
	pos.x=frac(pos.x*0.25);
1996
	if(pos.x<0.2)mask.r =1.0   ;else
1997
	if(pos.x<0.4)mask.rg=1.0.xx;else
1998
	if(pos.x<0.7)mask.gb=1.0.xx;else
1999
	mask.b=1.0;mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
2000
	}else
2001
	if(shadow_msk==12.0)
2002
	{
2003
	mask=0.0;
2004
	pos.x=floor(mod(pos.x,7.0));
2005
	if(pos.x<0.5)mask  =0.0.xxx;else
2006
	if(pos.x<2.5)mask.r=1.0    ;else
2007
	if(pos.x<4.5)mask.g=1.0    ;else
2008
	mask.b=1.0;
2009
	mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
2010
	}else
2011
	if(shadow_msk==13.0)
2012
	{
2013
	mask=0.0;
2014
	pos.x=floor(mod(pos.x,6.0));
2015
	if(pos.x<0.5)mask    =0.0.xxx;else
2016
	if(pos.x<1.5)mask.r  =1.0    ;else
2017
	if(pos.x<2.5)mask.rg =1.0.xx ;else
2018
	if(pos.x<3.5)mask.rgb=1.0.xxx;else
2019
	if(pos.x<4.5)mask.gb =1.0.xx ;else
2020
	mask.b=1.0;
2021
	mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
2022
	}else
2023
	{
2024
	mask=0.0;
2025
	pos.x=floor(mod(pos.x,5.0));
2026
	if(pos.x<0.5)mask    =0.0.xxx;else
2027
	if(pos.x<1.5)mask.r  =1.0    ;else
2028
	if(pos.x<2.5)mask.rg =1.0.xx ;else
2029
	if(pos.x<3.5)mask.gb =1.0.xx ;else
2030
	mask.b=1.0;
2031
	mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
2032
	}
2033
	if(mask_layout>0.5)mask=mask.rbg;
2034
	float maskmin=min(min(mask.r,mask.g),mask.b);
2035
	return (mask-maskmin)*(1.0+(maskboost-1.0)*mb)+maskmin;
2036
}
2037
2038
float slt_mask(float2 pos,float m,float swidth)
2039
{
2040
	if  ((slotmask1+slotmask2)==0.0)return 1.0;else
2041
	{
2042
	pos.y=floor(pos.y/slotms);
2043
	float mlen=swidth*2.0;
2044
	float px=floor( mod(pos.x, 0.99999*mlen));
2045
	float py=floor(frac(pos.y/(2.0*double_slot))*2.0*double_slot);
2046
	float slot_dark=lerp(1.0-slotmask2,1.0-slotmask1,m);
2047
	float slot=1.0;
2048
	if(py==0.0&&px<swidth) slot=slot_dark;else
2049
	if(py==double_slot&&px>=swidth) slot=slot_dark;
2050
	return slot;
2051
	}
2052
}
2053
2054
float humbars(float pos)
2055
{
2056
	if  (barintensity==0.0)return 1.0;else
2057
	{
2058
	pos=(barintensity>=0.0)?pos:(1.0-pos);
2059
	pos=frac(pos+ mod(float(framecount),barspeed)/(barspeed-1.0));
2060
	pos=(barintensity< 0.0)?pos:(1.0-pos);
2061
	return (1.0-barintensity)+barintensity*pos;
2062
	}
2063
}
2064
2065
float corner(float2 pos)
2066
{
2067
	pos=abs(2.0*(pos-0.50));
2068
	float2 aspect=float2(1.0,NewSize.x/NewSize.y);
2069
	float b=bsize*0.05+0.0005;pos.y=pos.y+b*(aspect.y-1.0);
2070
	float2 crn=max(csize.xx,2.0*b+0.0015);
2071
	float2 crp=max(pos-(1.0-crn*aspect),0.0)/aspect;float cd=sqrt(dot(crp,crp));
2072
	pos=max(pos,1.0-crn+cd);
2073
	float res=lerp(1.0,0.0,smoothstep(1.0-b,1.0,sqrt(max(pos.x,pos.y))));
2074
	return pow(res,sborder);
2075
}
2076
2077
float3 declip(float3 c,float b)
2078
{
2079
	float m=max(max(c.r,c.g),c.b);
2080
	if(m>b)c=c*b/m;
2081
	return c;
2082
}
2083
2084
float igc(float mc)
2085
{
2086
	return pow(mc,gamma_c);
2087
}
2088
2089
float3 gc2(float3 c,float w3)
2090
{
2091
	float mc=max(max(c.r,c.g),c.b);
2092
	float p=1.0/(1.0+(gamma_d-1.0)* lerp(0.375,1.0,w3));
2093
	float mg=pow(mc, p );
2094
	return c*mg/(mc+eps);
2095
}
2096
2097
float3 noise(float3 v)
2098
{
2099
	if(addnoised<0.0)v.z=-addnoised;else v.z= mod(v.z,6001.0)/1753.0;
2100
	v =frac(v)+frac(v*1e4)+frac(v*1e-4);
2101
	v+=float3(0.12345,0.6789,0.314159);
2102
	v =frac(v*dot(v,v)*123.456);
2103
	v =frac(v*dot(v,v)*123.456);
2104
	v =frac(v*dot(v,v)*123.456);
2105
	v =frac(v*dot(v,v)*123.456);
2106
	return v;
2107
}
2108
2109
float smothstep (float e0, float e1, float x)
2110
{
2111
   return clamp((x - e0) / (e1 - e0), 0.0, 1.0);
2112
}
2113
2114
float2 psrnd(float2 TexCoord, float FrameCount) {
2115
    float3 p = float3(TexCoord * 16758.5453, FrameCount);
2116
    float x = frac(sin(dot(p, float3(12.9898, 78.233, 3.183))) * 43758.5453);
2117
    float y = frac(sin(dot(p, float3(25.9796, 14.113, 11.271))) * 96321.9124);
2118
    return float2(x, y);
2119
}
2120
2121
float3 NoiseNP3(float2 TexCoord, float FrameCount) {
2122
float RFNOISE0 = RFNOISE*RFNOISE + 0.00001;
2123
    TexCoord = psrnd(TexCoord, FrameCount);
2124
    float3 p = float3(TexCoord * 758.5453, FrameCount);
2125
    float res1 = frac(sin(dot(p, float3(12.989835, 78.23341, 0.16453))) * 43758.54531);
2126
    float res2 = frac(sin(dot(p, float3(39.34679, 11.13523, 83.15573))) * 39459.32423);
2127
    float res3 = frac(sin(dot(p, float3(73.15691, 52.23504, 9.15197))) * 60493.84731);
2128
    float lns = float(abs(res1-0.5) < 0.2*RFNOISE0);
2129
    float cny = float(abs(res2-0.5) < 0.5*RFNOISE0);
2130
    float cnz = float(abs(res3-0.5) < 0.5*RFNOISE0);
2131
    lns = lns*smothstep(0.5-0.2*RFNOISE0, 0.5+0.2*RFNOISE0, res1) * 0.66 - 0.33*lns;
2132
    cny = cny*smothstep(0.5-0.5*RFNOISE0, 0.5+0.5*RFNOISE0, res2)  - 0.5*cny;
2133
    cnz = cnz*smothstep(0.5-0.5*RFNOISE0, 0.5+0.5*RFNOISE0, res3)  - 0.5*cnz;	
2134
    return float3(lns, cny, cnz);
2135
}
2136
2137
void bring_pixel(inout float3 c,inout float3 b,inout float3 g,float2 coord,float2 boord)
2138
{
2139
	float stepx=NewSize.z;
2140
	float stepy=NewSize.w;
2141
	float2 dx=float2(stepx,0.0);
2142
	float2 dy=float2(0.0,stepy);
2143
	float posx= 2.0*coord.x-1.0;
2144
	float posy= 2.0*coord.y-1.0;
2145
	if(dctypex>0.025)
2146
	{
2147
	posx= sign(posx)*pow(abs(posx),1.05-dctypex);
2148
	dx=posx*dx;
2149
	}
2150
	if(dctypey>0.025)
2151
	{
2152
	posy= sign(posy)*pow(abs(posy),1.05-dctypey);
2153
	dy=posy*dy;
2154
	}
2155
	float2 rc=deconrx*dx+deconry*dy;
2156
	float2 gc=decongx*dx+decongy*dy;
2157
	float2 bc=deconbx*dx+deconby*dy;
2158
	float r1=texCD(JoNTSC_S14,coord+rc).r;
2159
	float g1=texCD(JoNTSC_S14,coord+gc).g;
2160
	float b1=texCD(JoNTSC_S14,coord+bc).b;
2161
	float ds=decons;
2162
	float3 d=float3(r1,g1,b1);
2163
	c=clamp(lerp(c,d,ds),0.0,1.0);
2164
	r1=texCD(JoNTSC_S13,boord+rc).r;
2165
	g1=texCD(JoNTSC_S13,boord+gc).g;
2166
	b1=texCD(JoNTSC_S13,boord+bc).b;
2167
	d=float3(r1,g1,b1);
2168
	b=g=lerp(b,d,min(ds,1.0));
2169
	r1=texCD(JoNTSC_S11,boord+rc).r;
2170
	g1=texCD(JoNTSC_S11,boord+gc).g;
2171
	b1=texCD(JoNTSC_S11,boord+bc).b;
2172
	d=float3(r1,g1,b1);
2173
	g=lerp(g,d,min(ds,1.0));
2174
}
2175
2176
float3 scale_to_range(float3 x, float dmin, float dmax)
2177
{
2178
    return ( (dmax - dmin) * x ) + dmin; //Scales 0..1 range to a..b range
2179
}
2180
2181
2182
float3 adaptive_black(float3 c, float lum_in, float range, bool dark_crush)
2183
{
2184
    if (dark_crush)
2185
    {
2186
        // Black crush
2187
        return clamp(scale_to_range(c, -lum_in * range,1.0), 0.0,1.0);
2188
    }
2189
    else
2190
    {
2191
        // Increase gamma
2192
        float ga = 1.0 + lum_in * 2.0 * range;
2193
        return pow(c, float3(ga,ga,ga));
2194
    }
2195
}
2196
2197
float get_fps()
2198
{
2199
    // Direct port (frametime uniforms not available)
2200
    return OriginalFPS;
2201
}
2202
2203
static const float2 expanse=BoxSize/ (2*OptSize.xy);
2204
static const float2 capital=0.0/OptSize.xy+0.5;
2205
static const float coord_w=capital.x-expanse.x;
2206
static const float coord_e=capital.x+expanse.x;
2207
static const float coord_n=capital.y-expanse.y;
2208
static const float coord_s=capital.y+expanse.y;
2209
static const float2 correct=float2(coord_w,coord_n);
2210
2211
void CropProcessVS(in uint id:SV_VertexID,out float4 position:SV_Position,out float2 texcoord:TEXCOORD)
2212
{
2213
	#if __RENDERER__ <= 0x09300
2214
	texcoord.x=(id==1||id==3)?coord_e:coord_w;
2215
	texcoord.y=(id>1)?coord_s:coord_n;
2216
	position.x=(id==1||id==3)? 1:-1;
2217
	position.y=(id>1)?-1: 1;
2218
	position.zw=1;
2219
	#else
2220
	texcoord.x=(id&1)?coord_e:coord_w;
2221
	texcoord.y=(id&2)?coord_s:coord_n;
2222
	position.x=(id&1)? 1:-1;
2223
	position.y=(id&2)?-1: 1;
2224
	position.zw=1;
2225
	#endif
2226
}
2227
2228
float4 StockPassPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2229
{
2230
	return texCD(JoNTSC_S00,texcoord);
2231
}
2232
2233
float4 AfterglowPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2234
{
2235
	float2 dx=float2(OrgSize.z,0.0);
2236
	float2 dy=float2(0.0,OrgSize.w);
2237
	float w=1.0;
2238
	float3 color0=texCD(JoNTSC_S0S,texcoord   ).rgb;
2239
	float3 color1=texCD(JoNTSC_S0S,texcoord-dx).rgb;
2240
	float3 color2=texCD(JoNTSC_S0S,texcoord+dx).rgb;
2241
	float3 color3=texCD(JoNTSC_S0S,texcoord-dy).rgb;
2242
	float3 color4=texCD(JoNTSC_S0S,texcoord+dy).rgb;
2243
	float3 cr=(2.5*color0+color1+color2+color3+color4)/6.5;
2244
	float3 a=texCD(JoNTSC_S01,texcoord).rgb;
2245
	float b = bth/255.0;
2246
	float c = max(max(color0.r,color0.g),color0.b);
2247
	w = smoothstep(b, 2.0*b, c);
2248
	float3 result=lerp(max(lerp(cr,a,0.49+float3(PR,PG,PB))-0.5/255.0,0.0),cr,w);
2249
	return float4(result,w);
2250
}
2251
2252
float4 PreShaderPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2253
{
2254
	const float3x3 File0=float3x3(0.412391, 0.212639,0.019331, 0.357584,0.715169, 0.119195, 0.180481,0.072192,0.950532);
2255
	const float3x3 File1=float3x3(0.430554, 0.222004,0.020182, 0.341550,0.706655, 0.129553, 0.178352,0.071341,0.939322);
2256
	const float3x3 File2=float3x3(0.396686, 0.210299,0.006131, 0.372504,0.713766, 0.115356, 0.181266,0.075936,0.967571);
2257
	const float3x3 File3=float3x3(0.393521, 0.212376,0.018739, 0.365258,0.701060, 0.111934, 0.191677,0.086564,0.958385);
2258
	const float3x3 File4=float3x3(0.392258, 0.209410,0.016061, 0.351135,0.725680, 0.093636, 0.166603,0.064910,0.850324);
2259
	const float3x3 File5=float3x3(0.377923, 0.195679,0.010514, 0.317366,0.722319, 0.097826, 0.207738,0.082002,1.076960);
2260
	const float3x3 ToRGB=float3x3(3.240970,-0.969244,0.055630,-1.537383,1.875968,-0.203977,-0.498611,0.041555,1.056972);
2261
	const float3x3 ToMDN=float3x3(2.791723,-0.894766,0.041678,-1.173165,1.815586,-0.130886,-0.440973,0.032000,1.002034);
2262
	const float3x3 ToDCI=float3x3(2.973422,-0.867605,0.045031,-1.110433,1.843757,-0.095697,-0.480247,0.024743,1.201215);
2263
	const float3x3 ToADB=float3x3(2.041588,-0.969244,0.013444,-0.565007,1.875968,-0.118360,-0.344731,0.041555,1.015175);
2264
	const float3x3 ToREC=float3x3(1.716651,-0.666684,0.017640,-0.355671,1.616481,-0.042771,-0.253366,0.015769,0.942103);
2265
	const float3x3 ToP3=float3x3(2.493509,-0.829473,0.0358512,-0.931388,1.762630,-0.0761839,-0.402712,0.023624,0.9570296);
2266
	const float3x3 D65_to_D55=float3x3(0.4850339153,0.2500956126,0.0227359648,0.3488957224,0.6977914447,0.1162985741,0.1302823568,0.0521129427,0.6861537456);
2267
	const float3x3 D65_to_D93=float3x3(0.3412754080,0.1759701322,0.0159972847,0.3646170520,0.7292341040,0.1215390173,0.2369894093,0.0947957637,1.2481442225);
2268
	float4 imgColor=texCD(JoNTSC_S0S,texcoord);
2269
	float4 aftrglow=texCD(JoNTSC_S01,texcoord);
2270
	float w=1.0-aftrglow.w;
2271
	float l=length(aftrglow.rgb);
2272
	aftrglow.rgb=AS*w*normalize(pow(aftrglow.rgb+0.01,ST))*l;
2273
	float bp=w*BP1/255.0;
2274
	if(sega_fix>0.5) imgColor.rgb=imgColor.rgb*(255.0/239.0);
2275
	if(segams>0.5) { imgColor.b=(abs(imgColor.b - 0.375) < 0.125) ? 0.4078431372549019607843137254902 : imgColor.b; }
2276
	imgColor.rgb=min(imgColor.rgb,1.0);
2277
	if (segapal > 0.5) {
2278
	imgColor.r = contrast_sigmoid_inv(imgColor.r,2.578419881,0.520674); 
2279
	imgColor.g = contrast_sigmoid_inv(imgColor.g,2.578419881,0.520674); 
2280
	imgColor.b = contrast_sigmoid_inv(imgColor.b,2.578419881,0.520674); }
2281
   
2282
	imgColor.rgb = min(imgColor.rgb, 1.0);
2283
	float3 color=imgColor.rgb;
2284
	if(int(TNTC)==0) {color.rgb=imgColor.rgb;}else
2285
	{
2286
	float lutlow=LUTLOW/255.0;float invs=1.0/LS;
2287
	float3 lut_ref=imgColor.rgb+lutlow*(1.0-pow(imgColor.rgb,0.333.xxx));
2288
	float lutb=lut_ref.b*(1.0-0.5*invs);
2289
	lut_ref.rg=lut_ref.rg*(1.0-invs)+0.5*invs;
2290
	float tile1=ceil(lutb*(LS-1.0));
2291
	float tile0=max(tile1-1.0,0.0);
2292
	float f=frac(lutb*(LS-1.0));if(f==0.0)f=1.0;
2293
	float2 coord1=float2(tile0+lut_ref.r,lut_ref.g)*float2(invs,1.0);
2294
	float2 coord2=float2(tile1+lut_ref.r,lut_ref.g)*float2(invs,1.0);
2295
	float4 color1,color2,res;
2296
	if(int(TNTC)==1)
2297
	{
2298
	color1=texCD(JoNTSC_L01,coord1);
2299
	color2=texCD(JoNTSC_L01,coord2);
2300
	res=lerp(color1,color2,f);
2301
	}else
2302
	if(int(TNTC)==2)
2303
	{
2304
	color1=texCD(JoNTSC_L02,coord1);
2305
	color2=texCD(JoNTSC_L02,coord2);
2306
	res=lerp(color1,color2,f);
2307
	}else
2308
	if(int(TNTC)==3)
2309
	{
2310
	color1=texCD(JoNTSC_L03,coord1);
2311
	color2=texCD(JoNTSC_L03,coord2);
2312
	res=lerp(color1,color2,f);
2313
	}else
2314
	if(int(TNTC)==4)
2315
	{
2316
	color1=texCD(JoNTSC_L04,coord1);
2317
	color2=texCD(JoNTSC_L04,coord2);
2318
	res=lerp(color1,color2,f);
2319
	}
2320
	res.rgb=fix_lut(res.rgb,imgColor.rgb);
2321
	color=lerp(imgColor.rgb,res.rgb,min(TNTC,1.0));
2322
	}
2323
	float3 c=clamp(color,0.0,1.0);
2324
	float3x3 m_o;
2325
	float p;
2326
	if(CS==0.0){p=2.2;m_o=ToRGB;}else
2327
	if(CS==1.0){p=2.2;m_o=ToMDN;}else
2328
	if(CS==2.0){p=2.6;m_o=ToDCI;}else
2329
	if(CS==3.0){p=2.2;m_o=ToADB;}else
2330
	if(CS==4.0){p=2.4;m_o=ToREC;}
2331
	if(CS==5.0){p=2.2;m_o=ToP3; }
2332
	color=pow(c,p);
2333
	float3x3 m_i;
2334
	if(CP==0.0){m_i=File0;}else
2335
	if(CP==1.0){m_i=File1;}else
2336
	if(CP==2.0){m_i=File2;}else
2337
	if(CP==3.0){m_i=File3;}else
2338
	if(CP==4.0){m_i=File4;}else
2339
	if(CP==5.0){m_i=File5;}
2340
	color=mul(color,m_i);
2341
	color=mul(color,m_o);
2342
	color=clamp(color,0.0,1.0);
2343
	color=pow(color,1.0/p);
2344
	if(CP==-1.0)color=c;
2345
	float3 solor1=plant(pow(color,wp_saturation),max(max(color.r,color.g),color.b));
2346
	float luma=dot(color,float3(0.299,0.587,0.114));
2347
	float3 solor2=lerp(luma,color,wp_saturation);
2348
	color=(wp_saturation>1.0)?solor1:solor2;
2349
	color=plant(color,contrast(max(max(color.r,color.g),color.b)));
2350
	p=2.2;
2351
	color=clamp(color,0.0,1.0);
2352
	color=pow(color,p);
2353
	float3 warmer=mul(color,D65_to_D55);
2354
	warmer=mul(warmer,ToRGB);
2355
	float3 cooler=mul(color,D65_to_D93);
2356
	cooler=mul(cooler,ToRGB);
2357
	float m=abs(WP)/100.0;
2358
	float3 comp=(WP<0.0)?cooler:warmer;
2359
	color=lerp(color,comp,m);
2360
	color=pow(max(color,0.0),1.0/p);
2361
	color=pgc(color);
2362
	float bp1 = min(BP, 0.0);
2363
	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)));
2364
	color = color + aftrglow.rgb + bp;
2365
	color=min(color*pre_bb,1.0);
2366
	return float4(color,vignette(texcoord));
2367
}
2368
2369
float4 InterlacePS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2370
{
2371
    float3 c1=texCD(JoNTSC_S02,fuxcoord).rgb;
2372
    float3 c2=texCD(JoNTSC_S02,fuxcoord+float2(0.0,OrgSize.w)).rgb;
2373
    float3 c=c1;
2374
    float intera=1.0;
2375
    float m1=max(max(c1.r,c1.g),c1.b);
2376
    float m2=max(max(c2.r,c2.g),c2.b);
2377
    float3 df=abs(c1-c2);
2378
    float d=max(max(df.r,df.g),df.b);
2379
    if(interm==2.0) d=lerp(0.1*d,10.0*d,step(m1/(m2+0.0001),m2/(m1+0.0001)));
2380
    float r=m1;
2381
    float yres_div=1.0;if(intres>1.25)yres_div=intres;
2382
    bool hscans=(hiscan>0.5);
2383
    if(interr<=OrgSize.y/yres_div&&interm>0.5&&intres!=1.0&&intres!=0.5||hscans)
2384
    {
2385
    intera=0.25;
2386
    float liine_no=floor( mod(OrgSize.y*fuxcoord.y,2.0));
2387
    float frame_no=floor( mod(float(framecount),2.0));
2388
    float ii=abs(liine_no-frame_no);
2389
    if(interm< 3.5 || interm > 5.5)
2390
    {
2391
    if (interm == 6.0) c = lerp(c2, c1, ii); else
2392
    {
2393
    c2=plant(lerp(c2,c2*c2,iscans),max(max(c2.r,c2.g),c2.b));
2394
    r=max(m1*ii,(1.0-iscanb)*min(m1,m2));
2395
    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);
2396
    if(interm==3.0) c=(1.0-0.5*iscanb)*lerp(c2,c1,ii);
2397
    }
2398
    }
2399
    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);
2400
    }
2401
    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);
2402
    }
2403
    if(hscans)c=c1;
2404
    }
2405
    return float4(c,intera);
2406
}
2407
2408
float4 Signal_1_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2409
{
2410
	float2 vtexcoord=texcoord*float2(speedup, 1.0);
2411
	float NOrgSize = (OrgSize.x < 400.0) ? OrgSize.x : OrgSize.x / max(round(OrgSize.x / 300.0), 1.0);
2412
	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);
2413
	if(ntsc_phase==4.0)phase=3.0; else if (ntsc_phase == 5.0) phase = 2.0;
2414
	float ntsc_sizex = (OrgSize.x < 400.0) ? OrgSize.x : (phase == 2.0) ? 320.0 : 256.0;
2415
	ntsc_sizex = (ntsc_samp < 1.5) ? ntsc_sizex : OrgSize.x;
2416
	float ntsc_sizey = OrgSize.y / max(round(OrgSize.y / 220.0), 1.0);
2417
	float2 pix_no = vtexcoord * float2(ntsc_sizex,ntsc_sizey) * float2(4.0, 1.0);
2418-
	ntsc_sizex = (chr_freq < 1.5) ? ntsc_sizex : OrgSize.x;
2418+
2419
	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));
2420
	float ARTIFACT=cust_artifacting;
2421
	float FRINGING=cust_fringing;
2422
	float BRIGHTNESS=ntsc_brt;
2423
	float SATURATION=ntsc_sat;
2424
	float MERGE=0.0;
2425
	if(ntsc_fields== -1.0&&phase==3.0) MERGE=1.0;else
2426
	if(ntsc_fields== 0.0) MERGE=0.0;else
2427
	if(ntsc_fields== 1.0) MERGE=1.0;
2428
	float MIT = ntsc_taps;
2429
	MIT = smothstep(16.0, 8.0, MIT) * 0.325;
2430
	float3x3 mix_m = float3x3(BRIGHTNESS,FRINGING,FRINGING,ARTIFACT,2.0*SATURATION,0.0,ARTIFACT,0.0,2.0*SATURATION);
2431
	if (vtexcoord.x > 1.0) return 0.0.xxxx; else
2432
	{
2433
	float3 col0=texCD(JoNTSC_S0I, vtexcoord).rgb;
2434
	float3 yiq1=rgb2yiq(col0);
2435
	yiq1.x=pow(yiq1.x,ntsc_gamma);
2436
	float lum=yiq1.x;
2437
	float3 temp=yiq1;
2438
	float3 yiq2=yiq1;
2439
	float3 yiqs=yiq1;
2440
	float3 yiqz=yiq1;
2441
2442
	float res = nscale;
2443
2444
	if (abs(ntsc_dith) > 0.005 && OrgSize.y < 300.0 && (phase == 2.0 || ntsc_phase > 3.5))
2445
	{
2446
	float2 TexD = (floor(vtexcoord * OrgSize.xy) + 0.5)*OrgSize.zw;
2447
	float2 xx = float2(OrgSize.z, 0.0);
2448
2449
	float ca = get_luma(texCD(JoNTSC_S0I, TexD - xx - xx).rgb);
2450
	float c0 = get_luma(texCD(JoNTSC_S0I, TexD - xx).rgb);
2451
	float c1 = get_luma(texCD(JoNTSC_S0I, TexD     ).rgb);
2452
	float c2 = get_luma(texCD(JoNTSC_S0I, TexD + xx).rgb);
2453
	float cb = get_luma(texCD(JoNTSC_S0I, TexD + xx + xx).rgb);
2454
2455
	float line0  = smothstep(0.01, 0.0, min(abs(c1-c0),abs(c2-c1)));
2456
	float line1  = max(smothstep(0.01, 0.0, min(abs(ca-c0),abs(c2-cb))), line0);
2457
	float line2  = max(smothstep(0.01, 0.0, min(abs(ca-c2),abs(c0-cb))), line1);
2458-
	float line0  = smothstep(0.0075, 0.0, min(abs(c1-c0),abs(c2-c1)));
2458+
	float line3  = smothstep(0.01, 0.0, min(max(abs(c0-c2),abs(c1-ca)),max(abs(c0-c2),abs(c1-cb))));
2459-
	float line1  = max(smothstep(0.0075, 0.0, min(abs(ca-c0),abs(c2-cb))), line0);
2459+
	line2 = lerp(line2, line0, line3);
2460-
	float line2  = max(smothstep(0.0075, 0.0, min(abs(ca-c2),abs(c0-cb))), line1);
2460+
2461
	res /= 1.0 + (1.0-line2) * nd;
2462
	}
2463
2464
	if(MERGE>0.5)
2465
	{
2466
	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.));
2467
	float mod_phase2=chroma_phase2+pix_no.x*CHROMA_MOD_FREQ;
2468
	float i_mod2=cos( mod_phase2 );
2469
	float q_mod2=sin( mod_phase2 );
2470
	yiq2.yz*=float2(i_mod2,q_mod2);
2471
	yiq2=mul(mix_m, yiq2);
2472
	yiq2.yz*=float2(i_mod2,q_mod2);
2473
	yiq2.yz =lerp(yiq2.yz,temp.yz,MIT);
2474
	if(res>1.025)
2475
	{
2476
	mod_phase2=chroma_phase2 + pix_no.x * CHROMA_MOD_FREQ * res;
2477
	i_mod2=cos(mod_phase2);
2478
	q_mod2=sin(mod_phase2);
2479
	yiqs.yz*=float2(i_mod2,q_mod2);
2480
	yiq2.x=dot(yiqs,mix_m[0]);
2481
	}
2482
	}
2483
	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.));
2484
	float mod_phase1=chroma_phase1+pix_no.x*CHROMA_MOD_FREQ;
2485
	float i_mod1=cos( mod_phase1 );
2486
	float q_mod1=sin( mod_phase1 );
2487
	yiq1.yz*=float2(i_mod1,q_mod1);
2488
	yiq1=mul(mix_m, yiq1);
2489
	yiq1.yz*=float2(i_mod1,q_mod1);
2490
	yiq1.yz =lerp(yiq1.yz,temp.yz,MIT);
2491
	if(res>1.025)
2492
	{
2493
	mod_phase1=chroma_phase1 + pix_no.x*CHROMA_MOD_FREQ * res;
2494
	i_mod1=cos(mod_phase1);
2495
	q_mod1=sin(mod_phase1);
2496
	yiqz.yz*=float2(i_mod1,q_mod1);
2497
	yiq1.x=dot(yiqz,mix_m[0]);
2498
	}
2499
	if(ntsc_phase==4.0){yiq1.x=lum;yiq2.x=lum;}
2500
	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);}
2501
	return float4(yiq1,lum);
2502
	}
2503
}
2504
2505
float4 Signal_2_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2506
{
2507
	float2 tex_c=texcoord+float2(0.5/speedup*OrgSize.z/4.0,0.0);
2508
	float NOrgSize = (OrgSize.x < 400.0) ? OrgSize.x : OrgSize.x / max(round(OrgSize.x / 300.0), 1.0);
2509
	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);
2510
	if (ntsc_phase == 4.0) phase = 3.0; else if (ntsc_phase == 5.0) phase = 2.0;
2511
	const int TAPS_2_phase=32;
2512
	const int TAPS_3_phase=24;
2513
	float luma_filter_2_phase[33]={
2514
   -0.000174844,-0.000205844,-0.000149453,-0.000051693, 0.000000000,-0.000066171,-0.000245058,-0.000432928,-0.000472644,-0.000252236, 0.000198929,
2515
    0.000687058, 0.000944112, 0.000803467, 0.000363199, 0.000013422, 0.000253402, 0.001339461, 0.002932972, 0.003983485, 0.003026683,-0.001102056,
2516
   -0.008373026,-0.016897700,-0.022914480,-0.021642347,-0.028863273, 0.027271957, 0.054921920, 0.098342579, 0.139044281, 0.168055832, 0.178571429};
2517
	float chroma_filter_2_phase[33]={
2518
   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,
2519
   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,
2520
   30.00000, 31.00000, 32.00000, 33.00000};
2521
	float chroma_filter_3_phase[33]={
2522
    0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000,
2523
    0.000000000, 0.000000000, 0.000000000,
2524
   -0.000118847,-0.000271306,-0.000502642,-0.000930833,-0.001451013,
2525
   -0.002064744,-0.002700432,-0.003241276,-0.003524948,-0.003350284,
2526
   -0.002491729,-0.000721149, 0.002164659, 0.006313635, 0.011789103,
2527
    0.018545660, 0.026414396, 0.035100710, 0.044196567, 0.053207202,
2528
    0.061590275, 0.068803602, 0.074356193, 0.077856564, 0.079052396};
2529
	if (tex_c.x * speedup > (1.00325)) discard;
2530
	float luma_filter_3_phase[33]={
2531
    0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000,
2532
    0.000000000, 0.000000000, 0.000000000,
2533
   -0.000012020,-0.000022146,-0.000013155,-0.000012020,-0.000049979,
2534
   -0.000113940,-0.000122150,-0.000005612, 0.000170516, 0.000237199,
2535
    0.000169640, 0.000285688, 0.000984574, 0.002018683, 0.002002275,
2536
   -0.005909882,-0.012049081,-0.018222860,-0.022606931, 0.002460860,
2537
    0.035868225, 0.084016453, 0.135563500, 0.175261268, 0.220176552};
2538
2539
	float res = nscale;
2540
   
2541
	if (abs(ntsc_dith) > 0.005 && OrgSize.y < 300.0 && (phase == 2.0 || ntsc_phase > 3.5))
2542
	{
2543
	float2 TexD = (floor(tex_c * OrgSize.xy) + 0.5)*OrgSize.zw;
2544
	float2 xx = float2(OrgSize.z, 0.0);
2545
2546
	float ca = texCD(JoNTSC_S03, TexD - xx - xx).a;
2547
	float c0 = texCD(JoNTSC_S03, TexD - xx).a;
2548
	float c1 = texCD(JoNTSC_S03, TexD     ).a;
2549
	float c2 = texCD(JoNTSC_S03, TexD + xx).a;
2550
	float cb = texCD(JoNTSC_S03, TexD + xx + xx).a;
2551
2552
	float line0  = smothstep(0.01, 0.0, min(abs(c1-c0),abs(c2-c1)));
2553-
	float line0  = smothstep(0.0075, 0.0, min(abs(c1-c0),abs(c2-c1)));
2553+
	float line1  = max(smothstep(0.01, 0.0, min(abs(ca-c0),abs(c2-cb))), line0);
2554-
	float line1  = max(smothstep(0.0075, 0.0, min(abs(ca-c0),abs(c2-cb))), line0);
2554+
	float line2  = max(smothstep(0.01, 0.0, min(abs(ca-c2),abs(c0-cb))), line1);
2555-
	float line2  = max(smothstep(0.0075, 0.0, min(abs(ca-c2),abs(c0-cb))), line1);
2555+
	float line3  = smothstep(0.01, 0.0, min(max(abs(c0-c2),abs(c1-ca)),max(abs(c0-c2),abs(c1-cb))));
2556
	line2 = lerp(line2, line0, line3);
2557
	float nd = (ntsc_dith > 0.005) ? ntsc_dith : max(res-1.0, 0.0);
2558
	res /= 1.0 + (1.0-line2) * nd;
2559
	}
2560
2561
	float ntsc_sizex = (ntsc_samp > 1.5) ? OrgSize.x : ((OrgSize.x < 400.0) ? OrgSize.x : (phase == 2.0) ? 320.0 : 256.0);
2562
	float2 one_x = 0.25 / ntsc_sizex.xx;
2563
	one_x.x = one_x.x / res / speedup;
2564
	one_x.y = one_x.y / speedup;
2565
   
2566
	float3 signal = float3(0.0, 0.0, 0.0);
2567
	if(ntsc_phase>3.5){luma_filter_3_phase=luma_filter_2_phase;}
2568
	float offset=0.0;int i=0; float j =0.0;
2569
	float3 wsum =0.0.xxx;
2570
	float3 sums=wsum;
2571
	float3 tmps=wsum;
2572
	if(phase<2.5)
2573
	{
2574
	one_x.y = one_x.y/ntsc_cscale1;
2575
	float3 dx = float3(one_x.x, one_x.y, 0.0);
2576
	float mit = 1.0;
2577
	float loob = ntsc_taps;
2578
	loob = max(loob, 8.0); mit = 1.0 + 0.04*pow(smothstep(16.0, 8.0, loob), 0.5);
2579
	float3 xd = dx; dx.x*=mit;
2580
	int loopstart = int(32.0 - loob);
2581
	int j = loopstart;
2582
	for(i=loopstart;i<32;i++)
2583
	{
2584
	offset = float(i-loopstart); xd.xy = (offset - loob)*dx.xy;
2585
	j = i - loopstart;
2586
	sums = fetch_offset(xd);
2587
	tmps = float3(luma_filter_2_phase[i], chroma_filter_2_phase[j].xx);
2588
	wsum=wsum+tmps;
2589
	signal+=sums*tmps;
2590
	}
2591
	j = int(loob);
2592
	tmps=float3(luma_filter_2_phase[TAPS_2_phase], chroma_filter_2_phase[j], chroma_filter_2_phase[j]);
2593
	wsum=wsum+wsum+tmps;
2594
	signal+=texCD(JoNTSC_S03,tex_c).xyz*tmps;
2595
	signal =signal/wsum;
2596
	}else
2597
	{
2598
	one_x.y=one_x.y/ntsc_cscale2;
2599
	float3 dx=float3(one_x.x,one_x.y,0.0);
2600
	float mit=1.0;
2601
	float loob=min(ntsc_taps,TAPS_3_phase); 
2602
	if(ntsc_phase>3.5){loob=max(loob,8.0); mit=1.0+0.04*pow(swoothstep(16.0,8.0,loob),0.5);}
2603
	float3 xd=dx; dx.x*=mit;
2604
	int loopstart=int(32.0-loob);
2605
	for(i=loopstart;i<32;i++)
2606
	{
2607
	offset=float(i-loopstart); xd.xy=(offset-loob)*dx.xy;
2608
	sums=fetch_offset(xd);
2609
	tmps=float3(luma_filter_3_phase[i], chroma_filter_3_phase[i].xx);
2610
	wsum=wsum+tmps;
2611
	signal+=sums*tmps;
2612
	}
2613
	tmps=float3(luma_filter_3_phase[TAPS_2_phase], chroma_filter_3_phase[TAPS_2_phase], chroma_filter_3_phase[TAPS_2_phase]);
2614
	wsum=wsum+wsum+tmps;
2615
	signal+=texCD(JoNTSC_S03,tex_c).xyz*tmps;
2616
	signal =signal/wsum;
2617
	}
2618
	signal.x=clamp( signal.x,0.0,1.0);
2619
	if(ntsc_ring>0.05)
2620
	{
2621
	float2 dx=float2(OrgSize.z/min(res,1.0)/speedup,0.0);
2622
	float a=texCD(JoNTSC_S03,tex_c-2.0*dx).a;
2623
	float b=texCD(JoNTSC_S03,tex_c-    dx).a;
2624
	float c=texCD(JoNTSC_S03,tex_c+2.0*dx).a;
2625
	float d=texCD(JoNTSC_S03,tex_c+    dx).a;
2626
	float e=texCD(JoNTSC_S03,tex_c       ).a;
2627
	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);
2628
	}
2629
	float x=get_luma(texCD(JoNTSC_S02, tex_c*float2(speedup, 1.0)).rgb);
2630
	return float4(signal,x);
2631
}
2632
2633
float4 Signal_3_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2634
{
2635
    float auto_rez = lerp(1.0, 0.5, clamp(auto_res * round(OrgSize.x/300.0)-1.0, 0.0, 1.0));
2636
    float2 vtex_c0=texcoord / float2(speedup, 1.0);
2637
    float2 vtex_c1=(floor(vtex_c0*OrgSize.xy)+0.5)*OrgSize.zw;
2638
    float2 vtex_c=texcoord+float2(0.5*(OrgSize.z/auto_rez)/4.0,0.0);
2639
    float NOrgSize = (OrgSize.x < 400.0) ? OrgSize.x : OrgSize.x / max(round(OrgSize.x / 300.0), 1.0);
2640
    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);
2641
    if (ntsc_phase == 4.0) phase = 3.0; else if (ntsc_phase == 5.0) phase = 2.0;
2642
2643
    float4 AdvSize= LumSize;
2644
2645
    if(speedup > 1.25 && ((OrgSize.y > 500.0 && AdvSize.y > 820.0) || AdvSize.y > 820.0))
2646
    {
2647
        float3 signal = texCD(JoNTSC_S04, vtex_c0).xyz;
2648
        signal.x = pow(signal.x, 1.0/ntsc_gamma);
2649
        return float4(clamp(yiq2rgb(signal), 0.0, 1.0), 1.0);
2650
    }
2651
    else
2652
    {
2653
2654
	float2 xx=float2(0.5000*OrgSize.z/auto_rez/speedup,0.0);
2655
	float2 dx=float2(0.0625*OrgSize.z/auto_rez/speedup,0.0);
2656
2657
	float2 tcoorb=(floor(OrgSize.xy*vtex_c)+0.5)*OrgSize.zw;
2658
	float2 tcoord=vtex_c-2.0*dx;
2659
	float2 vTex=vtex_c;
2660
	if (speedup > 1.25) { tcoorb = vtex_c1; tcoord = vtex_c0; vTex = vtex_c0; }
2661
	float3 ll1=texCD(JoNTSC_S04,tcoord+ xx).xyz;
2662
	float3 ll2=texCD(JoNTSC_S04,tcoord- xx).xyz;
2663
	float dy=0.0;
2664
	float2 yy = float2(0.0, OrgSize.w);
2665
	xx=float2(OrgSize.z/auto_rez/speedup,0.0);
2666
	float th=(phase<2.5)?0.025:0.0075;;
2667
	float ca=texCD(JoNTSC_S03,tcoorb-xx-xx).a;
2668
	float c0=texCD(JoNTSC_S03,tcoorb-xx   ).a;
2669
	float c1=texCD(JoNTSC_S03,tcoorb      ).a;
2670
	float c2=texCD(JoNTSC_S03,tcoorb+xx   ).a;
2671
	float cb=texCD(JoNTSC_S03,tcoorb+xx+xx).a;
2672
	float line0=    swoothstep(th,0.0,min(abs(c1-c0),abs(c2-c1)));
2673
	float line1=max(swoothstep(th,0.0,min(abs(ca-c0),abs(c2-cb))), line0 );
2674
	float line2=max(swoothstep(th,0.0,min(abs(ca-c2),abs(c0-cb))), line1 );
2675
2676
    float diffboost = 0.0;
2677
2678
    if (ntsc_fonts > 0.255)
2679
    {
2680
        float b1  = texCD(JoNTSC_S03, tcoorb - yy).a;
2681
        float d1  = texCD(JoNTSC_S03, tcoorb + yy).a;
2682
        float d2  = texCD(JoNTSC_S03, tcoorb + xx + yy).a;
2683
2684
        float maxdif = float(0.5 * (abs(c0-c1) + abs(c1-c2)) > (1.0 - ntsc_fonts)) * float(abs(c2-c0) < 0.05);
2685
        float linecb = swoothstep(0.1, 0.0, max(abs(c1-b1), abs(c1-d1)));
2686
        linecb = linecb * float(abs(c1-b1) < 0.05 || abs(c2-d2) < 0.05);
2687
2688
        b1 = texCD(JoNTSC_S04, tcoord         ).x;
2689
        d1 = texCD(JoNTSC_S04, tcoord - 9.0*yy).x;
2690
        d2 = texCD(JoNTSC_S04, tcoord + 9.0*yy).x;
2691
   
2692
        maxdif = maxdif * float((abs(d1-b1) > 0.2 || abs(d2-b1) > 0.2));
2693
2694
        float xdif1 = 0.0;
2695
        float xdif2 = 0.0;
2696
        float th   = 0.215;
2697
2698
        for (float i = 0.5; i < 10.5; i++)
2699
        {
2700
            float j = i + 1.0;
2701
            ca  = texCD(JoNTSC_S04, tcoord -  i*xx).x;
2702
            c0  = texCD(JoNTSC_S04, tcoord -  j*xx).x;
2703
            c2 = texCD(JoNTSC_S04, tcoord +  i*xx).x;
2704
            cb = texCD(JoNTSC_S04, tcoord +  j*xx).x;
2705
            xdif1 = max(abs(ca - c0) - th, xdif1);
2706
            xdif2 = max(abs(cb - c2) - th, xdif2);
2707
        }
2708
2709
        float linex   = swoothstep(0.0, 0.125, min(xdif1, xdif2));
2710
        diffboost     = min(linex * linecb * maxdif, 0.625);
2711
    }
2712
2713
    float3 ref = texCD(JoNTSC_S04, tcoord).xyz;
2714
    float2 org = ref.yz;
2715
	if( ntsc_rainbow>0.5&&(phase<2.5 || ntsc_phase == 5.0))
2716
	{
2717
	float ybool1=1.0;
2718
	if((ntsc_rainbow<1.5)&&bool(line0))ybool1=0.0;else
2719
	if((ntsc_rainbow<2.5)&&bool(line2))ybool1=0.0;
2720
2721
	float liine_no=floor( mod(OrgSize.y*vtex_c.y,2.0));
2722
	float frame_no=floor( mod(float(framecount),2.0));
2723
	float ii=abs(liine_no-frame_no);
2724
	dy=ii*OrgSize.w*ybool1;
2725
	float2 ref1 = texCD(JoNTSC_S04, tcoord + float2(0.0, -dy)).yz;
2726
				   
2727
	float2 ref2 = texCD(JoNTSC_S04, tcoord + float2(0.0,  dy)).yz;
2728
	float2 rdf1 = abs(org - ref1);
2729
	float2 rdf2 = abs(org - ref2);
2730
	rdf1        = rdf1 / max(rdf1 + rdf2, 0.0000001);
2731
2732
	ref.yz = lerp(ref1, ref2, rdf1);
2733
	}
2734
	float lum1=min(texCD(JoNTSC_S03,vTex-dx).a, texCD(JoNTSC_S03,vTex+dx).a);
2735
	float lum2=ref.x ;
2736
	float3 ll3=abs(ll1-ll2);
2737
	float di=max(max(max(ll3.x,ll3.y),max(ll3.z,abs(ll1.x*ll1.x-ll2.x*ll2.x))),diffboost);
2738
	float df=pow(di,0.125);
2739
	float lc=swoothstep(0.20,0.10,abs(lum2-lum1))*df;
2740
	float tmp1=swoothstep(0.05-0.03*lc,0.425-0.375*lc,di);
2741
	float tmp2=pow((tmp1+0.1)/1.1,0.25);
2742
	float sweight=lerp(tmp1,tmp2,line0);
2743
	float zweight=lerp(tmp1,tmp2,line2);
2744
	float3 signal=ref;
2745
	float ntzc_shrp= abs(ntsc_shrp);
2746
	if(ntzc_shrp>0.25 || ntsc_fonts > 0.255)
2747
	{
2748
	float mixer=zweight;
2749
	if(ntsc_shrp < -0.25)mixer=sweight; mixer*=max(0.1*ntzc_shrp, diffboost*1.25);
2750
	float lumix=lerp(lum2,lum1,mixer);
2751
	float lm1=lerp(lum2*lum2 ,lum1*lum1 ,mixer);lm1=sqrt(lm1);
2752
	float lm2=lerp(sqrt(lum2),sqrt(lum1),mixer);lm2=lm2* lm2 ;
2753
	float k1=abs(lumix-lm1)+0.00001;
2754
	float k2=abs(lumix-lm2)+0.00001;
2755
	signal.x=min((k2*lm1+k1*lm2)/(k1+k2),1.0);
2756
	signal.x=min(signal.x,max(ntsc_shpe*signal.x,lum2));
2757
	}
2758
	if((ntsc_charp1+ntsc_charp2)>0.25)
2759
	{
2760
	dx.x = 0.0625 * OrgSize.z/auto_rez;
2761
	float lcoord=OrgSize.x*(vtex_c.x+dx.x )-0.5;
2762
	float fpx=frac(lcoord);
2763
	lcoord =(floor(lcoord)+0.5)*OrgSize.z;
2764
	float mixer=sweight;
2765
	if(ntsc_shrp>0.25)mixer=zweight;
2766
	mixer =lerp(swoothstep(0.075,0.125,max(ll3.y,ll3.z)),swoothstep(0.015,0.0275,di),line2)*mixer;
2767
	mixer*=0.1*((phase<2.5)? ntsc_charp1:ntsc_charp2);
2768
	tcoord=float2(lcoord,tcoord.y);
2769
	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)));
2770
	signal.yz=lerp(signal.yz,origin.yz,mixer);
2771
	}
2772
2773
    if ((RFNOISE1 + RFNOISE2) > 0.005)
2774
    {
2775
        float3 ns = NoiseNP3(vtex_c, float(framecount));
2776
        float Y   = lerp(0.375, 1.0, pow(signal.x, 0.2));
2777
2778
        signal.x = clamp(signal.x + RFNOISE1 * ns.x,  0.00, 1.00);
2779
        signal.y = clamp(signal.y + Y * RFNOISE2 * (0.325 + 1.325 * abs(signal.y)) * ns.y, -0.60, 0.60);
2780
        signal.z = clamp(signal.z + Y * RFNOISE2 * (0.325 + 1.325 * abs(signal.z)) * ns.z, -0.53, 0.53);
2781
    }
2782
	signal.x=pow(signal.x,1.0/ntsc_gamma);
2783
	signal=clamp(yiq2rgb(signal),0.0,1.0);
2784
    zweight = (phase == 2.0 || ntsc_phase > 3.5) ? zweight : 1.0;
2785
	return float4(signal,zweight);
2786
    }
2787
}
2788
2789
float4 SharpnessPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2790
{
2791
	float resmult = round(OrgSize.x / 300.0);
2792
	float2 g01=float2(-0.5*resmult*OrgSize.z,0.0);
2793
	float2 g21=float2( 0.5*resmult*OrgSize.z,0.0);
2794
	float3 c01=texCD(JoNTSC_S05,texcoord+g01).rgb;
2795
	float3 c21=texCD(JoNTSC_S05,texcoord+g21).rgb;
2796
	float3 c11=texCD(JoNTSC_S05,texcoord    ).rgb;
2797
	float3 b11=0.5*(c01+c21);
2798
	float contrazt=max(max(c11.r,c11.g),c11.b);
2799
	contrazt=lerp(2.0*CCONTR,CCONTR,contrazt);
2800
	float3 nim=min(min(c01,c21),c11);float3 mn1=min(nim,c11*(1.0-contrazt));
2801
	float3 xam=max(max(c01,c21),c11);float3 mx1=max(xam,c11*(1.0+contrazt));
2802
	float3 di0=pow(mx1-mn1+0.00001,0.75);
2803
	float3 sharpen=lerp(CSHARPEN*CDETAILS,CSHARPEN,di0);
2804
	float3 res=clamp(lerp(c11,b11,-sharpen),mn1,mx1);
2805
	if(NDEBLUR>1.125)
2806
	{
2807
	float2 toxcoord=(floor(OrgSize.xy*texcoord)+0.5)*OrgSize.zw;
2808
	float l01=get_luma(texCD(JoNTSC_S02,texcoord+2.0*g01).rgb);
2809
	float l21=get_luma(texCD(JoNTSC_S02,texcoord+2.0*g21).rgb);
2810
	float l11=get_luma(texCD(JoNTSC_S02,toxcoord        ).rgb);
2811
	float dth = texCD(JoNTSC_S05,texcoord).a;
2812
	float DEB = max(lerp(0.375*NDEBLUR, NDEBLUR, max(1.0-DSMART, dth)), 1.0);
2813
	float d11=min(min(l01,l21),l11);
2814
	l11=max(max(l01,l21),l11);
2815
	float lmn=min(min(get_luma(c01),get_luma(c21)),get_luma(c11));float ln1=min(lerp(d11,lmn,lmn),lmn);
2816
	float lmx=max(max(get_luma(c01),get_luma(c21)),get_luma(c11));float lx1=max(lerp(lmx,l11,lmx),lmx);
2817
	float r11=get_luma(res);
2818
	float di1=max((r11-ln1),0.0)+0.00001;di1=pow(di1,DEB);
2819
	float di2=max((lx1-r11),0.0)+0.00001;di2=pow(di2,DEB);
2820
	float ratio=di1/(di1+di2);
2821
	float zharpen=lerp(ln1,lx1,ratio);
2822
	zharpen=min(zharpen,max(DREDGE*zharpen,r11));
2823
	res=rgb2yiq(res);
2824
	d11=res.x;
2825
	res.x=zharpen;
2826
	res.x=clamp((1.0+ DSHARP)* res.x-DSHARP*d11,ln1*(1.0-contrazt),lx1*(1.0+contrazt));
2827
	res=max(yiq2rgb(res),0.0);
2828
	}
2829
	return float4(res,1.0);
2830
}
2831-
float4 PS_CRT_BlackCrush_AvgLum(float4 position:SV_Position,float2 texcoord:TEXCOORD) : SV_Target
2831+
2832
float4 PS_CRT_BlackCrush(float4 position:SV_Position,float2 texcoord:TEXCOORD) : SV_Target
2833
{
2834
    float vTsmooth = 0.8;
2835
    const float tsmooth_at_60 = 0.8;
2836-
    float t = get_fps() > 90 ? 0.95 : ((60.0 - get_fps()) / 30.0);
2836+
2837
    float t = (60.0 - min(get_fps(),90.0) ) / 30.0;
2838
    vTsmooth = lerp(tsmooth_at_60, tsmooth_at_30, t);
2839-
    float3 c_current = tex2Dlod(JoNTSC_S06, float4(float2(0.5, 0.5), 20.0, 0.0)).rgb;
2839+
2840-
    float lum_past = tex2Dlod(JBCrsh_S01, float4(float2(0.5,0.5), 20.0, 0)).a;
2840+
    float3 lum_current = dot (tex2Dlod(JoNTSC_S06, float4(float2(0.5,0.5), 20.0,0)).rgb, float3(0.3333,0.3333,0.3333) );
2841-
    float lum_current = (c_current.r + c_current.g + c_current.b) / 3.0;
2841+
    float lum_past = texCD(JBCrsh_S01, float2(0.5,0.5)).a;
2842
    if (framecount == 0.0) lum_past = lum_current;
2843
    float lum_avg = lerp(lum_current, lum_past, vTsmooth);
2844
    float3 c = texCD(JoNTSC_S06, texcoord).rgb;
2845-
    return float4(texCD(JoNTSC_S06, texcoord).rgb, lum_avg);
2845+
    c = adaptive_black(c, lum_avg, abs(ADPT_BLK_RANGE),ADPT_BLK_RANGE > 0.0);
2846
    return float4(c, lum_avg);
2847
}
2848
2849
float4 LuminancePS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2850-
    float lum = tex2Dlod(JBCrsh_S01, float4(float2(0.5,0.5), 20.0,0)).a;
2850+
2851-
    float3 c = texCD(JBCrsh_S01, texcoord).rgb;
2851+
2852-
    c = adaptive_black(c, lum, abs(ADPT_BLK_RANGE),ADPT_BLK_RANGE > 0.0);
2852+
2853
	float2 dx=float2(1.0/LumSize.x,0.0);
2854-
    return float4(c, 1.0);
2854+
2855
	float2 x2=2.0*dx;
2856
	float2 y2=2.0*dy;
2857
	float ltotal=0.0;
2858
	ltotal+=length(tex2Dlod(JBCrsh_S01,float4(float2(0.3,0.3),m,0)).rgb);
2859
	ltotal+=length(tex2Dlod(JBCrsh_S01,float4(float2(0.3,0.7),m,0)).rgb);
2860
	ltotal+=length(tex2Dlod(JBCrsh_S01,float4(float2(0.7,0.3),m,0)).rgb);
2861
	ltotal+=length(tex2Dlod(JBCrsh_S01,float4(float2(0.7,0.7),m,0)).rgb);
2862
	ltotal*=0.25;
2863
	ltotal=pow(0.577350269*ltotal,0.7);
2864
	float lhistory=texCD(JoNTSC_S07,float2(0.5,0.5)).a;
2865
	ltotal=lerp(ltotal,lhistory,min(lerp(lsmooth, lsmooth + lsdev, ltotal),0.99));
2866-
	ltotal+=length(tex2Dlod(JBCrsh_S02,float4(float2(0.3,0.3),m,0)).rgb);
2866+
	float3 l1=texCD(JBCrsh_S01,fuxcoord.xy   ).rgb;
2867-
	ltotal+=length(tex2Dlod(JBCrsh_S02,float4(float2(0.3,0.7),m,0)).rgb);
2867+
	float3 r1=texCD(JBCrsh_S01,fuxcoord.xy+dx).rgb;
2868-
	ltotal+=length(tex2Dlod(JBCrsh_S02,float4(float2(0.7,0.3),m,0)).rgb);
2868+
	float3 l2=texCD(JBCrsh_S01,fuxcoord.xy-dx).rgb;
2869-
	ltotal+=length(tex2Dlod(JBCrsh_S02,float4(float2(0.7,0.7),m,0)).rgb);
2869+
	float3 r2=texCD(JBCrsh_S01,fuxcoord.xy+x2).rgb;
2870
	float c1=dist(l2,l1);
2871
	float c2=dist(l1,r1);
2872
	float c3=dist(r2,r1);
2873
	return float4(c1,c2,c3,ltotal);
2874-
	float3 l1=texCD(JBCrsh_S02,fuxcoord.xy   ).rgb;
2874+
2875-
	float3 r1=texCD(JBCrsh_S02,fuxcoord.xy+dx).rgb;
2875+
2876-
	float3 l2=texCD(JBCrsh_S02,fuxcoord.xy-dx).rgb;
2876+
2877-
	float3 r2=texCD(JBCrsh_S02,fuxcoord.xy+x2).rgb;
2877+
2878
{
2879
    float3 c = texCD(JBCrsh_S01,fuxcoord).rgb;
2880
    if((downsample_levelx+downsample_levely)>0.025)
2881
    {
2882
    c=fetch_pixel(fuxcoord);
2883
    }
2884
    float intera = texCD(JoNTSC_S0I,fuxcoord).a;
2885
    float gamma_in=gamma_i;
2886
    c=pow(c,gamma_in);
2887-
    float3 c = texCD(JBCrsh_S02,fuxcoord).rgb;
2887+
2888
    return float4(c,gamma_in);
2889
}
2890
2891
float4 HGaussianPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2892
{
2893
	float FINE_GAUSS= (FINE_GAUSS>0.5)? FINE_GAUSS: lerp(0.75,0.50,-FINE_GAUSS);
2894
	float4 AdvSize=float4(OrgSize.x,OrgSize.y,OrgSize.z,OrgSize.w)*float4(FINE_GAUSS,FINE_GAUSS,1.0/FINE_GAUSS,1.0/FINE_GAUSS);
2895
	float f=frac(AdvSize.x*texcoord.x);
2896
	f=0.5-f;
2897
	float2 tex=floor(AdvSize.xy*texcoord)*AdvSize.zw+0.5*AdvSize.zw;
2898
	float3 color=0.0;
2899
	float2 dx=float2(AdvSize.z ,0.0);
2900
	float3 pixel;
2901
	float w;
2902
	float wsum=0.0;
2903
	float n=-SIZEH;
2904
	do
2905
	{
2906
	pixel=texCD(JoNTSC_S08,tex+n*dx).rgb;
2907
	if(m_glow>0.5)
2908
	{
2909
	pixel=max(pixel-m_glow_cutoff,0.0);
2910
	pixel=plant(pixel,max(max(max(pixel.r,pixel.g),pixel.b)-m_glow_cutoff,0.0));
2911
	}
2912
	w=gauss_h(n+f);
2913
	color=color+w*pixel;
2914
	wsum=wsum+w;
2915
	n=n+1.0;
2916
	}
2917
	while(n<=SIZEH);
2918
	color=color/wsum;
2919
	return float4(color,1.0);
2920
}
2921
2922
float4 VGaussianPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2923
{
2924
	float FINE_GAUSS= (FINE_GAUSS>0.5)? FINE_GAUSS: lerp(0.75,0.50,-FINE_GAUSS);
2925
	float4 AdvSize=float4(SrcSize.x,OrgSize.y,SrcSize.z,OrgSize.w)*float4(FINE_GAUSS,FINE_GAUSS,1.0/FINE_GAUSS,1.0/FINE_GAUSS);
2926
	float f=frac(AdvSize.y*texcoord.y);
2927
	f=0.5-f;
2928
	float2 tex=floor(AdvSize.xy*texcoord)*AdvSize.zw+0.5*AdvSize.zw;
2929
	float3 color=0.0;
2930
	float2 dy=float2(0.0,AdvSize.w );
2931
	float3 pixel;
2932
	float w;
2933
	float wsum=0.0;
2934
	float n=-SIZEV;
2935
	do
2936
	{
2937
	pixel=texCD(JoNTSC_S10,tex+n*dy).rgb;
2938
	w=gauss_v(n+f);
2939
	color=color+w*pixel;
2940
	wsum=wsum+w;
2941
	n=n+1.0;
2942
	}
2943
	while(n<=SIZEV);
2944
	color=color/wsum;
2945
	return float4(color,1.0);
2946
}
2947
2948
float4 BloomHorzPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2949
{
2950
	float FINE_BLOOM= (FINE_BLOOM>0.5)? FINE_BLOOM: lerp(0.75,0.50,-FINE_BLOOM);
2951
	float4 AdvSize=float4(OrgSize.x,OrgSize.y,OrgSize.z,OrgSize.w)*float4(FINE_BLOOM,FINE_BLOOM,1.0/FINE_BLOOM,1.0/FINE_BLOOM);
2952
	float f=frac(AdvSize.x*texcoord.x);
2953
	f=0.5-f;
2954
	float2 tex=floor(AdvSize.xy*texcoord)*AdvSize.zw+0.5*AdvSize.zw;
2955
	float4 color=0.0;
2956
	float2 dx=float2(AdvSize.z ,0.0);
2957
	float4 pixel;
2958
	float w;
2959
	float wsum=0.0;
2960
	float n=-SIZEX;
2961
	do
2962
	{
2963
	pixel=texCD(JoNTSC_S08,tex+n*dx);
2964
	w=bloom_h(n+f);
2965
	pixel.a =max(max(pixel.r,pixel.g),pixel.b);
2966
	pixel.a*=pixel.a*pixel.a;
2967
	color=color+w*pixel;
2968
	wsum=wsum+w;
2969
	n=n+1.0;
2970
	}
2971
	while(n<=SIZEX);
2972
	color=color/wsum;
2973
	return float4(color.rgb,pow(color.a,0.333333));
2974
}
2975
2976
float4 BloomVertPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
2977
{
2978
	float FINE_BLOOM= (FINE_BLOOM>0.5)? FINE_BLOOM: lerp(0.75,0.50,-FINE_BLOOM);
2979
	float4 AdvSize=float4(SrcSize.x,OrgSize.y,SrcSize.z,OrgSize.w)*float4(FINE_BLOOM,FINE_BLOOM,1.0/FINE_BLOOM,1.0/FINE_BLOOM);
2980
	float f=frac(AdvSize.y*texcoord.y);
2981
	f=0.5-f;
2982
	float2 tex=floor(AdvSize.xy*texcoord)*AdvSize.zw+0.5*AdvSize.zw;
2983
	float4 color=0.0;
2984
	float2 dy=float2(0.0,AdvSize.w );
2985
	float4 pixel;
2986
	float w;
2987
	float wsum=0.0;
2988
	float n=-SIZEY;
2989
	do
2990
	{
2991
	pixel=texCD(JoNTSC_S12,tex+n*dy);
2992
	w=bloom_v(n+f);
2993
	pixel.a*=pixel.a*pixel.a;
2994
	color=color+w*pixel;
2995
	wsum=wsum+w;
2996
	n=n+1.0;
2997
	}
2998
	while(n<=SIZEY);
2999
	color=color/wsum;
3000
	return float4(color.rgb,pow(color.a,0.175000));
3001
}
3002
3003
float4 NTSC_TV1_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
3004
{
3005
	float f=frac(LumSize.x*fuxcoord.x);
3006
	f=0.5-f;
3007
	float2 tex=floor(LumSize.xy*fuxcoord)*LumSize.zw+0.5*LumSize.zw;
3008
	float3 color=0.0.xxx;
3009
	float solor=0.0;
3010
	float2 dx=float2(LumSize.z ,0.0);
3011
	float3 pixel;
3012
	float w=0.0;
3013
	float swum=0.0;
3014
	float wsum=0.0;
3015
	float3 cmax=0.0.xxx;
3016
	float3 cmin=1.0.xxx;
3017
	float xs=max(2.0*0.4, 1.0);
3018
	float hsharpness=HSHARPNESS*xs*filter_res;
3019
	float LIGMA_H2 = LIGMA_H * HSHARPNESS;
3020
	xs=1.0/(2.0*LIGMA_H2*LIGMA_H2*xs*xs*filter_res*filter_res);
3021
	float sharp=crthd_h(hsharpness,xs) *S_SHARP;
3022
	float ksharp = -2.0*hsharpness*xs*sharp;	
3023
	float maxsharp=MAXS;
3024
	float FPR=hsharpness;
3025
	float FPRi=1.0/hsharpness;
3026
	float fpx=0.0;
3027
	float sp=0.0;
3028
	float sw=0.0;
3029
	float ts=0.025;
3030
	float3 luma=float3(0.2126,0.7152,0.0722);
3031
	float LOOPSIZE=ceil(2.0*FPR);
3032
	float n=-LOOPSIZE;
3033
	do
3034
	{
3035
	pixel=texCD(JoNTSC_S08,tex+n*dx).rgb;
3036
	w=crthd_h(n+f,xs)-sharp;
3037
	fpx=clamp((abs(n+f)-FPR)*FPRi, 0.0, 1.0);
3038
	if(w<0.0)w=max(ksharp*fpx, maxsharp * ksharp * (1.0-fpx*fpx)); else
3039
	{
3040
	cmax=max(cmax,pixel);cmin=min(cmin,pixel);sw=w*(dot(pixel,luma)+ts);
3041
	sp=max(max(pixel.r,pixel.g),pixel.b);
3042
	solor=solor+sw*sp;
3043
	swum=swum+sw;
3044
	}
3045
	color=color+w*pixel;
3046
	wsum=wsum+w;
3047
	n=n+1.0;
3048
	}
3049
	while(n<=LOOPSIZE);
3050
	color=color/wsum;
3051
	solor=solor/swum;
3052
	color=clamp(lerp( clamp (color,cmin,cmax),color,SSRNG),0.0,1.0);
3053
	solor=clamp(lerp(max(max(color.r,color.g),color.b),solor,spike),0.0,1.0);
3054
	return float4(color,solor);
3055
}
3056
3057
float4 NTSC_TV2_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
3058
{
3059
	float gamma_in=1.0/texCD(JoNTSC_S08,float2(0.25,0.25)).a;
3060
	float lum=texCD(JoNTSC_S07,float2(0.5,0.5)).a;
3061
	float intera=texCD(JoNTSC_S08,float2(0.75,0.25)).a;
3062
	bool hscans=(hiscan>0.5);
3063
	bool inter6=(intera<0.35&&interm==6.0);
3064
	bool interb=(((intera<0.35&&!inter6)||(no_scanlines>0.025))&&!hscans);
3065
	float4 AdvSize= LumSize;
3066
	float SourceY=AdvSize.y;
3067
	float sy=1.0;
3068
	if( intres==1.0)sy=max(round(SourceY/224.0),1.0);
3069
	if( intres>0.25&&intres!=1.0)sy=intres;
3070
	if (inter6) sy*=2.0;
3071
	AdvSize*=float4(1.0,1.0/sy,1.0,sy);
3072
	float2 lexcoord=fuxcoord.xy;
3073
	if(IOS> 0.0&& !interb)
3074
	{
3075
	float2 ofactor= NewSize.xy/OrgSize.xy;
3076
	float2 ifactor=(IOS<2.5)? floor(ofactor):ceil(ofactor);
3077
	float2 diff=ofactor/ifactor;
3078
	float scan=diff.y;
3079
	lexcoord=overscan(lexcoord,scan,scan);
3080
	if(IOS==1.0||IOS==3.0) lexcoord=float2(fuxcoord.x,lexcoord.y);
3081
	}
3082
	float factor=1.0+(1.0-0.5*OS)*blm_2/100.0-lum*blm_2/100.0;
3083
	lexcoord=overscan(lexcoord,factor,factor);
3084
	lexcoord.y = lexcoord.y - VShift*OrgSize.w;
3085
	lexcoord=overscan(lexcoord,(OrgSize.x-overscanx)/OrgSize.x,(OrgSize.y-overscany)/OrgSize.y);
3086
	float2 pos = warp(lexcoord);
3087
	float ii = float(inter6)*(floor(mod(float(framecount), 2.0)));
3088
	float2 coffset = float2(0.5, 0.5 + 0.5*ii);
3089
	float2 ps=AdvSize.zw;
3090
	float2 OGL2Pos=pos*AdvSize.xy-coffset;
3091
	float2 fp=frac(OGL2Pos);
3092
	float2 dx=float2(ps.x,0.0);
3093
	float2 dy=float2(0.0,ps.y);
3094
	float f=fp.y;
3095
	float2 pC4=floor(OGL2Pos)*ps+0.5*ps; pC4.y = pC4.y + float(inter6)*0.25*dy.y;
3096
	pC4.x=pos.x;
3097
	if( intres==0.5<1.5)pC4.y=floor(pC4.y*OrgSize.y)*OrgSize.w+0.5*OrgSize.w;
3098
	if( interb&&no_scanlines<0.025|| hscans) pC4.y=pos.y;else
3099
	if( interb) pC4.y=pC4.y+smoothstep(0.40-0.5*no_scanlines,0.60+0.5*no_scanlines,f)*AdvSize.w;
3100
	float3 color1=texCD(JoNTSC_S09,pC4).rgb;
3101
	float3 solor1=texCD(JoNTSC_S09,pC4).aaa;
3102
	if(!interb)color1=pow(color1,scangamma/gamma_in);
3103
	pC4+=dy;
3104
	if( intres==0.5<1.5)pC4.y=floor((pos.y+0.33*dy.y)*OrgSize.y)*OrgSize.w+0.5*OrgSize.w;
3105
	float3 color2=texCD(JoNTSC_S09,pC4).rgb;
3106
	float3 solor2=texCD(JoNTSC_S09,pC4).aaa;
3107
	if(!interb)color2=pow(color2,scangamma/gamma_in);
3108
	float3 ctmp=color1;float w3=1.0;float3 color=color1;
3109
	float3 one=1.0;
3110
	if( hscans){color2=color1;solor2=solor1;}
3111
	if(!interb|| hscans)
3112
	{
3113
	float ssub = ssharp*abs(solor1.x-solor2.x);
3114
	float shape1=lerp(scanline1,scanline2 + ssub * solor1.x * 35.0,    f);
3115
	float shape2=lerp(scanline1,scanline2 + ssub * solor2.x * 35.0,1.0-f);
3116
	float wt1=st0(    f);
3117
	float wt2=st0(1.0-f);
3118
	float3 color0=color1*wt1+color2*wt2;
3119
	float3 solor0=solor1*wt1+solor2*wt2;
3120
	ctmp = color0/(wt1+wt2);
3121
	float3 stmp=solor0/(wt1+wt2);
3122
	if(abs(rolling_scan)>0.005){color1=ctmp;color2=ctmp;solor1=stmp;solor2=stmp;}
3123
	float3 w1,w2;
3124
	float3 cref1=lerp(stmp,solor1,beam_size);float creff1=pow(max(max(cref1.r,cref1.g),cref1.b),scan_falloff);
3125
	float3 cref2=lerp(stmp,solor2,beam_size);float creff2=pow(max(max(cref2.r,cref2.g),cref2.b),scan_falloff);
3126
	if(tds>0.5){shape1=lerp(scanline2,shape1,creff1);shape2=lerp(scanline2,shape2,creff2);}
3127
	float scanpix=OrgSize.y/NewSize.y;
3128
	float f1=frac(f-rolling_scan*float(framecount)*scanpix);
3129
	float f2=1.0-f1;
3130
	float m1=max(max(color1.r,color1.g),color1.b)+eps;
3131
	float m2=max(max(color2.r,color2.g),color2.b)+eps;
3132
	cref1=color1/m1;
3133
	cref2=color2/m2;
3134
	if(gsl< 0.5)
3135
	{w1=sw0(f1,creff1,shape1,cref1);w2=sw0(f2,creff2,shape2,cref2);}else
3136
	if(gsl==1.0)
3137
	{w1=sw1(f1,creff1,shape1,cref1);w2=sw1(f2,creff2,shape2,cref2);}else
3138
	{w1=sw2(f1,creff1,shape1,cref1);w2=sw2(f2,creff2,shape2,cref2);}
3139
	float3 w3=w1+w2;
3140
	float wf1=max(max(w3.r,w3.g),w3.b);
3141
	if(wf1>1.0){wf1=1.0/wf1;w1*=wf1,w2*=wf1;}
3142
	if(abs(clp)>0.005)
3143
	{
3144
	sy=m1; one=(clp>0.0)?w1:1.0.xxx;
3145
	float sat=1.0001-min(min(cref1.r,cref1.g),cref1.b);
3146
	color1=lerp(color1,plant(pow(color1,0.70.xxx-0.325*sat),sy),pow(sat,0.3333)*one*abs(clp));
3147
	sy=m2; one=(clp>0.0)?w2:1.0.xxx;
3148
	sat=1.0001-min(min(cref2.r,cref2.g),cref2.b);
3149
	color2=lerp(color2,plant(pow(color2,0.70.xxx-0.325*sat),sy),pow(sat,0.3333)*one*abs(clp));
3150
	}
3151
	color=gc1(color1)*w1+gc1(color2)*w2;
3152
	if (bloomsamp > 0.5) {	
3153
		float3 BloomS = texCD(JoNTSC_S13, pos).rgb;
3154
		BloomS = pow(BloomS, scangamma/gamma_in);
3155
		float cm = max(max(ctmp.r,ctmp.g),ctmp.b);
3156
		float bm = max(max(BloomS.r,BloomS.g),BloomS.b);
3157
		float bmix = clamp(max((cm-bm), (bm-cm)/(cm+0.25)-cm), 0.0, 1.0);
3158
		if (abs(clp) > 0.005)
3159
		{
3160
			sy = cm + eps; one = (clp > 0.0) ? min(w1+w2,1.0) : 1.0.xxx;
3161
			cref1 = plant(BloomS,1.0);
3162
			float sat = 1.0001-min(min(cref1.r,cref1.g),cref1.b);
3163
			BloomS = lerp(BloomS, plant(pow(BloomS, 0.70.xxx-0.325*sat),sy), pow(sat,0.3333)*one*abs(clp));
3164
		}
3165
		float3 Bloom1 = (color1*wt1 + color2*wt2)/(wt1+wt2);
3166
		BloomS = lerp(BloomS, Bloom1, min(3.0*abs(plant(sqrt(Bloom1),1.0) - plant(sqrt(BloomS),1.0)), 1.0));
3167
		bm = max(max(BloomS.r,BloomS.g),BloomS.b);
3168
		BloomS = plant(lerp(BloomS,Bloom1,bloomsamp-1.0), lerp(bm, 1.125*cm, bmix));
3169
		BloomS = gc1(BloomS)*(w1+w2);
3170
		color = min(lerp(color, BloomS, pow(cm, lerp(0.4, 0.2, pow(cm,0.375)))), max(BloomS,color));
3171
	}
3172
	color=min(color,1.0);
3173
	}
3174
	if( interb)
3175
	{
3176
	color=gc1(color1);
3177
	}
3178
	float colmx=max( max(ctmp.r,ctmp.g),ctmp.b);
3179
	if(!interb){color=pow(color,gamma_in/scangamma); colmx = pow(colmx, gamma_in/scangamma); }
3180
	return float4(color,colmx);
3181
}
3182
3183
float4 ChromaticPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
3184
{
3185
	float gamma_in=1.0/texCD(JoNTSC_S08,float2(0.25,0.25)).a;
3186
	float lum=texCD(JoNTSC_S07,float2(0.5,0.5)).a;
3187
	float intera=texCD(JoNTSC_S08,float2(0.75,0.25)).a;
3188
	bool inter6=(intera<0.35&&interm==6.0);
3189
	bool interb=(((intera<0.35&&!inter6)||(no_scanlines>0.025))&&!hiscan);
3190
	float2 lexcoord=fuxcoord.xy;
3191
	if(IOS> 0.0&& !interb)
3192
	{
3193
	float2 ofactor= NewSize.xy/OrgSize.xy;
3194
	float2 ifactor=(IOS<2.5)? floor(ofactor):ceil(ofactor);
3195
	float2 diff=ofactor/ifactor;
3196
	float scan=diff.y;
3197
	lexcoord=overscan(lexcoord,scan,scan);
3198
	if(IOS==1.0||IOS==3.0) lexcoord=float2(fuxcoord.x,lexcoord.y);
3199
	}
3200
	float factor=1.0+(1.0-0.5*OS)*blm_2/100.0-lum*blm_2/100.0;
3201
	lexcoord=overscan(lexcoord,factor,factor);
3202
	lexcoord.y=lexcoord.y - VShift*OrgSize.w;
3203
	lexcoord=overscan(lexcoord,(OrgSize.x-overscanx)/OrgSize.x,(OrgSize.y-overscany)/OrgSize.y);
3204
	float2 pos0= warp(fuxcoord);
3205
	float2 pos1= fuxcoord;
3206
	float2 pos = warp(lexcoord);
3207
	float2 posb = 2.0*(pos0-0.5);
3208
	if (blm_2 < 0.5) posb = max(abs(posb), abs(2.0*(pos-0.5)))*sign(posb);
3209
	posb = 0.5*posb + 0.5;
3210
	float3 color=texCD(JoNTSC_S14,pos1).rgb;
3211
	float3 Bloom=texCD(JoNTSC_S13,pos ).rgb;
3212
	float3 Glow =texCD(JoNTSC_S11,pos ).rgb;
3213
	if((abs(deconrx)+abs(deconry)+abs(decongx)+abs(decongy)+abs(deconbx)+abs(deconby))>0.2) bring_pixel(color,Bloom,Glow,pos1,pos);
3214
	float cm=igc(max(max(color.r,color.g),color.b));
3215
	float mx1=texCD(JoNTSC_S14,pos1   ).a;
3216
	float colmx=max(mx1,cm);
3217
	float w3=min((max((cm-0.0005)*1.0005,0.0)+0.0001)/(colmx+0.0005),1.0);if(interb)w3=1.0;
3218
	float2 dx=float2(0.001,0.0);
3219
	float mx0=texCD(JoNTSC_S14,pos1-dx).a;
3220
	float mx2=texCD(JoNTSC_S14,pos1+dx).a;
3221
	float mxg=max(max(mx0,mx1),max(mx2,cm));
3222
	float mx=pow(mxg,1.40/gamma_in);
3223
	float cx=pow(colmx,1.40/gamma_in);
3224
	dx=float2(OrgSize.z,0.0)*0.25;
3225
	mx0=texCD(JoNTSC_S14,pos1-dx).a;
3226
	mx2=texCD(JoNTSC_S14,pos1+dx).a;
3227
	float mb=(1.0-min(abs(mx0-mx2)/(0.5+mx1),1.0));
3228
	float3 orig1=color;
3229
	float3 one=1.0;
3230
	float3 cmask=one;
3231
	float3 dmask=one;
3232
	float3 emask=one;
3233
	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};
3234
	float mwidth=mwidths[int(shadow_msk)];
3235
	float mask_compensate=frac(mwidth);
3236
	float mwidth0 = mwidth;
3237
	if(shadow_msk> -0.5)
3238
	{
3239
	float2 maskcoord= fracoord.xy+float2(laysh*masksize,0.0);
3240
	float2 scoord=maskcoord;
3241
	mwidth=floor(mwidth)*masksize;
3242
	float swidth=mwidth;
3243
	bool zoomed=(abs(mask_zoom)>0.75);
3244
	float mscale=1.0;
3245
	float2 maskcoord0=maskcoord;
3246
	maskcoord.y=floor(maskcoord.y/masksize);
3247
	mwidth0=max(mwidth+mask_zoom,2.0);
3248
	if( mshift> 0.25)
3249
	{
3250
	float stagg_lvl=1.0; if(frac(mshift)>0.25)stagg_lvl=2.0;
3251
	float next_line=float(floor(mod(maskcoord.y,2.0*stagg_lvl))<stagg_lvl);
3252
	maskcoord0.x=maskcoord0.x+next_line*0.5*mwidth0;
3253
	}
3254
	maskcoord=maskcoord0/masksize;
3255
	if(!zoomed)cmask=crt_mask(floor(maskcoord),mx,mb);else
3256
	{
3257
	mscale=mwidth0/mwidth;
3258
	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);
3259
3260
	float coord = floor(maskcoord.x/mscale);
3261
	if (shadow_msk == 12.0 && mask_zoom == -2.0) coord = ceil(maskcoord.x/mscale);
3262
	cmask = lerp(crt_mask(float2(coord,maskcoord.y), mx, mb), crt_mask(float2(coord + 1.0, maskcoord.y), mx, mb), clerp);
3263
	}
3264
	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);
3265
	if( zoomed)
3266
	{
3267
	if(mask_layout<0.5&&bsm_offset)sm_offset=1.0;else
3268
	if(bsm_offset)sm_offset=-1.0;
3269
	}
3270
	swidth=round(mwidth0); if (slotwidth > 0.5) swidth = slotwidth; float smask = 1.0;
3271
	smask =slt_mask(scoord+float2(sm_offset,0.0),mx,swidth);
3272
	smask =clamp(smask+lerp(smask_mit,0.0,w3*pow(colmx,0.3)),0.0,1.0);
3273
	emask =cmask;
3274
	cmask*=smask;
3275
	dmask =cmask;
3276
	if(abs(mask_bloom)>0.025)
3277
	{
3278
	float maxbl=max( max(max(Bloom.r,Bloom.g),Bloom.b),mxg);
3279
	maxbl=maxbl*max(lerp(1.0,2-colmx,bloom_dist),0.0);
3280
	if(mask_bloom>0.025) cmask= max(min(cmask +maxbl*mask_bloom,1),cmask); else
3281
	cmask=max(lerp(cmask,cmask*(1.0-0.5*maxbl)+plant(pow( Bloom,0.35.xxx),maxbl),-mask_bloom),cmask);
3282
	}
3283
	color=pow(color,mask_gamma/gamma_in);
3284
	color=color*cmask;
3285
	color=min(color,1.0);
3286
	color=pow(color,gamma_in/mask_gamma);
3287
	cmask=min(cmask,1.0);
3288
	dmask=min(dmask,1.0);
3289
	}
3290
	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;
3291
	float bb=lerp(brightboost1,brightboost2,mx)* dark_compensate; color*=bb;
3292
	float3 Ref=texCD(JoNTSC_S08,pos).rgb;
3293
	float maxb=texCD(JoNTSC_S13,pos).a;
3294
	float vig =texCD(JoNTSC_S02,clamp(pos,0.0+0.5*OrgSize.zw,1.0-0.5*OrgSize.zw)).a;
3295
	if(pr_scan > 0.025)
3296
	{
3297
		float mbl = max(max(Bloom.r,Bloom.g),Bloom.b);
3298
		Bloom = lerp(Bloom, lerp(Bloom, plant(orig1,mbl), min(2.5*(1.0-w3),1.0)), min(2.0*pr_scan, 1.0));
3299
	}	
3300
	float3 bcmask=lerp(one,dmask,b_mask);
3301
	float3 hcmask=lerp(one,dmask,h_mask);
3302
	float3 Bloomy=Bloom;
3303
	if(abs(blm_1)>0.025)
3304
	{
3305
	if(blm_1<-0.01)Bloomy=plant(Bloom,maxb);
3306
	Bloomy= min(Bloomy*(orig1+color),max(0.5*(colmx+orig1-color),0.001*Bloomy));
3307
	Bloomy=0.5*(Bloomy+lerp(Bloomy,lerp(colmx*orig1,Bloomy,0.5),1.0-color));
3308
	Bloomy= bcmask*Bloomy*max(lerp(1.0,2.0-colmx,bloom_dist),0);
3309
	color=pow(pow(color,mask_gamma/gamma_in)+abs(blm_1)*pow( Bloomy,mask_gamma/gamma_in),gamma_in/mask_gamma);
3310
	}
3311
	if(halation> 0.01)
3312
	{
3313
	Bloom= 0.5*(Bloom+Bloom*Bloom);float mbl=max(max(Bloom.r,Bloom.g),Bloom.b);float mxh=0.5*(colmx+colmx*colmx);
3314
	mbl=lerp(lerp(mxh,lerp( mxh,mbl,mbl),colmx),mbl,mb);
3315
	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);
3316
	Bloom=(3.0-colmx-color)*plant(0.325+orig1/w3,0.5*(1.0+w3))*hcmask*Bloom;
3317
	color=pow(pow(color,mask_gamma/gamma_in)+ halation *pow( Bloom ,mask_gamma/gamma_in),gamma_in/mask_gamma);
3318
	}else
3319
	if(halation<-0.01)
3320
	{
3321
	float mbl=max(max(Bloom.r,Bloom.g),Bloom.b);
3322
	Bloom=plant(Bloom+Ref+orig1+Bloom*Bloom*Bloom,min(mbl*mbl,0.75));
3323
	Bloom = 2.0*lerp(1.0,w3,0.5*colmx)*hcmask*Bloom;
3324
	color = color -halation*Bloom;
3325
	}
3326
	color=min(color,1.0);
3327
	color=gc2(color,w3 );
3328
	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);}
3329
	if(m_glow<0.5)Glow=lerp(Glow,0.25*color,colmx);else
3330
	{
3331
	float3 orig2=plant(orig1+0.001*Ref,1.0); maxb=max(max(Glow.r,Glow.g),Glow.b);
3332
	Bloom=plant(Glow,1.0);Ref=abs(orig2-Bloom);
3333
	mx0=max(max(orig2.r,orig2.g),orig2.b)-min(min(orig2.r,orig2.g),orig2.b);
3334
	mx2=max(max(Bloom.r,Bloom.g),Bloom.b)-min(min(Bloom.r,Bloom.g),Bloom.b);
3335
	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));
3336
	if(m_glow>1.5)Glow=lerp(0.5*Glow*Glow,Bloom,Bloom);
3337
	Glow=lerp(m_glow_low*Glow,m_glow_high*Bloom,pow(colmx,m_glow_dist/gamma_in));
3338
	}
3339
	if(m_glow<0.5)
3340
	{
3341
	if(glow >=0.0)color=color+0.5*Glow*glow;else color=color+abs(glow)*min(emask*emask,1.0)*Glow;}else
3342
	{
3343
	float3 fmask=clamp(lerp(one,dmask,m_glow_mask),0.0,1.0);
3344
	color=color+abs(glow)*fmask*Glow;
3345
	}
3346
	color=min(color,1.0);
3347
	if(edgemask>0.05)
3348
	{
3349
	mx0=texCD(JoNTSC_S14,pos1-dx).a;mx0=texCD(JoNTSC_S14,pos1-dx*(1.0-0.75*sqrt(mx0))).a;
3350
	mx2=texCD(JoNTSC_S14,pos1+dx).a;mx2=texCD(JoNTSC_S14,pos1+dx*(1.0-0.75*sqrt(mx2))).a;
3351
	float mx3=texCD(JoNTSC_S14,pos1-4.0*dx).a;
3352
	float mx4=texCD(JoNTSC_S14,pos1+4.0*dx).a;
3353
	mx4=max(pow(abs(mx3-mx4),0.55-0.40*cx),min(max(mx3,mx4)/min(0.1+cx,1.0),1.0));
3354
	mb=(1.0-abs(pow(mx0,1.0-0.65*mx2)-pow(mx2,1.0-0.65*mx0)));
3355
	mb=mx4*edgemask*(1.0001-mb*mb);float3 temp=lerp(color,orig1,mb);
3356
	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);
3357
	}
3358
	color=color* lerp(1.0,lerp(0.5*(1.0+w3),w3,mx),pr_scan);
3359
	color=min(color,max(orig1,color)*lerp(one,dmask,mclip));
3360
	color=pow(color,1.0/gamma_o);
3361
	float q=0.6*sqrt(max(max(color.r,color.g),color.b))+0.4;
3362
	if(abs(addnoised)>0.01)
3363
	{
3364
	float3 noise0=noise(float3(floor(NewSize.xy*fuxcoord/noiseresd),float(framecount)));
3365
	if(noisetype<0.5)color=lerp(color,noise0,0.25*abs(addnoised)*q);else
3366
	color=min(color* lerp(1.0,1.5*noise0.x,0.5*abs(addnoised)),1.0);
3367
	}
3368
	colmx=max(max(orig1.r,orig1.g),orig1.b);
3369
	color=color+bmask*lerp(emask,0.125*(1.0-colmx)*color,min(20.0*colmx,1.0));
3370
	return lerp(float4(color*vig*humbars(lerp(pos.y, pos.x, bardir))*post_br*corner(posb), 1.0), 
3371
	            texCD(JoNTSC_S0S, (floor(pos1*OrgSize.xy)+0.5)*OrgSize.zw), step(pos1.x,oimage-0.00025));
3372
}
3373
3374
float4 RatioSizePS(float4 position : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
3375
{
3376
    const bool margins=float(texcoord.x>=coord_w&&texcoord.x<=coord_e&&texcoord.y>=coord_n&&texcoord.y<=coord_s);
3377
    const float2 boxcoord=((texcoord-correct)*OptSize.xy+0)/BoxSize;
3378
    const float4 boxcolor=texCD(JoNTSC_S15,boxcoord);
3379
    const float4 orgcolor=texCD(JoNTSC_S00,texcoord);
3380
    return lerp(orgcolor,float4(margins*boxcolor.rgb,boxcolor.a),float(margins));
3381
}
3382
3383
technique JobimaCRT_guest_advancedV8
3384
{
3385
	pass StockPass
3386
	{
3387
	VertexShader=CropProcessVS;
3388
	PixelShader=StockPassPS;
3389
	RenderTarget=JoNTSC_T0S;
3390
	PrimitiveTopology=TRIANGLESTRIP;
3391
	VertexCount=4;
3392
	}
3393
	pass Afterglow
3394
	{
3395
	VertexShader=PostProcessVS;
3396
	PixelShader=AfterglowPS;
3397
	RenderTarget=JoNTSC_T01;
3398
	}
3399
	pass PreShader
3400
	{
3401
	VertexShader=PostProcessVS;
3402
	PixelShader=PreShaderPS;
3403
	RenderTarget=JoNTSC_T02;
3404
	}
3405
	pass Interlace
3406
	{
3407
	VertexShader=PostProcessVS;
3408
	PixelShader=InterlacePS;
3409
	RenderTarget=JoNTSC_T0I;
3410
	}
3411
	pass NTSCPASS1
3412
	{
3413
	VertexShader=PostProcessVS;
3414
	PixelShader=Signal_1_PS;
3415
	RenderTarget=JoNTSC_T03;
3416
	}
3417
	pass NTSCPASS2
3418
	{
3419
	VertexShader=PostProcessVS;
3420
	PixelShader=Signal_2_PS;
3421
	RenderTarget=JoNTSC_T04;
3422
	}
3423
	pass NTSCPASS3
3424
	{
3425
	VertexShader=PostProcessVS;
3426
	PixelShader=Signal_3_PS;
3427
	RenderTarget=JoNTSC_T05;
3428
	}
3429
	pass Sharpness
3430
	{
3431
	VertexShader=PostProcessVS;
3432
	PixelShader=SharpnessPS;
3433
	RenderTarget=JoNTSC_T06;
3434
	}
3435
	pass CRT_BlackCrush
3436
	{
3437
        VertexShader = PostProcessVS;
3438
        PixelShader  = PS_CRT_BlackCrush;
3439
        RenderTarget = JBCrsh_T01;
3440
	}
3441
	pass Luminance
3442
	{
3443-
	pass BCAvgLum
3443+
3444
	PixelShader=LuminancePS;
3445
	RenderTarget=JoNTSC_T07;
3446-
        PixelShader  = PS_CRT_BlackCrush_AvgLum;
3446+
3447
	pass Linearize
3448
	{
3449
	VertexShader=PostProcessVS;
3450
	PixelShader=LinearizeNewPS;
3451
	RenderTarget=JoNTSC_T08;
3452
	}
3453-
        RenderTarget = JBCrsh_T02;
3453+
3454
	{
3455
	VertexShader=PostProcessVS;
3456
	PixelShader=NTSC_TV1_PS;
3457
	RenderTarget=JoNTSC_T09;
3458
	}
3459
	pass GaussianX
3460
	{
3461
	VertexShader=PostProcessVS;
3462
	PixelShader=HGaussianPS;
3463
	RenderTarget=JoNTSC_T10;
3464
	}
3465
	pass GaussianY
3466
	{
3467
	VertexShader=PostProcessVS;
3468
	PixelShader=VGaussianPS;
3469
	RenderTarget=JoNTSC_T11;
3470
	}
3471
	pass BloomHorz
3472
	{
3473
	VertexShader=PostProcessVS;
3474
	PixelShader=BloomHorzPS;
3475
	RenderTarget=JoNTSC_T12;
3476
	}
3477
	pass BloomVert
3478
	{
3479
	VertexShader=PostProcessVS;
3480
	PixelShader=BloomVertPS;
3481
	RenderTarget=JoNTSC_T13;
3482
	}
3483
	pass CRT_Pass2
3484
	{
3485
	VertexShader=PostProcessVS;
3486
	PixelShader=NTSC_TV2_PS;
3487
	RenderTarget=JoNTSC_T14;
3488
	}
3489
	pass Chromatic
3490
	{
3491
	VertexShader=PostProcessVS;
3492
	PixelShader=ChromaticPS;
3493
	RenderTarget=JoNTSC_T15;
3494
	}
3495
	pass RatioSize
3496
	{
3497
	VertexShader=PostProcessVS;
3498
	PixelShader=RatioSizePS;
3499
	}
3500
}