Guest User

CRT-Guest-NTSC Aspect Ratio TEST

a guest
Jul 7th, 2025
161
0
Never
6
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 75.28 KB | None | 0 0
  1. /*
  2.  
  3. CRT - Guest - NTSC
  4.  
  5. Copyright (C) 2018-2025 guest(r)
  6.  
  7. Incorporates many good ideas and suggestions from Dr. Venom.
  8.  
  9. I would also like give thanks to many Libretro forums members for continuous feedback, suggestions and using the shader.
  10.  
  11. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
  12. as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
  13.  
  14. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  15. without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. See the GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License along with this program; if not,
  19. write to the Free Software Foundation, Inc, 59 Temple Place - STE 330, Boston, MA 02111-1307, USA.
  20.  
  21. Ported to ReShade by DevilSingh with some help from guest(r)
  22.  
  23. */
  24.  
  25. uniform float internal_res <
  26. ui_type = "drag";
  27. ui_min = 0.5;
  28. ui_max = 8.0;
  29. ui_step = 0.1;
  30. ui_label = "Internal Resolution";
  31. > = 1.0;
  32.  
  33. uniform float cust_artifacting <
  34. ui_type = "drag";
  35. ui_min = 0.0;
  36. ui_max = 5.0;
  37. ui_step = 0.1;
  38. ui_label = "NTSC Custom Artifacting Value";
  39. > = 1.0;
  40.  
  41. uniform float cust_fringing <
  42. ui_type = "drag";
  43. ui_min = 0.0;
  44. ui_max = 5.0;
  45. ui_step = 0.1;
  46. ui_label = "NTSC Custom Fringing Value";
  47. > = 1.0;
  48.  
  49. uniform float ntsc_fields <
  50. ui_type = "drag";
  51. ui_min = 1.0;
  52. ui_max = 3.0;
  53. ui_step = 1.0;
  54. ui_label = "NTSC Merge Fields: Auto | No | Yes";
  55. > = 1.0;
  56.  
  57. uniform float ntsc_phase <
  58. ui_type = "drag";
  59. ui_min = 1.0;
  60. ui_max = 4.0;
  61. ui_step = 1.0;
  62. ui_label = "NTSC Phase: Auto | 2 Phase | 3 Phase | Mixed";
  63. > = 1.0;
  64.  
  65. uniform float ntsc_scale <
  66. ui_type = "drag";
  67. ui_min = 0.2;
  68. ui_max = 2.5;
  69. ui_step = 0.025;
  70. ui_label = "NTSC Resolution Scaling";
  71. > = 1.0;
  72.  
  73. uniform float ntsc_taps <
  74. ui_type = "drag";
  75. ui_min = 6.0;
  76. ui_max = 32.0;
  77. ui_step = 1.0;
  78. ui_label = "NTSC # of Taps (Filter Width)";
  79. > = 32.0;
  80.  
  81. uniform float ntsc_cscale1 <
  82. ui_type = "drag";
  83. ui_min = 0.5;
  84. ui_max = 4.00;
  85. ui_step = 0.05;
  86. ui_label = "NTSC Chroma Scaling/Bleeding (2 Phase)";
  87. > = 1.0;
  88.  
  89. uniform float ntsc_cscale2 <
  90. ui_type = "drag";
  91. ui_min = 0.2;
  92. ui_max = 2.25;
  93. ui_step = 0.05;
  94. ui_label = "NTSC Chroma Scaling/Bleeding (3 Phase)";
  95. > = 1.0;
  96.  
  97. uniform float ntsc_sat <
  98. ui_type = "drag";
  99. ui_min = 0.0;
  100. ui_max = 2.0;
  101. ui_step = 0.01;
  102. ui_label = "NTSC Color Saturation";
  103. > = 1.0;
  104.  
  105. uniform float ntsc_brt <
  106. ui_type = "drag";
  107. ui_min = 0.0;
  108. ui_max = 1.5;
  109. ui_step = 0.01;
  110. ui_label = "NTSC Brightness";
  111. > = 1.0;
  112.  
  113. uniform float ntsc_gamma <
  114. ui_type = "drag";
  115. ui_min = 0.25;
  116. ui_max = 2.5;
  117. ui_step = 0.025;
  118. ui_label = "NTSC Filtering Gamma Correction";
  119. > = 1.0;
  120.  
  121. uniform float ntsc_rainbow <
  122. ui_type = "drag";
  123. ui_min = 0.0;
  124. ui_max = 3.0;
  125. ui_step = 1.0;
  126. ui_label = "NTSC Coloring/Rainbow Effect (2 Phase)";
  127. > = 0.0;
  128.  
  129. uniform float ntsc_ring <
  130. ui_type = "drag";
  131. ui_min = 0.0;
  132. ui_max = 1.0;
  133. ui_step = 0.1;
  134. ui_label = "NTSC Anti-Ringing";
  135. > = 0.5;
  136.  
  137. uniform float ntsc_shrp <
  138. ui_type = "drag";
  139. ui_min = -10.0;
  140. ui_max = 10.0;
  141. ui_step = 0.5;
  142. ui_label = "NTSC Sharpness (Adaptive)";
  143. > = 0.0;
  144.  
  145. uniform float ntsc_shpe <
  146. ui_type = "drag";
  147. ui_min = 0.5;
  148. ui_max = 1.0;
  149. ui_step = 0.025;
  150. ui_label = "NTSC Sharpness Shape";
  151. > = 0.8;
  152.  
  153. uniform float ntsc_charp1 <
  154. ui_type = "drag";
  155. ui_min = 0.0;
  156. ui_max = 10.0;
  157. ui_step = 0.5;
  158. ui_label = "NTSC Preserve 'Edge' Colors (2 Phase)";
  159. > = 0.0;
  160.  
  161. uniform float ntsc_charp2 <
  162. ui_type = "drag";
  163. ui_min = 0.0;
  164. ui_max = 10.0;
  165. ui_step = 0.5;
  166. ui_label = "NTSC Preserve 'Edge' Colors (3 Phase)";
  167. > = 0.0;
  168.  
  169. uniform float CSHARPEN <
  170. ui_type = "drag";
  171. ui_min = 0.0;
  172. ui_max = 5.0;
  173. ui_step = 0.1;
  174. ui_label = "FSharpen - Sharpen Strength";
  175. > = 0.0;
  176.  
  177. uniform float CCONTR <
  178. ui_type = "drag";
  179. ui_min = 0.0;
  180. ui_max = 0.25;
  181. ui_step = 0.01;
  182. ui_label = "FSharpen - Sharpen (+ Deblur) Contrast";
  183. > = 0.05;
  184.  
  185. uniform float CDETAILS <
  186. ui_type = "drag";
  187. ui_min = 0.0;
  188. ui_max = 1.0;
  189. ui_step = 0.05;
  190. ui_label = "FSharpen - Sharpen Details";
  191. > = 1.0;
  192.  
  193. uniform float DEBLUR <
  194. ui_type = "drag";
  195. ui_min = 1.0;
  196. ui_max = 7.0;
  197. ui_step = 0.25;
  198. ui_label = "FSharpen - Deblur Strength";
  199. > = 1.0;
  200.  
  201. uniform float DREDGE <
  202. ui_type = "drag";
  203. ui_min = 0.7;
  204. ui_max = 1.0;
  205. ui_step = 0.01;
  206. ui_label = "FSharpen - Deblur Edges Falloff";
  207. > = 0.9;
  208.  
  209. uniform float DSHARP <
  210. ui_type = "drag";
  211. ui_min = 0.0;
  212. ui_max = 4.0;
  213. ui_step = 0.2;
  214. ui_label = "FSharpen - Deblur Extra Sharpen";
  215. > = 0.0;
  216.  
  217. uniform float PR <
  218. ui_type = "drag";
  219. ui_min = 0.0;
  220. ui_max = 0.5;
  221. ui_step = 0.01;
  222. ui_label = "Persistence 'R'";
  223. > = 0.32;
  224.  
  225. uniform float PG <
  226. ui_type = "drag";
  227. ui_min = 0.0;
  228. ui_max = 0.5;
  229. ui_step = 0.01;
  230. ui_label = "Persistence 'G'";
  231. > = 0.32;
  232.  
  233. uniform float PB <
  234. ui_type = "drag";
  235. ui_min = 0.0;
  236. ui_max = 0.5;
  237. ui_step = 0.01;
  238. ui_label = "Persistence 'B'";
  239. > = 0.32;
  240.  
  241. uniform float AS <
  242. ui_type = "drag";
  243. ui_min = 0.0;
  244. ui_max = 0.6;
  245. ui_step = 0.01;
  246. ui_label = "Afterglow Strength";
  247. > = 0.2;
  248.  
  249. uniform float ST <
  250. ui_type = "drag";
  251. ui_min = 0.0;
  252. ui_max = 1.0;
  253. ui_step = 0.01;
  254. ui_label = "Afterglow Saturation";
  255. > = 0.5;
  256.  
  257. uniform float CS <
  258. ui_type = "drag";
  259. ui_min = 0.0;
  260. ui_max = 4.0;
  261. ui_step = 1.0;
  262. ui_label = "Display Gamut: sRGB | Modern | DCI | Adobe | Rec. 2020";
  263. > = 0.0;
  264.  
  265. uniform float CP <
  266. ui_type = "drag";
  267. ui_min = -1.0;
  268. ui_max = 5.0;
  269. ui_step = 1.0;
  270. ui_label = "CRT Profile: EBU | P22 | SMPTE-C | Philips | Trinitron";
  271. > = 0.0;
  272.  
  273. uniform float TNTC <
  274. ui_type = "drag";
  275. ui_min = 0.0;
  276. ui_max = 4.0;
  277. ui_step = 1.0;
  278. ui_label = "LUT Colors: Trinitron 1 | Trinitron 2 | Nec MultiSync | NTSC";
  279. > = 0.0;
  280.  
  281. uniform float LUTLOW <
  282. ui_type = "drag";
  283. ui_min = 0.0;
  284. ui_max = 50.0;
  285. ui_step = 1.0;
  286. ui_label = "Fix LUT Dark Range";
  287. > = 5.0;
  288.  
  289. uniform float LUTBR <
  290. ui_type = "drag";
  291. ui_min = 0.0;
  292. ui_max = 1.0;
  293. ui_step = 0.01;
  294. ui_label = "Fix LUT Brightness";
  295. > = 1.0;
  296.  
  297. uniform float WP <
  298. ui_type = "drag";
  299. ui_min = -100.0;
  300. ui_max = 100.0;
  301. ui_step = 5.0;
  302. ui_label = "Color Temperature %";
  303. > = 0.0;
  304.  
  305. uniform float wp_saturation <
  306. ui_type = "drag";
  307. ui_min = 0.0;
  308. ui_max = 2.0;
  309. ui_step = 0.05;
  310. ui_label = "Saturation Adjustment";
  311. > = 1.0;
  312.  
  313. uniform float pre_bb <
  314. ui_type = "drag";
  315. ui_min = 0.0;
  316. ui_max = 2.0;
  317. ui_step = 0.01;
  318. ui_label = "Brightness Adjustment";
  319. > = 1.0;
  320.  
  321. uniform float contra <
  322. ui_type = "drag";
  323. ui_min = -2.0;
  324. ui_max = 2.0;
  325. ui_step = 0.05;
  326. ui_label = "Contrast Adjustment";
  327. > = 0.0;
  328.  
  329. uniform float sega_fix <
  330. ui_type = "drag";
  331. ui_min = 0.0;
  332. ui_max = 1.0;
  333. ui_step = 1.0;
  334. ui_label = "Sega Brightness Fix";
  335. > = 0.0;
  336.  
  337. uniform float BP <
  338. ui_type = "drag";
  339. ui_min = -100.0;
  340. ui_max = 25.0;
  341. ui_step = 1.0;
  342. ui_label = "Raise Black Level";
  343. > = 0.0;
  344.  
  345. uniform float vigstr <
  346. ui_type = "drag";
  347. ui_min = 0.0;
  348. ui_max = 2.0;
  349. ui_step = 0.05;
  350. ui_label = "Vignette Strength";
  351. > = 0.0;
  352.  
  353. uniform float vigdef <
  354. ui_type = "drag";
  355. ui_min = 0.5;
  356. ui_max = 3.0;
  357. ui_step = 0.1;
  358. ui_label = "Vignette Size";
  359. > = 1.0;
  360.  
  361. uniform float lsmooth <
  362. ui_type = "drag";
  363. ui_min = 0.5;
  364. ui_max = 1.0;
  365. ui_step = 0.01;
  366. ui_label = "Raster Bloom Effect Smoothing";
  367. > = 0.7;
  368.  
  369. uniform float gamma_i <
  370. ui_type = "drag";
  371. ui_min = 1.0;
  372. ui_max = 5.0;
  373. ui_step = 0.05;
  374. ui_label = "Gamma Input";
  375. > = 2.00;
  376.  
  377. uniform float gamma_o <
  378. ui_type = "drag";
  379. ui_min = 1.0;
  380. ui_max = 5.0;
  381. ui_step = 0.05;
  382. ui_label = "Gamma Out";
  383. > = 1.95;
  384.  
  385. uniform float interr <
  386. ui_type = "drag";
  387. ui_min = 0.0;
  388. ui_max = 800.0;
  389. ui_step = 25.0;
  390. ui_label = "Interlace Trigger Resolution";
  391. > = 400.0;
  392.  
  393. uniform float interm <
  394. ui_type = "drag";
  395. ui_min = 0.0;
  396. ui_max = 5.0;
  397. ui_step = 1.0;
  398. ui_label = "Interlace Mode: 0:OFF | 1-3:Normal | 4-5:Interpolation";
  399. > = 4.0;
  400.  
  401. uniform float iscanb <
  402. ui_type = "drag";
  403. ui_min = 0.0;
  404. ui_max = 1.0;
  405. ui_step = 0.05;
  406. ui_label = "Interlacing Scanlines Effect (Interlaced Brightness)";
  407. > = 0.2;
  408.  
  409. uniform float iscans <
  410. ui_type = "drag";
  411. ui_min = 0.0;
  412. ui_max = 1.0;
  413. ui_step = 0.05;
  414. ui_label = "Interlacing Scanlines Saturation";
  415. > = 0.25;
  416.  
  417. uniform float hiscan <
  418. ui_type = "drag";
  419. ui_min = 0.0;
  420. ui_max = 1.0;
  421. ui_step = 1.0;
  422. ui_label = "High Resolution Scanlines (Prepend A Scaler)";
  423. > = 0.0;
  424.  
  425. uniform float intres <
  426. ui_type = "drag";
  427. ui_min = 0.0;
  428. ui_max = 10.0;
  429. ui_step = 0.5;
  430. ui_label = "Internal Resolution Y: 0.5 | Y-Dowsample";
  431. > = 0.0;
  432.  
  433. uniform float downsample_levelx <
  434. ui_type = "drag";
  435. ui_min = 0.0;
  436. ui_max = 2.0;
  437. ui_step = 0.05;
  438. ui_label = "Downsampling-X (High-Res Content, Pre-Scalers)";
  439. > = 0.0;
  440.  
  441. uniform float downsample_levely <
  442. ui_type = "drag";
  443. ui_min = 0.0;
  444. ui_max = 2.0;
  445. ui_step = 0.05;
  446. ui_label = "Downsampling-Y (High-Res Content, Pre-Scalers)";
  447. > = 0.0;
  448.  
  449. uniform float HSHARPNESS <
  450. ui_type = "drag";
  451. ui_min = 1.0;
  452. ui_max = 8.0;
  453. ui_step = 0.05;
  454. ui_label = "Horizontal Filter Range";
  455. > = 1.6;
  456.  
  457. uniform float LIGMA_H <
  458. ui_type = "drag";
  459. ui_min = 0.1;
  460. ui_max = 7.0;
  461. ui_step = 0.025;
  462. ui_label = "Horizontal Blur Sigma";
  463. > = 0.8;
  464.  
  465. uniform float S_SHARP <
  466. ui_type = "drag";
  467. ui_min = 0.0;
  468. ui_max = 3.0;
  469. ui_step = 0.05;
  470. ui_label = "Substractive Sharpness";
  471. > = 1.1;
  472.  
  473. uniform float SHARP <
  474. ui_type = "drag";
  475. ui_min = 0.0;
  476. ui_max = 2.0;
  477. ui_step = 0.1;
  478. ui_label = "Sharpness Definition";
  479. > = 1.2;
  480.  
  481. uniform float MAXS <
  482. ui_type = "drag";
  483. ui_min = 0.0;
  484. ui_max = 0.3;
  485. ui_step = 0.01;
  486. ui_label = "Maximum Sharpness";
  487. > = 0.18;
  488.  
  489. uniform float SSRNG <
  490. ui_type = "drag";
  491. ui_min = 0.0;
  492. ui_max = 4.0;
  493. ui_step = 0.05;
  494. ui_label = "Substractive Sharpness Ringing";
  495. > = 0.3;
  496.  
  497. uniform float m_glow <
  498. ui_type = "drag";
  499. ui_min = 0.0;
  500. ui_max = 2.0;
  501. ui_step = 1.0;
  502. ui_label = "Ordinary Glow | Magic Glow";
  503. > = 0.0;
  504.  
  505. uniform float m_glow_cutoff <
  506. ui_type = "drag";
  507. ui_min = 0.0;
  508. ui_max = 0.4;
  509. ui_step = 0.01;
  510. ui_label = "Magic Glow Cutoff";
  511. > = 0.12;
  512.  
  513. uniform float m_glow_low <
  514. ui_type = "drag";
  515. ui_min = 0.0;
  516. ui_max = 7.0;
  517. ui_step = 0.05;
  518. ui_label = "Magic Glow Low Strength";
  519. > = 0.35;
  520.  
  521. uniform float m_glow_high <
  522. ui_type = "drag";
  523. ui_min = 0.0;
  524. ui_max = 7.0;
  525. ui_step = 0.1;
  526. ui_label = "Magic Glow High Strength";
  527. > = 5.0;
  528.  
  529. uniform float m_glow_dist <
  530. ui_type = "drag";
  531. ui_min = 0.2;
  532. ui_max = 4.0;
  533. ui_step = 0.05;
  534. ui_label = "Magic Glow Distribution";
  535. > = 1.0;
  536.  
  537. uniform float m_glow_mask <
  538. ui_type = "drag";
  539. ui_min = 0.0;
  540. ui_max = 2.0;
  541. ui_step = 0.025;
  542. ui_label = "Magic Glow Mask Strength";
  543. > = 1.0;
  544.  
  545. uniform float FINE_GAUSS <
  546. ui_type = "drag";
  547. ui_min = -1.0;
  548. ui_max = 5.0;
  549. ui_step = 1.0;
  550. ui_label = "Fine (Magic) Glow Sampling";
  551. > = 1.0;
  552.  
  553. uniform float SIZEH <
  554. ui_type = "drag";
  555. ui_min = 1.0;
  556. ui_max = 50.0;
  557. ui_step = 1.0;
  558. ui_label = "Horizontal Glow Radius";
  559. > = 6.0;
  560.  
  561. uniform float SIGMA_H <
  562. ui_type = "drag";
  563. ui_min = 0.2;
  564. ui_max = 15.0;
  565. ui_step = 0.05;
  566. ui_label = "Horizontal Glow Sigma";
  567. > = 1.2;
  568.  
  569. uniform float SIZEV <
  570. ui_type = "drag";
  571. ui_min = 1.0;
  572. ui_max = 50.0;
  573. ui_step = 1.0;
  574. ui_label = "Vertical Glow Radius";
  575. > = 6.0;
  576.  
  577. uniform float SIGMA_V <
  578. ui_type = "drag";
  579. ui_min = 0.2;
  580. ui_max = 15.0;
  581. ui_step = 0.05;
  582. ui_label = "Vertical Glow Sigma";
  583. > = 1.2;
  584.  
  585. uniform float FINE_BLOOM <
  586. ui_type = "drag";
  587. ui_min = -1.0;
  588. ui_max = 5.0;
  589. ui_step = 1.0;
  590. ui_label = "Fine Bloom/Halation Sampling";
  591. > = 1.0;
  592.  
  593. uniform float SIZEX <
  594. ui_type = "drag";
  595. ui_min = 1.0;
  596. ui_max = 50.0;
  597. ui_step = 1.0;
  598. ui_label = "Horizontal Bloom/Halation Radius";
  599. > = 3.0;
  600.  
  601. uniform float SIGMA_X <
  602. ui_type = "drag";
  603. ui_min = 0.25;
  604. ui_max = 15.0;
  605. ui_step = 0.025;
  606. ui_label = "Horizontal Bloom/Halation Sigma";
  607. > = 0.75;
  608.  
  609. uniform float SIZEY <
  610. ui_type = "drag";
  611. ui_min = 1.0;
  612. ui_max = 50.0;
  613. ui_step = 1.0;
  614. ui_label = "Vertical Bloom/Halation Radius";
  615. > = 3.0;
  616.  
  617. uniform float SIGMA_Y <
  618. ui_type = "drag";
  619. ui_min = 0.25;
  620. ui_max = 15.0;
  621. ui_step = 0.025;
  622. ui_label = "Vertical Bloom/Halation Sigma";
  623. > = 0.60;
  624.  
  625. uniform float glow <
  626. ui_type = "drag";
  627. ui_min = -2.0;
  628. ui_max = 2.0;
  629. ui_step = 0.01;
  630. ui_label = "(Magic) Glow Strength";
  631. > = 0.08;
  632.  
  633. uniform float blm_1 <
  634. ui_type = "drag";
  635. ui_min = -2.0;
  636. ui_max = 2.0;
  637. ui_step = 0.05;
  638. ui_label = "Bloom Strength";
  639. > = 0.0;
  640.  
  641. uniform float b_mask <
  642. ui_type = "drag";
  643. ui_min = -1.0;
  644. ui_max = 1.0;
  645. ui_step = 0.025;
  646. ui_label = "Bloom Mask Strength";
  647. > = 0.0;
  648.  
  649. uniform float mask_bloom <
  650. ui_type = "drag";
  651. ui_min = -2.0;
  652. ui_max = 2.0;
  653. ui_step = 0.05;
  654. ui_label = "Mask Bloom";
  655. > = 0.0;
  656.  
  657. uniform float bloom_dist <
  658. ui_type = "drag";
  659. ui_min = -2.0;
  660. ui_max = 3.0;
  661. ui_step = 0.05;
  662. ui_label = "Bloom Distribution";
  663. > = 0.0;
  664.  
  665. uniform float halation <
  666. ui_type = "drag";
  667. ui_min = -2.0;
  668. ui_max = 2.0;
  669. ui_step = 0.025;
  670. ui_label = "Halation Strength";
  671. > = 0.0;
  672.  
  673. uniform float h_mask <
  674. ui_type = "drag";
  675. ui_min = -1.0;
  676. ui_max = 1.0;
  677. ui_step = 0.025;
  678. ui_label = "Halation Mask Strength";
  679. > = 0.5;
  680.  
  681. uniform float gamma_c <
  682. ui_type = "drag";
  683. ui_min = 0.5;
  684. ui_max = 2.0;
  685. ui_step = 0.025;
  686. ui_label = "Gamma Correct";
  687. > = 1.0;
  688.  
  689. uniform float gamma_d <
  690. ui_type = "drag";
  691. ui_min = 1.0;
  692. ui_max = 2.0;
  693. ui_step = 0.025;
  694. ui_label = "Complementary Gamma Correct";
  695. > = 1.0;
  696.  
  697. uniform float brightboost1 <
  698. ui_type = "drag";
  699. ui_min = 0.25;
  700. ui_max = 10.0;
  701. ui_step = 0.05;
  702. ui_label = "Bright Boost Dark Pixels";
  703. > = 1.4;
  704.  
  705. uniform float brightboost2 <
  706. ui_type = "drag";
  707. ui_min = 0.25;
  708. ui_max = 3.0;
  709. ui_step = 0.025;
  710. ui_label = "Bright Boost Bright Pixels";
  711. > = 1.1;
  712.  
  713. uniform float clp <
  714. ui_type = "drag";
  715. ui_min = -1.0;
  716. ui_max = 1.0;
  717. ui_step = 0.05;
  718. ui_label = "Clip Saturated Color Beams";
  719. > = 0.0;
  720.  
  721. uniform float gsl <
  722. ui_type = "drag";
  723. ui_min = -1.0;
  724. ui_max = 2.0;
  725. ui_step = 1.0;
  726. ui_label = "Scanlines Type";
  727. > = 0.0;
  728.  
  729. uniform float scanline1 <
  730. ui_type = "drag";
  731. ui_min = -20.0;
  732. ui_max = 40.0;
  733. ui_step = 0.5;
  734. ui_label = "Scanlines Beam Shape Center";
  735. > = 6.0;
  736.  
  737. uniform float scanline2 <
  738. ui_type = "drag";
  739. ui_min = 0.0;
  740. ui_max = 70.0;
  741. ui_step = 1.0;
  742. ui_label = "Scanlines Beam Shape Edges";
  743. > = 8.0;
  744.  
  745. uniform float beam_min <
  746. ui_type = "drag";
  747. ui_min = 0.25;
  748. ui_max = 10.0;
  749. ui_step = 0.05;
  750. ui_label = "Scanlines Shape Dark Pixels";
  751. > = 1.3;
  752.  
  753. uniform float beam_max <
  754. ui_type = "drag";
  755. ui_min = 0.2;
  756. ui_max = 3.5;
  757. ui_step = 0.025;
  758. ui_label = "Scanlines Shape Bright Pixels";
  759. > = 1.0;
  760.  
  761. uniform float tds <
  762. ui_type = "drag";
  763. ui_min = 0.0;
  764. ui_max = 1.0;
  765. ui_step = 1.0;
  766. ui_label = "Thinner Dark Scanlines";
  767. > = 0.0;
  768.  
  769. uniform float beam_size <
  770. ui_type = "drag";
  771. ui_min = 0.0;
  772. ui_max = 1.0;
  773. ui_step = 0.05;
  774. ui_label = "Increased Bright Scanlines Beam";
  775. > = 0.6;
  776.  
  777. uniform float scans <
  778. ui_type = "drag";
  779. ui_min = 0.0;
  780. ui_max = 6.0;
  781. ui_step = 0.1;
  782. ui_label = "Scanlines Saturation / Mask Falloff";
  783. > = 0.5;
  784.  
  785. uniform float scan_falloff <
  786. ui_type = "drag";
  787. ui_min = 0.1;
  788. ui_max = 2.0;
  789. ui_step = 0.025;
  790. ui_label = "Scanlines Falloff";
  791. > = 1.0;
  792.  
  793. uniform float spike <
  794. ui_type = "drag";
  795. ui_min = 0.0;
  796. ui_max = 2.0;
  797. ui_step = 0.1;
  798. ui_label = "Scanlines Spike Removal";
  799. > = 1.0;
  800.  
  801. uniform float scangamma <
  802. ui_type = "drag";
  803. ui_min = 0.5;
  804. ui_max = 5.0;
  805. ui_step = 0.05;
  806. ui_label = "Scanlines Gamma";
  807. > = 2.4;
  808.  
  809. uniform float rolling_scan <
  810. ui_type = "drag";
  811. ui_min = -1.0;
  812. ui_max = 1.0;
  813. ui_step = 0.01;
  814. ui_label = "Rolling Scanlines";
  815. > = 0.0;
  816.  
  817. uniform float no_scanlines <
  818. ui_type = "drag";
  819. ui_min = 0.0;
  820. ui_max = 1.5;
  821. ui_step = 0.05;
  822. ui_label = "No-Scanlines Mode";
  823. > = 0.0;
  824.  
  825. uniform float IOS <
  826. ui_type = "drag";
  827. ui_min = 0.0;
  828. ui_max = 4.0;
  829. ui_step = 1.0;
  830. ui_label = "Integer Scaling: Odd:Y | Even:X+Y";
  831. > = 0.0;
  832.  
  833. uniform float OS <
  834. ui_type = "drag";
  835. ui_min = 0.0;
  836. ui_max = 2.0;
  837. ui_step = 1.0;
  838. ui_label = "Raster Bloom Overscan Mode";
  839. > = 1.0;
  840.  
  841. uniform float blm_2 <
  842. ui_type = "drag";
  843. ui_min = 0.0;
  844. ui_max = 20.0;
  845. ui_step = 1.0;
  846. ui_label = "Raster Bloom %";
  847. > = 0.0;
  848.  
  849. uniform float csize <
  850. ui_type = "drag";
  851. ui_min = 0.0;
  852. ui_max = 0.35;
  853. ui_step = 0.01;
  854. ui_label = "Corner Size";
  855. > = 0.0;
  856.  
  857. uniform float bsize <
  858. ui_type = "drag";
  859. ui_min = 0.0;
  860. ui_max = 2.0;
  861. ui_step = 0.01;
  862. ui_label = "Border Size";
  863. > = 0.0;
  864.  
  865. uniform float sborder <
  866. ui_type = "drag";
  867. ui_min = 0.25;
  868. ui_max = 2.0;
  869. ui_step = 0.05;
  870. ui_label = "Border Intensity";
  871. > = 0.75;
  872.  
  873. uniform float barspeed <
  874. ui_type = "drag";
  875. ui_min = 5.0;
  876. ui_max = 200.0;
  877. ui_step = 1.0;
  878. ui_label = "Hum Bar Speed";
  879. > = 50.0;
  880.  
  881. uniform float barintensity <
  882. ui_type = "drag";
  883. ui_min = -1.0;
  884. ui_max = 1.0;
  885. ui_step = 0.01;
  886. ui_label = "Hum Bar Intensity";
  887. > = 0.0;
  888.  
  889. uniform float bardir <
  890. ui_type = "drag";
  891. ui_min = 0.0;
  892. ui_max = 1.0;
  893. ui_step = 1.0;
  894. ui_label = "Hum Bar Direction";
  895. > = 0.0;
  896.  
  897. uniform float warpx <
  898. ui_type = "drag";
  899. ui_min = 0.0;
  900. ui_max = 0.25;
  901. ui_step = 0.01;
  902. ui_label = "Curvature X (Default 0.03)";
  903. > = 0.0;
  904.  
  905. uniform float warpy <
  906. ui_type = "drag";
  907. ui_min = 0.0;
  908. ui_max = 0.25;
  909. ui_step = 0.01;
  910. ui_label = "Curvature Y (Default 0.04)";
  911. > = 0.0;
  912.  
  913. uniform float c_shape <
  914. ui_type = "drag";
  915. ui_min = 0.05;
  916. ui_max = 0.6;
  917. ui_step = 0.05;
  918. ui_label = "Curvature Shape";
  919. > = 0.25;
  920.  
  921. uniform float overscanx <
  922. ui_type = "drag";
  923. ui_min = -200.0;
  924. ui_max = 200.0;
  925. ui_step = 1.0;
  926. ui_label = "Overscan X Original Pixels";
  927. > = 0.0;
  928.  
  929. uniform float overscany <
  930. ui_type = "drag";
  931. ui_min = -200.0;
  932. ui_max = 200.0;
  933. ui_step = 1.0;
  934. ui_label = "Overscan Y Original Pixels";
  935. > = 0.0;
  936.  
  937. uniform float shadow_msk <
  938. ui_type = "drag";
  939. ui_min = 0.0;
  940. ui_max = 14.0;
  941. ui_step = 1.0;
  942. ui_label = "CRT Mask: 1:CGWG | 2-5:Lottes | 6-14:Trinitron";
  943. > = 1.0;
  944.  
  945. uniform float maskstr <
  946. ui_type = "drag";
  947. ui_min = -0.5;
  948. ui_max = 1.0;
  949. ui_step = 0.025;
  950. ui_label = "Mask Strength (1, 6-14)";
  951. > = 0.3;
  952.  
  953. uniform float mcut <
  954. ui_type = "drag";
  955. ui_min = 0.0;
  956. ui_max = 2.0;
  957. ui_step = 0.05;
  958. ui_label = "Mask 6-14 Low Strength";
  959. > = 1.1;
  960.  
  961. uniform float maskboost <
  962. ui_type = "drag";
  963. ui_min = 1.0;
  964. ui_max = 3.0;
  965. ui_step = 0.05;
  966. ui_label = "CRT Mask Boost";
  967. > = 1.0;
  968.  
  969. uniform float masksize <
  970. ui_type = "drag";
  971. ui_min = 1.0;
  972. ui_max = 4.0;
  973. ui_step = 1.0;
  974. ui_label = "CRT Mask Size";
  975. > = 1.0;
  976.  
  977. uniform float mask_zoom <
  978. ui_type = "drag";
  979. ui_min = -10.0;
  980. ui_max = 6.0;
  981. ui_step = 1.0;
  982. ui_label = "CRT Mask Zoom (+ Mask Width)";
  983. > = 0.0;
  984.  
  985. uniform float zoom_mask <
  986. ui_type = "drag";
  987. ui_min = 0.0;
  988. ui_max = 1.0;
  989. ui_step = 0.05;
  990. ui_label = "CRT Mask Zoom Sharpen";
  991. > = 0.0;
  992.  
  993. uniform float mshift <
  994. ui_type = "drag";
  995. ui_min = 0.0;
  996. ui_max = 1.0;
  997. ui_step = 0.5;
  998. ui_label = "(Transform to) Shadow Mask";
  999. > = 0.0;
  1000.  
  1001. uniform float mask_layout <
  1002. ui_type = "drag";
  1003. ui_min = 0.0;
  1004. ui_max = 1.0;
  1005. ui_step = 1.0;
  1006. ui_label = "Mask Layout: RGB or BGR (Check LCD Panel)";
  1007. > = 0.0;
  1008.  
  1009. uniform float mask_drk <
  1010. ui_type = "drag";
  1011. ui_min = 0.0;
  1012. ui_max = 2.0;
  1013. ui_step = 0.05;
  1014. ui_label = "Lottes Mask Dark";
  1015. > = 0.5;
  1016.  
  1017. uniform float mask_lgt <
  1018. ui_type = "drag";
  1019. ui_min = 0.0;
  1020. ui_max = 2.0;
  1021. ui_step = 0.05;
  1022. ui_label = "Lottes Mask Bright";
  1023. > = 1.5;
  1024.  
  1025. uniform float mask_gamma <
  1026. ui_type = "drag";
  1027. ui_min = 1.0;
  1028. ui_max = 5.0;
  1029. ui_step = 0.05;
  1030. ui_label = "Mask Gamma";
  1031. > = 2.4;
  1032.  
  1033. uniform float slotmask1 <
  1034. ui_type = "drag";
  1035. ui_min = 0.0;
  1036. ui_max = 1.0;
  1037. ui_step = 0.05;
  1038. ui_label = "Slot Mask Strength Bright Pixels";
  1039. > = 0.0;
  1040.  
  1041. uniform float slotmask2 <
  1042. ui_type = "drag";
  1043. ui_min = 0.0;
  1044. ui_max = 1.0;
  1045. ui_step = 0.05;
  1046. ui_label = "Slot Mask Strength Dark Pixels";
  1047. > = 0.0;
  1048.  
  1049. uniform float slotwidth <
  1050. ui_type = "drag";
  1051. ui_min = 0.0;
  1052. ui_max = 16.0;
  1053. ui_step = 1.0;
  1054. ui_label = "Slot Mask Width (0:Auto)";
  1055. > = 0.0;
  1056.  
  1057. uniform float double_slot <
  1058. ui_type = "drag";
  1059. ui_min = 1.0;
  1060. ui_max = 4.0;
  1061. ui_step = 1.0;
  1062. ui_label = "Slot Mask Height: 2x1 or 4x1";
  1063. > = 2.0;
  1064.  
  1065. uniform float slotms <
  1066. ui_type = "drag";
  1067. ui_min = 1.0;
  1068. ui_max = 4.0;
  1069. ui_step = 1.0;
  1070. ui_label = "Slot Mask Thickness";
  1071. > = 1.0;
  1072.  
  1073. uniform float smoothmask <
  1074. ui_type = "drag";
  1075. ui_min = 0.0;
  1076. ui_max = 2.0;
  1077. ui_step = 0.25;
  1078. ui_label = "Smooth Masks In Bright Scanlines";
  1079. > = 0.0;
  1080.  
  1081. uniform float smask_mit <
  1082. ui_type = "drag";
  1083. ui_min = 0.0;
  1084. ui_max = 1.0;
  1085. ui_step = 0.05;
  1086. ui_label = "Mitigate Slot Mask Interaction";
  1087. > = 0.0;
  1088.  
  1089. uniform float bmask <
  1090. ui_type = "drag";
  1091. ui_min = 0.0;
  1092. ui_max = 0.25;
  1093. ui_step = 0.01;
  1094. ui_label = "Base (Black) Mask Strength";
  1095. > = 0.0;
  1096.  
  1097. uniform float mclip <
  1098. ui_type = "drag";
  1099. ui_min = 0.0;
  1100. ui_max = 1.0;
  1101. ui_step = 0.025;
  1102. ui_label = "Preserve Mask Strength";
  1103. > = 0.0;
  1104.  
  1105. uniform float pr_scan <
  1106. ui_type = "drag";
  1107. ui_min = 0.0;
  1108. ui_max = 1.0;
  1109. ui_step = 0.025;
  1110. ui_label = "Preserve Scanlines Strength";
  1111. > = 0.1;
  1112.  
  1113. uniform float maskmid <
  1114. ui_type = "drag";
  1115. ui_min = 0.0;
  1116. ui_max = 1.0;
  1117. ui_step = 0.05;
  1118. ui_label = "Mitigate Mask on Mid-Colors";
  1119. > = 0.0;
  1120.  
  1121. uniform float edgemask <
  1122. ui_type = "drag";
  1123. ui_min = 0.0;
  1124. ui_max = 1.0;
  1125. ui_step = 0.1;
  1126. ui_label = "Mitigate Mask on Edges";
  1127. > = 0.0;
  1128.  
  1129. uniform float dctypex <
  1130. ui_type = "drag";
  1131. ui_min = 0.0;
  1132. ui_max = 0.75;
  1133. ui_step = 0.05;
  1134. ui_label = "Deconvergence Type X: 0:Static | Other:Dynamic";
  1135. > = 0.0;
  1136.  
  1137. uniform float dctypey <
  1138. ui_type = "drag";
  1139. ui_min = 0.0;
  1140. ui_max = 0.75;
  1141. ui_step = 0.05;
  1142. ui_label = "Deconvergence Type Y: 0:Static | Other:Dynamic";
  1143. > = 0.0;
  1144.  
  1145. uniform float deconrx <
  1146. ui_type = "drag";
  1147. ui_min = -15.0;
  1148. ui_max = 15.0;
  1149. ui_step = 0.25;
  1150. ui_label = "Horizontal Deconvergence 'R' Range";
  1151. > = 0.0;
  1152.  
  1153. uniform float decongx <
  1154. ui_type = "drag";
  1155. ui_min = -15.0;
  1156. ui_max = 15.0;
  1157. ui_step = 0.25;
  1158. ui_label = "Horizontal Deconvergence 'G' Range";
  1159. > = 0.0;
  1160.  
  1161. uniform float deconbx <
  1162. ui_type = "drag";
  1163. ui_min = -15.0;
  1164. ui_max = 15.0;
  1165. ui_step = 0.25;
  1166. ui_label = "Horizontal Deconvergence 'B' Range";
  1167. > = 0.0;
  1168.  
  1169. uniform float deconry <
  1170. ui_type = "drag";
  1171. ui_min = -15.0;
  1172. ui_max = 15.0;
  1173. ui_step = 0.25;
  1174. ui_label = "Vertical Deconvergence 'R' Range";
  1175. > = 0.0;
  1176.  
  1177. uniform float decongy <
  1178. ui_type = "drag";
  1179. ui_min = -15.0;
  1180. ui_max = 15.0;
  1181. ui_step = 0.25;
  1182. ui_label = "Vertical Deconvergence 'G' Range";
  1183. > = 0.0;
  1184.  
  1185. uniform float deconby <
  1186. ui_type = "drag";
  1187. ui_min = -15.0;
  1188. ui_max = 15.0;
  1189. ui_step = 0.25;
  1190. ui_label = "Vertical Deconvergence 'B' Range";
  1191. > = 0.0;
  1192.  
  1193. uniform float decons <
  1194. ui_type = "drag";
  1195. ui_min = 0.0;
  1196. ui_max = 3.0;
  1197. ui_step = 0.1;
  1198. ui_label = "Deconvergence Strength";
  1199. > = 1.0;
  1200.  
  1201. uniform float addnoised <
  1202. ui_type = "drag";
  1203. ui_min = -1.0;
  1204. ui_max = 1.0;
  1205. ui_step = 0.02;
  1206. ui_label = "Add Noise";
  1207. > = 0.0;
  1208.  
  1209. uniform float noiseresd <
  1210. ui_type = "drag";
  1211. ui_min = 1.0;
  1212. ui_max = 10.0;
  1213. ui_step = 1.0;
  1214. ui_label = "Noise Resolution";
  1215. > = 2.0;
  1216.  
  1217. uniform float noisetype <
  1218. ui_type = "drag";
  1219. ui_min = 0.0;
  1220. ui_max = 1.0;
  1221. ui_step = 1.0;
  1222. ui_label = "Noise Type: Colored | Luma";
  1223. > = 0.0;
  1224.  
  1225. uniform float post_br <
  1226. ui_type = "drag";
  1227. ui_min = 0.25;
  1228. ui_max = 5.0;
  1229. ui_step = 0.01;
  1230. ui_label = "Post Brightness";
  1231. > = 1.0;
  1232.  
  1233. #include "ReShade.fxh"
  1234.  
  1235. #define TexSize float2(Resolution_X,Resolution_Y)
  1236. #define IptSize float2(800.00000000,600.00000000)
  1237. #define RatSize float2(OutputSize_X,OutputSize_Y)
  1238. #define OptSize float4(RatSize,1.0/RatSize)
  1239. #define OrgSize float4(TexSize,1.0/TexSize)
  1240. #define SrcSize float4(IptSize,1.0/IptSize)
  1241. #define fuxcoord (texcoord*1.00001)
  1242. #define scans 1.5*scans
  1243. #define eps 1e-8
  1244. #define pii 3.14159265
  1245. #define fracoord (fuxcoord*OptSize.xy)
  1246. #define texCD(c,d) tex2Dlod(c,float4(d,0,0))
  1247. #define LumSize float4(2.0*TexSize.x,1.0*TexSize.y,1.0/(2.0*TexSize.x),1.0/(1.0*TexSize.y))
  1248. #define mix_m float3x3(BRIGHTNESS,ARTIFACT,ARTIFACT,FRINGING,2.0*SATURATION,0.0,FRINGING,0.0,2.0*SATURATION)
  1249. #define rgb_m float3x3(0.299,0.587,0.114,0.596,-0.274,-0.322,0.211,-0.523,0.312)
  1250. #define yiq_m float3x3(1.000,0.956,0.621,1.000,-0.272,-0.647,1.000,-1.106,1.703)
  1251. #define fetch_offset1(dx) texCD(NTSC_S03,tex_c+dx).xyz+texCD(NTSC_S03,tex_c-dx).xyz
  1252. #define fetch_offset2(dx) float3(texCD(NTSC_S03,tex_c+dx.xz).x+texCD(NTSC_S03,tex_c-dx.xz).x,texCD(NTSC_S03,tex_c+dx.yz).yz+texCD(NTSC_S03,tex_c-dx.yz).yz)
  1253.  
  1254. #ifndef Resolution_X
  1255. #define Resolution_X 320
  1256. #endif
  1257.  
  1258. #ifndef Resolution_Y
  1259. #define Resolution_Y 240
  1260. #endif
  1261.  
  1262. #ifndef OutputSize_X
  1263. #define OutputSize_X BUFFER_SCREEN_SIZE.x
  1264. #endif
  1265.  
  1266. #ifndef OutputSize_Y
  1267. #define OutputSize_Y BUFFER_SCREEN_SIZE.y
  1268. #endif
  1269.  
  1270. #define NTSC_S00 ReShade::BackBuffer
  1271.  
  1272. texture NTSC_T01{Width=1.0*Resolution_X;Height=Resolution_Y;Format=RGBA16F;};
  1273. sampler NTSC_S01{Texture=NTSC_T01;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=POINT ;MinFilter=POINT ;MipFilter=POINT ;};
  1274.  
  1275. texture NTSC_T02{Width=1.0*Resolution_X;Height=Resolution_Y;Format=RGBA16F;};
  1276. sampler NTSC_S02{Texture=NTSC_T02;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=POINT ;MinFilter=POINT ;MipFilter=POINT ;};
  1277.  
  1278. texture NTSC_T03{Width=4.0*Resolution_X;Height=Resolution_Y;Format=RGBA16F;};
  1279. sampler NTSC_S03{Texture=NTSC_T03;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  1280.  
  1281. texture NTSC_T04{Width=2.0*Resolution_X;Height=Resolution_Y;Format=RGBA16F;};
  1282. sampler NTSC_S04{Texture=NTSC_T04;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  1283.  
  1284. texture NTSC_T05{Width=2.0*Resolution_X;Height=Resolution_Y;Format=RGBA16F;};
  1285. sampler NTSC_S05{Texture=NTSC_T05;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  1286.  
  1287. texture NTSC_T06{Width=2.0*Resolution_X;Height=Resolution_Y;Format=RGBA16F;};
  1288. sampler NTSC_S06{Texture=NTSC_T06;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  1289.  
  1290. texture NTSC_T07{Width=2.0*Resolution_X;Height=Resolution_Y;Format=RGBA16F;};
  1291. sampler NTSC_S07{Texture=NTSC_T07;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  1292.  
  1293. texture NTSC_T08{Width=2.0*Resolution_X;Height=Resolution_Y;Format=RGBA16F;};
  1294. sampler NTSC_S08{Texture=NTSC_T08;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  1295.  
  1296. texture NTSC_T09{Width=1.0*OutputSize_X;Height=Resolution_Y;Format=RGBA16F;};
  1297. sampler NTSC_S09{Texture=NTSC_T09;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  1298.  
  1299. texture NTSC_T10{Width=1.0*800.00000000;Height=Resolution_Y;Format=RGBA16F;};
  1300. sampler NTSC_S10{Texture=NTSC_T10;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  1301.  
  1302. texture NTSC_T11{Width=1.0*800.00000000;Height=600.00000000;Format=RGBA16F;};
  1303. sampler NTSC_S11{Texture=NTSC_T11;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  1304.  
  1305. texture NTSC_T12{Width=1.0*800.00000000;Height=600.00000000;Format=RGBA16F;};
  1306. sampler NTSC_S12{Texture=NTSC_T12;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  1307.  
  1308. texture NTSC_T13{Width=1.0*800.00000000;Height=600.00000000;Format=RGBA16F;};
  1309. sampler NTSC_S13{Texture=NTSC_T13;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  1310.  
  1311. texture NTSC_T14{Width=1.0*OutputSize_X;Height=OutputSize_Y;Format=RGBA16F;};
  1312. sampler NTSC_S14{Texture=NTSC_T14;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  1313.  
  1314. texture NTSC_001<source="CRT-LUT-1.png";>{Width=1024;Height=32;};
  1315. sampler NTSC_L01{Texture=NTSC_001;};
  1316.  
  1317. texture NTSC_002<source="CRT-LUT-2.png";>{Width=1024;Height=32;};
  1318. sampler NTSC_L02{Texture=NTSC_002;};
  1319.  
  1320. texture NTSC_003<source="CRT-LUT-3.png";>{Width=1024;Height=32;};
  1321. sampler NTSC_L03{Texture=NTSC_003;};
  1322.  
  1323. texture NTSC_004<source="CRT-LUT-4.png";>{Width=1024;Height=32;};
  1324. sampler NTSC_L04{Texture=NTSC_004;};
  1325.  
  1326. uniform int framecount<source="framecount";>;
  1327.  
  1328. float3 fix_lut(float3 lut,float3 ref)
  1329. {
  1330. float r=length(ref);
  1331. float l=length(lut);
  1332. float m=max(max(ref.r,ref.g),ref.b);
  1333. ref=normalize(lut+0.0000001)*lerp(r,l,pow(m,1.25));
  1334. return lerp(lut,ref,LUTBR);
  1335. }
  1336.  
  1337. float vignette(float2 pos)
  1338. {
  1339. float2 b=vigdef*float2(1.0,OrgSize.x/OrgSize.y)*0.125;
  1340. pos=clamp(pos,0.0,1.0);
  1341. pos=abs(2.0*(pos-0.5));
  1342. float2 res=lerp(0.0.xx,1.0.xx,smoothstep(1.0.xx,1.0.xx-b,sqrt(pos)));
  1343. res=pow(res,0.70.xx);
  1344. return max(lerp(1.0,sqrt(res.x*res.y),vigstr),0.0);
  1345. }
  1346.  
  1347. float contrast(float x)
  1348. {
  1349. return max(lerp(x,smoothstep(0,1.0,x),contra),0.0);
  1350. }
  1351.  
  1352. float dist(float3 A,float3 B)
  1353. {
  1354. float r=0.5*(A.r+B.r);
  1355. float3 d=A-B;
  1356. float3 c=float3(2.+r,4.,3.-r);
  1357. return sqrt(dot(c*d,d))/3.;
  1358. }
  1359.  
  1360. float3 plant(float3 tar,float r)
  1361. {
  1362. float t=max(max(tar.r,tar.g),tar.b)+0.00001;
  1363. return tar*r/t;
  1364. }
  1365.  
  1366. float3 fetch_pixel(float2 coord)
  1367. {
  1368. float2 dx=float2(LumSize.z,0.0)*downsample_levelx;
  1369. float2 dy=float2(0.0,LumSize.w)*downsample_levely;
  1370. float2 d1=dx+dy;
  1371. float2 d2=dx-dy;
  1372. float sum=15.0;
  1373. float3 result=
  1374. 3.0*texCD(NTSC_S06,coord ).rgb+2.0*texCD(NTSC_S06,coord+dx).rgb+2.0*texCD(NTSC_S06,coord-dx).rgb+
  1375. 2.0*texCD(NTSC_S06,coord+dy).rgb+2.0*texCD(NTSC_S06,coord-dy).rgb+ texCD(NTSC_S06,coord+d1).rgb+
  1376. texCD(NTSC_S06,coord-d1).rgb+ texCD(NTSC_S06,coord+d2).rgb+ texCD(NTSC_S06,coord-d2).rgb;
  1377. return result/sum;
  1378. }
  1379.  
  1380. float gauss_h(float x)
  1381. {
  1382. float sigma=1.0/(2.0*SIGMA_H*SIGMA_H);
  1383. return exp(-x*x*sigma);
  1384. }
  1385.  
  1386. float gauss_v(float x)
  1387. {
  1388. float sigma=1.0/(2.0*SIGMA_V*SIGMA_V);
  1389. return exp(-x*x*sigma);
  1390. }
  1391.  
  1392. float bloom_h(float x)
  1393. {
  1394. float sigma=1.0/(2.0*SIGMA_X*SIGMA_X);
  1395. return exp(-x*x*sigma);
  1396. }
  1397.  
  1398. float bloom_v(float x)
  1399. {
  1400. float sigma=1.0/(2.0*SIGMA_Y*SIGMA_Y);
  1401. return exp(-x*x*sigma);
  1402. }
  1403.  
  1404. float crthd_h(float x,float y)
  1405. {
  1406. float sigma=1.0/(2.0*LIGMA_H*LIGMA_H*y*y*internal_res*internal_res);
  1407. return exp(-x*x*sigma);
  1408. }
  1409.  
  1410. float mod(float x,float y)
  1411. {
  1412. return x-y* floor(x/y);
  1413. }
  1414.  
  1415. float st0(float x)
  1416. {
  1417. return exp2(-10.0*x*x);
  1418. }
  1419.  
  1420. float3 sw0(float x,float color,float scanline,float3 c)
  1421. {
  1422. float3 xe=lerp(1.0.xxx+scans,1.0.xxx,c);
  1423. float tmp=lerp(beam_min,beam_max,color);
  1424. float ex=x*tmp;
  1425. ex=(gsl>-0.5)?ex*ex:lerp(ex*ex,ex*ex*ex,0.4);
  1426. return exp2(-scanline*ex*xe);
  1427. }
  1428.  
  1429. float3 sw1(float x,float color,float scanline,float3 c)
  1430. {
  1431. float3 xe=lerp(1.0.xxx+scans,1.0.xxx,c);
  1432. x=lerp(x,beam_min*x,max(x-0.4*color,0.0));
  1433. float tmp=lerp(1.2*beam_min,beam_max,color);
  1434. float ex=x*tmp;
  1435. return exp2(-scanline*ex*ex*xe);
  1436. }
  1437.  
  1438. float3 sw2(float x,float color,float scanline,float3 c)
  1439. {
  1440. float3 xe=lerp(1.0.xxx+scans,1.0.xxx,c);
  1441. float tmp=lerp((2.5-0.5*color)*beam_min,beam_max,color);
  1442. tmp=lerp(beam_max,tmp,pow(x,color+0.3));
  1443. float ex=x*tmp;
  1444. return exp2(-scanline*ex*ex*xe);
  1445. }
  1446.  
  1447. float2 overscan(float2 pos,float dx,float dy)
  1448. {
  1449. pos=pos*2.0-1.0;
  1450. pos*=float2(dx,dy);
  1451. return pos*0.5+0.5;
  1452. }
  1453.  
  1454. float2 warp(float2 pos)
  1455. {
  1456. pos=pos*2.0-1.0;
  1457. 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);
  1458. return pos*0.5+0.5;
  1459. }
  1460.  
  1461. float3 gc1(float3 c)
  1462. {
  1463. float mc=max(max(c.r,c.g),c.b);
  1464. float mg=pow(mc,1.0/gamma_c);
  1465. return c*mg/(mc+eps);
  1466. }
  1467.  
  1468. float3 rgb2yiq(float3 r)
  1469. {
  1470. return mul(rgb_m, r);
  1471. }
  1472.  
  1473. float3 yiq2rgb(float3 y)
  1474. {
  1475. return mul(yiq_m, y);
  1476. }
  1477.  
  1478. float get_luma(float3 c)
  1479. {
  1480. return dot(c,float3(0.299,0.587,0.114));
  1481. }
  1482.  
  1483. float swoothstep(float e0,float e1,float x)
  1484. {
  1485. return clamp((x-e0)/(e1-e0),0.0,1.0);
  1486. }
  1487.  
  1488. float3 crt_mask(float2 pos,float mx,float mb)
  1489. {
  1490. float3 mask=mask_drk;
  1491. float3 one=1.0;
  1492. if(shadow_msk== 1.0)
  1493. {
  1494. float mc=1.0-max(maskstr,0.0);
  1495. pos.x=frac(pos.x*0.5);
  1496. if(pos.x<0.49)
  1497. {
  1498. mask.r=1.0;mask.g= mc;mask.b=1.0;
  1499. }else
  1500. {
  1501. mask.r= mc;mask.g=1.0;mask.b= mc;
  1502. }
  1503. }else
  1504. if(shadow_msk== 2.0)
  1505. {
  1506. float lane=mask_lgt;
  1507. float odd=0.0;
  1508. if(frac(pos.x/6.0)<0.49)odd=1.0;
  1509. if(frac((pos.y+odd)/2.0)<0.49)lane=mask_drk;
  1510. pos.x=floor(mod(pos.x,3.0));
  1511. if(pos.x<0.5)mask.r=mask_lgt;else
  1512. if(pos.x<1.5)mask.g=mask_lgt;else
  1513. mask.b= mask_lgt;
  1514. mask*=lane;
  1515. }else
  1516. if(shadow_msk== 3.0)
  1517. {
  1518. pos.x=floor(mod(pos.x,3.0));
  1519. if(pos.x<0.5)mask.r=mask_lgt;else
  1520. if(pos.x<1.5)mask.g=mask_lgt;else
  1521. mask.b= mask_lgt;
  1522. }else
  1523. if(shadow_msk== 4.0)
  1524. {
  1525. pos.x+=pos.y*3.0;
  1526. pos.x=frac(pos.x/6.0);
  1527. if(pos.x<0.3)mask.r=mask_lgt;else
  1528. if(pos.x<0.6)mask.g=mask_lgt;else
  1529. mask.b= mask_lgt;
  1530. }else
  1531. if(shadow_msk== 5.0)
  1532. {
  1533. pos.xy=floor(pos.xy*float2(1.0,0.5));
  1534. pos.x+=pos.y*3.0;
  1535. pos.x=frac(pos.x/6.0);
  1536. if(pos.x<0.3)mask.r=mask_lgt;else
  1537. if(pos.x<0.6)mask.g=mask_lgt;else
  1538. mask.b= mask_lgt;
  1539. }else
  1540. if(shadow_msk== 6.0)
  1541. {
  1542. mask=0.0;
  1543. pos.x=frac(pos.x/2.0);
  1544. if(pos.x<0.49)
  1545. {
  1546. mask.r=1.0;
  1547. mask.b=1.0;
  1548. }else
  1549. mask.g=1.0;
  1550. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1551. }else
  1552. if(shadow_msk== 7.0)
  1553. {
  1554. mask=0.0;
  1555. pos.x=floor(mod(pos.x,3.0));
  1556. if(pos.x<0.5)mask.r=1.0;else
  1557. if(pos.x<1.5)mask.g=1.0;else
  1558. mask.b=1.0;
  1559. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1560. }else
  1561. if(shadow_msk== 8.0)
  1562. {
  1563. mask=0.0;
  1564. pos.x=frac(pos.x/2.0);
  1565. if(pos.x<0.49)
  1566. {
  1567. mask=0.0.xxx;
  1568. }else
  1569. mask=1.0.xxx;
  1570. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1571. }else
  1572. if(shadow_msk== 9.0)
  1573. {
  1574. mask=0.0;
  1575. pos.x=frac(pos.x/3.0);
  1576. if(pos.x<0.3)mask=0.0.xxx;else
  1577. if(pos.x<0.6)mask=1.0.xxx;else
  1578. mask=1.0.xxx;
  1579. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1580. }else
  1581. if(shadow_msk==10.0)
  1582. {
  1583. mask=0.0;
  1584. pos.x=frac(pos.x/3.0);
  1585. if(pos.x<0.3)mask =0.0.xxx;else
  1586. if(pos.x<0.6)mask.rb=1.0.xx ;else
  1587. mask.g=1.0;
  1588. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1589. }else
  1590. if(shadow_msk==11.0)
  1591. {
  1592. mask=0.0;
  1593. pos.x=frac(pos.x*0.25);
  1594. if(pos.x<0.2)mask =0.0.xxx;else
  1595. if(pos.x<0.4)mask.r=1.0 ;else
  1596. if(pos.x<0.7)mask.g=1.0 ;else
  1597. mask.b=1.0;
  1598. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1599. }else
  1600. if(shadow_msk==12.0)
  1601. {
  1602. mask=0.0;
  1603. pos.x=frac(pos.x*0.25);
  1604. if(pos.x<0.2)mask.r =1.0 ;else
  1605. if(pos.x<0.4)mask.rg=1.0.xx;else
  1606. if(pos.x<0.7)mask.gb=1.0.xx;else
  1607. mask.b=1.0;mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1608. }else
  1609. if(shadow_msk==13.0)
  1610. {
  1611. mask=0.0;
  1612. pos.x=floor(mod(pos.x,7.0));
  1613. if(pos.x<0.5)mask =0.0.xxx;else
  1614. if(pos.x<2.5)mask.r=1.0 ;else
  1615. if(pos.x<4.5)mask.g=1.0 ;else
  1616. mask.b=1.0;
  1617. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1618. }else
  1619. {
  1620. mask=0.0;
  1621. pos.x=floor(mod(pos.x,6.0));
  1622. if(pos.x<0.5)mask =0.0.xxx;else
  1623. if(pos.x<1.5)mask.r =1.0 ;else
  1624. if(pos.x<2.5)mask.rg =1.0.xx ;else
  1625. if(pos.x<3.5)mask.rgb=1.0.xxx;else
  1626. if(pos.x<4.5)mask.gb =1.0.xx ;else
  1627. mask.b=1.0;
  1628. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1629. }
  1630. if(mask_layout>0.5)mask=mask.rbg;
  1631. float maskmin=min(min(mask.r,mask.g),mask.b);
  1632. return (mask-maskmin)*(1.0+(maskboost-1.0)*mb)+maskmin;
  1633. }
  1634.  
  1635. float slt_mask(float2 pos,float m,float swidth)
  1636. {
  1637. if ((slotmask1+slotmask2)==0.0)return 1.0;else
  1638. {
  1639. pos.y=floor(pos.y/slotms);
  1640. float mlen=swidth*2.0;
  1641. float px=floor( mod(pos.x, 0.99999*mlen));
  1642. float py=floor(frac(pos.y/(2.0*double_slot))*2.0*double_slot);
  1643. float slot_dark=lerp(1.0-slotmask2,1.0-slotmask1,m);
  1644. float slot=1.0;
  1645. if(py==0.0&&px<swidth) slot=slot_dark;else
  1646. if(py==double_slot&&px>=swidth) slot=slot_dark;
  1647. return slot;
  1648. }
  1649. }
  1650.  
  1651. float humbars(float pos)
  1652. {
  1653. if (barintensity==0.0)return 1.0;else
  1654. {
  1655. pos=(barintensity>=0.0)?pos:(1.0-pos);
  1656. pos=frac(pos+ mod(float(framecount),barspeed)/(barspeed-1.0));
  1657. pos=(barintensity< 0.0)?pos:(1.0-pos);
  1658. return (1.0-barintensity)+barintensity*pos;
  1659. }
  1660. }
  1661.  
  1662. float corner(float2 pos)
  1663. {
  1664. pos=abs(2.0*(pos-0.50));
  1665. float2 aspect=float2(1.0,OptSize.x/OptSize.y);
  1666. float b=bsize*0.05+0.0005;pos.y=pos.y+b*(aspect.y-1.0);
  1667. float2 crn=max(csize.xx,2.0*b+0.0015);
  1668. float2 crp=max(pos-(1.0-crn*aspect),0.0)/aspect;float cd=sqrt(dot(crp,crp));
  1669. pos=max(pos,1.0-crn+cd);
  1670. float res=lerp(1.0,0.0,smoothstep(1.0-b,1.0,sqrt(max(pos.x,pos.y))));
  1671. return pow(res,sborder);
  1672. }
  1673.  
  1674. float3 declip(float3 c,float b)
  1675. {
  1676. float m=max(max(c.r,c.g),c.b);
  1677. if(m>b)c=c*b/m;
  1678. return c;
  1679. }
  1680.  
  1681. float igc(float mc)
  1682. {
  1683. return pow(mc,gamma_c);
  1684. }
  1685.  
  1686. float3 gc2(float3 c,float w3)
  1687. {
  1688. float mc=max(max(c.r,c.g),c.b);
  1689. float p=1.0/(1.0+(gamma_d-1.0)* lerp(0.375,1.0,w3));
  1690. float mg=pow(mc, p );
  1691. return c*mg/(mc+eps);
  1692. }
  1693.  
  1694. float3 noise(float3 v)
  1695. {
  1696. if(addnoised<0.0)v.z=-addnoised;else v.z= mod(v.z,6001.0)/1753.0;
  1697. v =frac(v)+frac(v*1e4)+frac(v*1e-4);
  1698. v+=float3(0.12345,0.6789,0.314159);
  1699. v =frac(v*dot(v,v)*123.456);
  1700. v =frac(v*dot(v,v)*123.456);
  1701. v =frac(v*dot(v,v)*123.456);
  1702. v =frac(v*dot(v,v)*123.456);
  1703. return v;
  1704. }
  1705.  
  1706. void bring_pixel(inout float3 c,inout float3 b,inout float3 g,float2 coord,float2 boord)
  1707. {
  1708. float stepx=OptSize.z;
  1709. float stepy=OptSize.w;
  1710. float2 dx=float2(stepx,0.0);
  1711. float2 dy=float2(0.0,stepy);
  1712. float posx= 2.0*coord.x-1.0;
  1713. float posy= 2.0*coord.y-1.0;
  1714. if(dctypex>0.025)
  1715. {
  1716. posx= sign(posx)*pow(abs(posx),1.05-dctypex);
  1717. dx=posx*dx;
  1718. }
  1719. if(dctypey>0.025)
  1720. {
  1721. posy= sign(posy)*pow(abs(posy),1.05-dctypey);
  1722. dy=posy*dy;
  1723. }
  1724. float2 rc=deconrx*dx+deconry*dy;
  1725. float2 gc=decongx*dx+decongy*dy;
  1726. float2 bc=deconbx*dx+deconby*dy;
  1727. float r1=texCD(NTSC_S14,coord+rc).r;
  1728. float g1=texCD(NTSC_S14,coord+gc).g;
  1729. float b1=texCD(NTSC_S14,coord+bc).b;
  1730. float ds=decons;
  1731. float3 d=float3(r1,g1,b1);
  1732. c=clamp(lerp(c,d,ds),0.0,1.0);
  1733. r1=texCD(NTSC_S13,boord+rc).r;
  1734. g1=texCD(NTSC_S13,boord+gc).g;
  1735. b1=texCD(NTSC_S13,boord+bc).b;
  1736. d=float3(r1,g1,b1);
  1737. b=g=lerp(b,d,min(ds,1.0));
  1738. r1=texCD(NTSC_S11,boord+rc).r;
  1739. g1=texCD(NTSC_S11,boord+gc).g;
  1740. b1=texCD(NTSC_S11,boord+bc).b;
  1741. d=float3(r1,g1,b1);
  1742. g=lerp(g,d,min(ds,1.0));
  1743. }
  1744.  
  1745. float4 AfterglowPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1746. {
  1747. float2 dx=float2(OrgSize.z,0.0);
  1748. float2 dy=float2(0.0,OrgSize.w);
  1749. float w=1.0;
  1750. float3 color0=texCD(NTSC_S00,texcoord ).rgb;
  1751. float3 color1=texCD(NTSC_S00,texcoord-dx).rgb;
  1752. float3 color2=texCD(NTSC_S00,texcoord+dx).rgb;
  1753. float3 color3=texCD(NTSC_S00,texcoord-dy).rgb;
  1754. float3 color4=texCD(NTSC_S00,texcoord+dy).rgb;
  1755. float3 cr=(2.5*color0+color1+color2+color3+color4)/6.5;
  1756. float3 a=texCD(NTSC_S01,texcoord).rgb;
  1757. if((color0.r+color0.g+color0.b<5.0/255.0)){w=0.0;}
  1758. float3 result=lerp(max(lerp(cr,a,0.49+float3(PR,PG,PB))-1.25/255.0,0.0),cr,w);
  1759. return float4(result,w);
  1760. }
  1761.  
  1762. float4 PreShaderPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1763. {
  1764. const float3x3 File0=float3x3(0.412391, 0.212639,0.019331, 0.357584,0.715169, 0.119195, 0.180481,0.072192,0.950532);
  1765. const float3x3 File1=float3x3(0.430554, 0.222004,0.020182, 0.341550,0.706655, 0.129553, 0.178352,0.071341,0.939322);
  1766. const float3x3 File2=float3x3(0.396686, 0.210299,0.006131, 0.372504,0.713766, 0.115356, 0.181266,0.075936,0.967571);
  1767. const float3x3 File3=float3x3(0.393521, 0.212376,0.018739, 0.365258,0.701060, 0.111934, 0.191677,0.086564,0.958385);
  1768. const float3x3 File4=float3x3(0.392258, 0.209410,0.016061, 0.351135,0.725680, 0.093636, 0.166603,0.064910,0.850324);
  1769. const float3x3 File5=float3x3(0.377923, 0.195679,0.010514, 0.317366,0.722319, 0.097826, 0.207738,0.082002,1.076960);
  1770. const float3x3 ToRGB=float3x3(3.240970,-0.969244,0.055630,-1.537383,1.875968,-0.203977,-0.498611,0.041555,1.056972);
  1771. const float3x3 ToMDN=float3x3(2.791723,-0.894766,0.041678,-1.173165,1.815586,-0.130886,-0.440973,0.032000,1.002034);
  1772. const float3x3 ToDCI=float3x3(2.493497,-0.829489,0.035846,-0.931384,1.762664,-0.076172,-0.402711,0.023625,0.956885);
  1773. const float3x3 ToADB=float3x3(2.041588,-0.969244,0.013444,-0.565007,1.875968,-0.118360,-0.344731,0.041555,1.015175);
  1774. const float3x3 ToREC=float3x3(1.716651,-0.666684,0.017640,-0.355671,1.616481,-0.042771,-0.253366,0.015769,0.942103);
  1775. const float3x3 D65_to_D55=float3x3(0.4850339153,0.2500956126,0.0227359648,0.3488957224,0.6977914447,0.1162985741,0.1302823568,0.0521129427,0.6861537456);
  1776. const float3x3 D65_to_D93=float3x3(0.3412754080,0.1759701322,0.0159972847,0.3646170520,0.7292341040,0.1215390173,0.2369894093,0.0947957637,1.2481442225);
  1777. float4 imgColor=texCD(NTSC_S00,texcoord);
  1778. float4 aftrglow=texCD(NTSC_S01,texcoord);
  1779. float w=1.0-aftrglow.w;
  1780. float l=length(aftrglow.rgb);
  1781. aftrglow.rgb=AS*w*normalize(pow(aftrglow.rgb+0.01,ST))*l;
  1782. float bp=w*BP/255.0;
  1783. if(sega_fix>0.5) imgColor.rgb=imgColor.rgb*(255.0/239.0);
  1784. imgColor.rgb=min(imgColor.rgb,1.0);
  1785. float3 color=imgColor.rgb;
  1786. if(int(TNTC)==0) {color.rgb=imgColor.rgb;}else
  1787. {
  1788. float lutlow=LUTLOW/255.0;float invs=1.0/32.0;
  1789. float3 lut_ref=imgColor.rgb+lutlow*(1.0-pow(imgColor.rgb,0.333.xxx));
  1790. float lutb=lut_ref.b*(1.0-0.5*invs);
  1791. lut_ref.rg=lut_ref.rg*(1.0-invs)+0.5*invs;
  1792. float tile1=ceil(lutb*(32.0-1.0));
  1793. float tile0=max(tile1-1.0,0.0);
  1794. float f=frac(lutb*(32.0-1.0));if(f==0.0)f=1.0;
  1795. float2 coord1=float2(tile0+lut_ref.r,lut_ref.g)*float2(invs,1.0);
  1796. float2 coord2=float2(tile1+lut_ref.r,lut_ref.g)*float2(invs,1.0);
  1797. float4 color1,color2,res;
  1798. if(int(TNTC)==1)
  1799. {
  1800. color1=texCD(NTSC_L01,coord1);
  1801. color2=texCD(NTSC_L01,coord2);
  1802. res=lerp(color1,color2,f);
  1803. }else
  1804. if(int(TNTC)==2)
  1805. {
  1806. color1=texCD(NTSC_L02,coord1);
  1807. color2=texCD(NTSC_L02,coord2);
  1808. res=lerp(color1,color2,f);
  1809. }else
  1810. if(int(TNTC)==3)
  1811. {
  1812. color1=texCD(NTSC_L03,coord1);
  1813. color2=texCD(NTSC_L03,coord2);
  1814. res=lerp(color1,color2,f);
  1815. }else
  1816. if(int(TNTC)==4)
  1817. {
  1818. color1=texCD(NTSC_L04,coord1);
  1819. color2=texCD(NTSC_L04,coord2);
  1820. res=lerp(color1,color2,f);
  1821. }
  1822. res.rgb=fix_lut(res.rgb,imgColor.rgb);
  1823. color=lerp(imgColor.rgb,res.rgb,min(TNTC,1.0));
  1824. }
  1825. float3 c=clamp(color,0.0,1.0);
  1826. float3x3 m_o;
  1827. float p;
  1828. if(CS==0.0){p=2.2;m_o=ToRGB;}else
  1829. if(CS==1.0){p=2.2;m_o=ToMDN;}else
  1830. if(CS==2.0){p=2.6;m_o=ToDCI;}else
  1831. if(CS==3.0){p=2.2;m_o=ToADB;}else
  1832. if(CS==4.0){p=2.4;m_o=ToREC;}
  1833. color=pow(c,p);
  1834. float3x3 m_i;
  1835. if(CP==0.0){m_i=File0;}else
  1836. if(CP==1.0){m_i=File1;}else
  1837. if(CP==2.0){m_i=File2;}else
  1838. if(CP==3.0){m_i=File3;}else
  1839. if(CP==4.0){m_i=File4;}else
  1840. if(CP==5.0){m_i=File5;}
  1841. color=mul(color,m_i);
  1842. color=mul(color,m_o);
  1843. color=clamp(color,0.0,1.0);
  1844. color=pow(color,1.0/p);
  1845. if(CP==-1.0)color=c;
  1846. float3 solor1=plant(pow(color,wp_saturation),max(max(color.r,color.g),color.b));
  1847. float luma=dot(color,float3(0.299,0.587,0.114));
  1848. float3 solor2=lerp(luma,color,wp_saturation);
  1849. color=(wp_saturation>1.0)?solor1:solor2;
  1850. color=plant(color,contrast(max(max(color.r,color.g),color.b)));
  1851. p=2.2;
  1852. color=clamp(color,0.0,1.0);
  1853. color=pow(color,p);
  1854. float3 warmer=mul(color,D65_to_D55);
  1855. warmer=mul(warmer,ToRGB);
  1856. float3 cooler=mul(color,D65_to_D93);
  1857. cooler=mul(cooler,ToRGB);
  1858. float m=abs(WP)/100.0;
  1859. float3 comp=(WP<0.0)?cooler:warmer;
  1860. color=lerp(color,comp,m);
  1861. color=pow(max(color,0.0),1.0/p);
  1862. if(BP>-0.5)color=color+aftrglow.rgb+bp;else
  1863. {
  1864. color=max(color+BP/255.0,0.0)/(1.0+BP/255.0*step(-BP/255.0,max(max(color.r,color.g),color.b)))+aftrglow.rgb;
  1865. }
  1866. color=min(color*pre_bb,1.0);
  1867. return float4(color,vignette(texcoord));
  1868. }
  1869.  
  1870. float4 Signal_1_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1871. {
  1872. float pix_res= min(ntsc_scale,1.0);
  1873. float phase= (ntsc_phase<1.5)?((OrgSize.x>300.0)? 2.0:3.0):((ntsc_phase>2.5)?3.0:2.0);
  1874. if(ntsc_phase==4.0)phase=3.0;
  1875. float res=ntsc_scale;
  1876. float CHROMA_MOD_FREQ=(phase<2.5)?(4.0*pii/15.0):(pii/3.0);
  1877. float ARTIFACT=cust_artifacting;
  1878. float FRINGING=cust_fringing;
  1879. float BRIGHTNESS=ntsc_brt;
  1880. float SATURATION=ntsc_sat;
  1881. float MERGE=0.0;
  1882. if(ntsc_fields== 1.0&&phase==3.0) MERGE=1.0;else
  1883. if(ntsc_fields== 2.0) MERGE=0.0;else
  1884. if(ntsc_fields== 3.0) MERGE=1.0;
  1885. float2 pix_no=texcoord*OrgSize.xy*pix_res* float2(4.0,1.0);
  1886. float3 col0=texCD(NTSC_S02, texcoord).rgb;
  1887. float3 yiq1=rgb2yiq(col0);
  1888. yiq1.x=pow(yiq1.x,ntsc_gamma); float lum=yiq1.x;
  1889. float2 dx=float2(OrgSize.z,0.0);
  1890. float c1=get_luma(texCD(NTSC_S02,texcoord-dx).rgb);
  1891. float c2=get_luma(texCD(NTSC_S02,texcoord+dx).rgb);
  1892. if(ntsc_phase==4.0)
  1893. {
  1894. float miix=min(5.0*abs(c1-c2),1.0);
  1895. c1=pow(c1,ntsc_gamma);
  1896. c2=pow(c2,ntsc_gamma);
  1897. yiq1.x=lerp(min(0.5*(yiq1.x+max(c1,c2)),max(yiq1.x,min(c1,c2))),yiq1.x,miix);
  1898. }
  1899. float3 yiq2=yiq1;
  1900. float3 yiqs=yiq1;
  1901. float3 yiqz=yiq1;
  1902. float3 temp=yiq1;
  1903. float mit=ntsc_taps;if(ntsc_charp1>0.25&&phase==2.0)mit=clamp(mit,8.0,min(ntsc_taps,14.0));
  1904. mit=swoothstep(16.0,8.0,mit)*0.325;
  1905. if(MERGE>0.5)
  1906. {
  1907. 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.));
  1908. float mod_phase2=chroma_phase2+pix_no.x*CHROMA_MOD_FREQ;
  1909. float i_mod2=cos( mod_phase2 );
  1910. float q_mod2=sin( mod_phase2 );
  1911. yiq2.yz*=float2(i_mod2,q_mod2);
  1912. yiq2=mul(mix_m,yiq2);
  1913. yiq2.yz*=float2(i_mod2,q_mod2);
  1914. yiq2.yz =lerp(yiq2.yz,temp.yz,mit);
  1915. if(res>1.025)
  1916. {
  1917. mod_phase2=chroma_phase2 +res *pix_no.x*CHROMA_MOD_FREQ;
  1918. i_mod2=cos(mod_phase2);
  1919. q_mod2=sin(mod_phase2);
  1920. yiqs.yz*=float2(i_mod2,q_mod2);
  1921. yiq2.x=dot(yiqs,mix_m[0]);
  1922. }
  1923. }
  1924. 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.));
  1925. float mod_phase1=chroma_phase1+pix_no.x*CHROMA_MOD_FREQ;
  1926. float i_mod1=cos( mod_phase1 );
  1927. float q_mod1=sin( mod_phase1 );
  1928. yiq1.yz*=float2(i_mod1,q_mod1);
  1929. yiq1=mul(mix_m,yiq1);
  1930. yiq1.yz*=float2(i_mod1,q_mod1);
  1931. yiq1.yz =lerp(yiq1.yz,temp.yz,mit);
  1932. if(res>1.025)
  1933. {
  1934. mod_phase1=chroma_phase1 +res *pix_no.x*CHROMA_MOD_FREQ;
  1935. i_mod1=cos(mod_phase1);
  1936. q_mod1=sin(mod_phase1);
  1937. yiqz.yz*=float2(i_mod1,q_mod1);
  1938. yiq1.x=dot(yiqz,mix_m[0]);
  1939. }
  1940. if(ntsc_phase==4.0){yiq1.x=lum;yiq2.x=lum;}
  1941. 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);}
  1942. return float4(yiq1,lum);
  1943. }
  1944.  
  1945. float4 Signal_2_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1946. {
  1947. float chroma_filter_2_phase[33]={
  1948. 0.001384762, 0.001678312, 0.002021715, 0.002420562, 0.002880460, 0.003406879, 0.004004985, 0.004679445, 0.005434218, 0.006272332, 0.007195654,
  1949. 0.008204665, 0.009298238, 0.010473450, 0.011725413, 0.013047155, 0.014429548, 0.015861306, 0.017329037, 0.018817382, 0.020309220, 0.021785952,
  1950. 0.023227857, 0.024614500, 0.025925203, 0.027139546, 0.028237893, 0.029201910, 0.030015081, 0.030663170, 0.031134640, 0.031420995, 0.031517031};
  1951. float chroma_filter_3_phase[25]={
  1952. -0.000118847,-0.000271306,-0.000502642,-0.000930833,-0.001451013,
  1953. -0.002064744,-0.002700432,-0.003241276,-0.003524948,-0.003350284,
  1954. -0.002491729,-0.000721149, 0.002164659, 0.006313635, 0.011789103,
  1955. 0.018545660, 0.026414396, 0.035100710, 0.044196567, 0.053207202,
  1956. 0.061590275, 0.068803602, 0.074356193, 0.077856564, 0.079052396};
  1957. float luma_filter_2_phase[33]={
  1958. -0.000174844,-0.000205844,-0.000149453,-0.000051693, 0.000000000,-0.000066171,-0.000245058,-0.000432928,-0.000472644,-0.000252236, 0.000198929,
  1959. 0.000687058, 0.000944112, 0.000803467, 0.000363199, 0.000013422, 0.000253402, 0.001339461, 0.002932972, 0.003983485, 0.003026683,-0.001102056,
  1960. -0.008373026,-0.016897700,-0.022914480,-0.021642347,-0.028863273, 0.027271957, 0.054921920, 0.098342579, 0.139044281, 0.168055832, 0.178571429};
  1961. float luma_filter_3_phase[25]={
  1962. -0.000012020,-0.000022146,-0.000013155,-0.000012020,-0.000049979,
  1963. -0.000113940,-0.000122150,-0.000005612, 0.000170516, 0.000237199,
  1964. 0.000169640, 0.000285688, 0.000984574, 0.002018683, 0.002002275,
  1965. -0.005909882,-0.012049081,-0.018222860,-0.022606931, 0.002460860,
  1966. 0.035868225, 0.084016453, 0.135563500, 0.175261268, 0.220176552};
  1967. float luma_filter_4_phase[25]={
  1968. -0.000472644,-0.000252236, 0.000198929, 0.000687058, 0.000944112,
  1969. 0.000803467, 0.000363199, 0.000013422, 0.000253402, 0.001339461,
  1970. 0.002932972, 0.003983485, 0.003026683,-0.001102056,-0.008373026,
  1971. -0.016897700,-0.022914480,-0.021642347,-0.028863273, 0.027271957,
  1972. 0.054921920, 0.098342579, 0.139044281, 0.168055832, 0.178571429};
  1973. const int TAPS_2_phase=32;
  1974. const int TAPS_3_phase=24;
  1975. float res=ntsc_scale;
  1976. float3 signal=0.0;
  1977. float2 one=0.25*OrgSize.zz/res;
  1978. float2 tex_c=texcoord+float2(0.5*OrgSize.z/4.0,0.0);
  1979. float phase= ( ntsc_phase<1.5)?((OrgSize.x>300.0)?2.0:3.0):((ntsc_phase>2.5)?3.0:2.0);
  1980. if(ntsc_phase==4.0){phase=3.0;luma_filter_3_phase=luma_filter_4_phase;}
  1981. float3 wsum =0.0.xxx;
  1982. float3 sums=wsum;
  1983. float3 tmps=wsum;
  1984. float offset=0.0;int i=0;
  1985. float j =0.0;
  1986. if(phase<2.5)
  1987. {
  1988. float loop=max(ntsc_taps,8.0);
  1989. if(ntsc_charp1>0.25)loop=min(loop,14.0);
  1990. float loob=loop+1.0;
  1991. float taps=0.0;
  1992. float ssub=loop-loop/ntsc_cscale1;
  1993. float mit=1.0+0.0375*pow(swoothstep(16.0,8.0,loop),0.5);
  1994. float2 dx=float2(one.x*mit,0.0);
  1995. float2 xd=dx; int loopstart=int(TAPS_2_phase-loop);
  1996. for(i=loopstart;i<32;i++)
  1997. {
  1998. offset=float(i-loopstart);
  1999. j=offset+1.0;xd= (offset-loop)*dx;
  2000. sums=fetch_offset1(xd);
  2001. taps=max(j-ssub,0.0);
  2002. tmps=float3(luma_filter_2_phase[i], taps.xx );
  2003. wsum=wsum+tmps; signal+=sums*tmps;
  2004. }
  2005. taps=loob-ssub;
  2006. tmps=float3(luma_filter_2_phase[TAPS_2_phase], taps.xx);
  2007. wsum=wsum+wsum+tmps;
  2008. signal+=texCD(NTSC_S03,tex_c).xyz*tmps;
  2009. signal =signal/wsum;
  2010. }else
  2011. {
  2012. float loop=min(ntsc_taps,TAPS_3_phase); one.y=one.y/ntsc_cscale2;
  2013. float mit=1.0;
  2014. if(ntsc_phase==4.0){loop=max(loop,8.0); mit=1.0+0.0375*pow(swoothstep(16.0,8.0,loop),0.5);}
  2015. float3 dx=float3(one.x,one.y,0.0);
  2016. float3 xd=dx; int loopstart=int(TAPS_3_phase-loop);
  2017. dx.x*=mit;
  2018. for(i=loopstart;i<24;i++)
  2019. {
  2020. offset=float(i-loopstart);
  2021. j=offset+1.0;xd.xy=(offset-loop)*dx.xy;
  2022. sums=fetch_offset2(xd);
  2023. tmps=float3(luma_filter_3_phase[i], chroma_filter_3_phase[i].xx);
  2024. wsum=wsum+tmps; signal+=sums*tmps;
  2025. }
  2026. tmps=float3(luma_filter_3_phase[TAPS_3_phase], chroma_filter_3_phase[TAPS_3_phase], chroma_filter_3_phase[TAPS_3_phase]);
  2027. wsum=wsum+wsum+tmps;
  2028. signal+=texCD(NTSC_S03,tex_c).xyz*tmps;
  2029. signal =signal/wsum;
  2030. }
  2031. signal.x=clamp( signal.x,0.0,1.0);
  2032. if(ntsc_ring>0.05)
  2033. {
  2034. float2 dx=float2(OrgSize.z/min(res,1.0),0.0);
  2035. float a=texCD(NTSC_S03,tex_c-2.0*dx).a;
  2036. float b=texCD(NTSC_S03,tex_c- dx).a;
  2037. float c=texCD(NTSC_S03,tex_c+2.0*dx).a;
  2038. float d=texCD(NTSC_S03,tex_c+ dx).a;
  2039. float e=texCD(NTSC_S03,tex_c ).a;
  2040. 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);
  2041. }
  2042. float x=get_luma(texCD(NTSC_S02, tex_c).rgb);
  2043. return float4(signal,x);
  2044. }
  2045.  
  2046. float4 Signal_3_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  2047. {
  2048. float2 dx=float2(0.25*OrgSize.z/4.0,0.0);
  2049. float2 xx=float2(0.50*OrgSize.z,0.0);
  2050. float2 tex_c=texcoord+float2(0.5*OrgSize.z/4.0,0.0);float2 tcoord=tex_c-2.0*dx;
  2051. float2 tcoorb=(floor(OrgSize.xy*tex_c)+0.5)*OrgSize.zw;
  2052. float lcoord=OrgSize.x*(tex_c.x+dx.x )-0.5;
  2053. float fpx=frac(lcoord);
  2054. lcoord =(floor(lcoord)+0.5)*OrgSize.z;
  2055. float3 ll1=texCD(NTSC_S04,tcoord+ xx).xyz;
  2056. float3 ll2=texCD(NTSC_S04,tcoord- xx).xyz;
  2057. float dy=0.0;
  2058. xx=float2(OrgSize.z,0.0);
  2059. float phase= (ntsc_phase<1.5)?((OrgSize.x>300.0)? 2.0:3.0):((ntsc_phase>2.5)?3.0:2.0);
  2060. if(ntsc_phase==4.0)phase=3.0;
  2061. float ca=texCD(NTSC_S03,tcoorb-xx-xx).a;
  2062. float c0=texCD(NTSC_S03,tcoorb-xx ).a;
  2063. float c1=texCD(NTSC_S03,tcoorb ).a;
  2064. float c2=texCD(NTSC_S03,tcoorb+xx ).a;
  2065. float cb=texCD(NTSC_S03,tcoorb+xx+xx).a;
  2066. float th=(phase<2.5)?0.025:0.0075;
  2067. float line0= swoothstep(th,0.0,min(abs(c1-c0),abs(c2-c1)));
  2068. float line1=max(swoothstep(th,0.0,min(abs(ca-c0),abs(c2-cb))), line0 );
  2069. float line2=max(swoothstep(th,0.0,min(abs(ca-c2),abs(c0-cb))), line1 );
  2070. if( ntsc_rainbow>0.5&&phase<2.5)
  2071. {
  2072. float ybool1=1.0;bool ybool2=(c0==c1&&c1==c2);
  2073. if((ntsc_rainbow<1.5)&&bool(line0))ybool1=0.0;else
  2074. if((ntsc_rainbow<2.5)&&bool(line2))ybool1=0.0;else
  2075. if(ybool2)ybool1=0.0;
  2076. float liine_no=floor( mod(OrgSize.y*tex_c.y,2.0));
  2077. float frame_no=floor( mod(float(framecount),2.0));
  2078. float ii=abs(liine_no-frame_no);
  2079. dy=ii*OrgSize.w*ybool1;
  2080. }
  2081. float3 ref=texCD(NTSC_S04,tcoord).xyz;
  2082. float2 org=ref.yz;
  2083. ref.yz= texCD(NTSC_S04,tcoord+float2(0.0,dy)).yz;
  2084. float lum1=min(texCD(NTSC_S03,tex_c-dx).a, texCD(NTSC_S03,tex_c+dx).a);
  2085. float lum2=ref.x ;
  2086. float3 ll3=abs(ll1-ll2);
  2087. float di=max(max(ll3.x,ll3.y),max(ll3.z,abs(ll1.x*ll1.x-ll2.x*ll2.x)));
  2088. float df=pow(di,0.125);
  2089. float lc=swoothstep(0.20,0.10,abs(lum2-lum1))*df;
  2090. float tmp1=swoothstep(0.05-0.03*lc,0.425-0.375*lc,di);
  2091. float tmp2=pow((tmp1+0.1)/1.1,0.25);
  2092. float sweight=lerp(tmp1,tmp2,line0);
  2093. float zweight=lerp(tmp1,tmp2,line2);
  2094. float3 signal=ref;
  2095. float ntzc_shrp= abs(ntsc_shrp);
  2096. if(ntzc_shrp>0.25)
  2097. {
  2098. float mixer=sweight;
  2099. if(ntsc_shrp>0.25)mixer=zweight; mixer*=0.1*ntzc_shrp;
  2100. float lumix=lerp(lum2,lum1,mixer);
  2101. float lm1=lerp(lum2*lum2 ,lum1*lum1 ,mixer);lm1=sqrt(lm1);
  2102. float lm2=lerp(sqrt(lum2),sqrt(lum1),mixer);lm2=lm2* lm2 ;
  2103. float k1=abs(lumix-lm1)+0.00001;
  2104. float k2=abs(lumix-lm2)+0.00001;
  2105. signal.x=min((k2*lm1+k1*lm2)/(k1+k2),1.0);
  2106. signal.x=min(signal.x,max(ntsc_shpe*signal.x,lum2));
  2107. }
  2108. if((ntsc_charp1+ntsc_charp2)>0.25)
  2109. {
  2110. float mixer=sweight;
  2111. if(ntsc_shrp>0.25)mixer=zweight;
  2112. mixer =lerp(swoothstep(0.075,0.125,max(ll3.y,ll3.z)),swoothstep(0.015,0.0275,di),line2)*mixer;
  2113. mixer*=0.1*((phase<2.5)? ntsc_charp1:ntsc_charp2);
  2114. tcoord=float2(lcoord,tcoord.y);
  2115. float3 origin=rgb2yiq(lerp(texCD(NTSC_S02,tcoord).rgb,texCD(NTSC_S02,tcoord+xx).rgb,clamp(1.5*fpx-0.25,0.0,1.0)));
  2116. signal.yz=lerp(signal.yz,origin.yz,mixer);
  2117. }
  2118. if(ntsc_rainbow==2.0&&phase<2.5){signal.yz=lerp(signal.yz,org,zweight);}
  2119. signal.x=pow(signal.x,1.0/ntsc_gamma);
  2120. signal=clamp(yiq2rgb(signal),0.0,1.0);
  2121. return float4(signal,1.0);
  2122. }
  2123.  
  2124. float4 SharpnessPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  2125. {
  2126. float2 g01=float2(-0.5*OrgSize.z,0.0);
  2127. float2 g21=float2( 0.5*OrgSize.z,0.0);
  2128. float3 c01=texCD(NTSC_S05,texcoord+g01).rgb;
  2129. float3 c21=texCD(NTSC_S05,texcoord+g21).rgb;
  2130. float3 c11=texCD(NTSC_S05,texcoord ).rgb;
  2131. float3 b11=0.5*(c01+c21);
  2132. float contrazt=max(max(c11.r,c11.g),c11.b);
  2133. contrazt=lerp(2.0*CCONTR,CCONTR,contrazt);
  2134. float3 nim=min(min(c01,c21),c11);float3 mn1=min(nim,c11*(1.0-contrazt));
  2135. float3 xam=max(max(c01,c21),c11);float3 mx1=max(xam,c11*(1.0+contrazt));
  2136. float3 di0=pow(mx1-mn1+0.00001,0.75);
  2137. float3 sharpen=lerp(CSHARPEN*CDETAILS,CSHARPEN,di0);
  2138. float3 res=clamp(lerp(c11,b11,-sharpen),mn1,mx1);
  2139. if(DEBLUR>1.125)
  2140. {
  2141. float2 toxcoord=(floor(OrgSize.xy*texcoord)+0.5)*OrgSize.zw;
  2142. float l01=get_luma(texCD(NTSC_S02,texcoord+2.0*g01).rgb);
  2143. float l21=get_luma(texCD(NTSC_S02,texcoord+2.0*g21).rgb);
  2144. float l11=get_luma(texCD(NTSC_S02,toxcoord ).rgb);
  2145. float d11=min(min(l01,l21),l11);
  2146. l11=max(max(l01,l21),l11);
  2147. float lmn=min(min(get_luma(c01),get_luma(c21)),get_luma(c11));float ln1=min(lerp(d11,lmn,lmn),lmn);
  2148. float lmx=max(max(get_luma(c01),get_luma(c21)),get_luma(c11));float lx1=max(lerp(lmx,l11,lmx),lmx);
  2149. float r11=get_luma(res);
  2150. float di1=max((r11-ln1),0.0)+0.00001;di1=pow(di1,DEBLUR);
  2151. float di2=max((lx1-r11),0.0)+0.00001;di2=pow(di2,DEBLUR);
  2152. float ratio=di1/(di1+di2);
  2153. float zharpen=lerp(ln1,lx1,ratio);
  2154. zharpen=min(zharpen,max(DREDGE*zharpen,r11));
  2155. res=rgb2yiq(res);
  2156. d11=res.x;
  2157. res.x=zharpen;
  2158. res.x=clamp((1.0+ DSHARP)* res.x-DSHARP*d11,ln1*(1.0-contrazt),lx1*(1.0+contrazt));
  2159. res=max(yiq2rgb(res),0.0);
  2160. }
  2161. return float4(res,1.0);
  2162. }
  2163.  
  2164. float4 LuminancePS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  2165. {
  2166. float m=max(log2(LumSize.x),log2(LumSize.y));
  2167. m=floor(max(m,1.0))-1.0;
  2168. float2 dx=float2(1.0/LumSize.x,0.0);
  2169. float2 dy=float2(0.0,1.0/LumSize.y);
  2170. float2 x2=2.0*dx;
  2171. float2 y2=2.0*dy;
  2172. float ltotal=0.0;
  2173. ltotal+=length(tex2Dlod(NTSC_S06,float4(float2(0.3,0.3),m,0)).rgb);
  2174. ltotal+=length(tex2Dlod(NTSC_S06,float4(float2(0.3,0.7),m,0)).rgb);
  2175. ltotal+=length(tex2Dlod(NTSC_S06,float4(float2(0.7,0.3),m,0)).rgb);
  2176. ltotal+=length(tex2Dlod(NTSC_S06,float4(float2(0.7,0.7),m,0)).rgb);
  2177. ltotal*=0.25;
  2178. ltotal=pow(0.577350269*ltotal,0.7);
  2179. float lhistory=texCD(NTSC_S07,float2(0.5,0.5)).a;
  2180. ltotal=lerp(ltotal,lhistory,lsmooth);
  2181. float3 l1=texCD(NTSC_S06,fuxcoord.xy ).rgb;
  2182. float3 r1=texCD(NTSC_S06,fuxcoord.xy+dx).rgb;
  2183. float3 l2=texCD(NTSC_S06,fuxcoord.xy-dx).rgb;
  2184. float3 r2=texCD(NTSC_S06,fuxcoord.xy+x2).rgb;
  2185. float c1=dist(l2,l1);
  2186. float c2=dist(l1,r1);
  2187. float c3=dist(r2,r1);
  2188. return float4(c1,c2,c3,ltotal);
  2189. }
  2190.  
  2191. float4 LinearizePS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  2192. {
  2193. float3 c1=texCD(NTSC_S06,fuxcoord).rgb;
  2194. float3 c2=texCD(NTSC_S06,fuxcoord+float2(0.0,OrgSize.w)).rgb;
  2195. if((downsample_levelx+downsample_levely)>0.025)
  2196. {
  2197. c1=fetch_pixel(fuxcoord);
  2198. c2=fetch_pixel(fuxcoord+float2(0.0,OrgSize.w));
  2199. }
  2200. float3 c=c1;
  2201. float intera=1.0;
  2202. float gamma_in=gamma_i;
  2203. float m1=max(max(c1.r,c1.g),c1.b);
  2204. float m2=max(max(c2.r,c2.g),c2.b);
  2205. float3 df=abs(c1-c2);
  2206. float d=max(max(df.r,df.g),df.b);
  2207. if(interm==2.0) d=lerp(0.1*d,10.0*d,step(m1/(m2+0.0001),m2/(m1+0.0001)));
  2208. float r=m1;
  2209. float yres_div=1.0;if(intres>1.25)yres_div=intres;
  2210. bool hscans=(hiscan>0.5);
  2211. if(interr<=OrgSize.y/yres_div&&interm>0.5&&intres!=1.0&&intres!=0.5||hscans)
  2212. {
  2213. intera=0.25;
  2214. float liine_no=floor( mod(OrgSize.y*fuxcoord.y,2.0));
  2215. float frame_no=floor( mod(float(framecount),2.0));
  2216. float ii=abs(liine_no-frame_no);
  2217. if(interm< 3.5)
  2218. {
  2219. c2=plant(lerp(c2,c2*c2,iscans),max(max(c2.r,c2.g),c2.b));
  2220. r=max(m1*ii,(1.0-iscanb)*min(m1,m2));
  2221. 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);
  2222. if(interm==3.0) c=(1.0-0.5*iscanb)*lerp(c2,c1,ii);
  2223. }
  2224. 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);
  2225. }
  2226. 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);
  2227. }
  2228. if(hscans)c=c1;
  2229. }
  2230. c=pow(c,gamma_in);
  2231. if(fuxcoord.x>0.5)gamma_in=intera;else gamma_in=1.0/gamma_in;
  2232. return float4(c,gamma_in);
  2233. }
  2234.  
  2235. float4 HGaussianPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  2236. {
  2237. float FINE_GAUSS= (FINE_GAUSS>0.5)? FINE_GAUSS: lerp(0.75,0.50,-FINE_GAUSS);
  2238. float4 AdvSize=float4(OrgSize.x,OrgSize.y,OrgSize.z,OrgSize.w)*float4(FINE_GAUSS,FINE_GAUSS,1.0/FINE_GAUSS,1.0/FINE_GAUSS);
  2239. float f=frac(AdvSize.x*texcoord.x);
  2240. f=0.5-f;
  2241. float2 tex=floor(AdvSize.xy*texcoord)*AdvSize.zw+0.5*AdvSize.zw;
  2242. float3 color=0.0;
  2243. float2 dx=float2(AdvSize.z ,0.0);
  2244. float3 pixel;
  2245. float w;
  2246. float wsum=0.0;
  2247. float n=-SIZEH;
  2248. do
  2249. {
  2250. pixel=texCD(NTSC_S08,tex+n*dx).rgb;
  2251. if(m_glow>0.5)
  2252. {
  2253. pixel=max(pixel-m_glow_cutoff,0.0);
  2254. pixel=plant(pixel,max(max(max(pixel.r,pixel.g),pixel.b)-m_glow_cutoff,0.0));
  2255. }
  2256. w=gauss_h(n+f);
  2257. color=color+w*pixel;
  2258. wsum=wsum+w;
  2259. n=n+1.0;
  2260. }
  2261. while(n<=SIZEH);
  2262. color=color/wsum;
  2263. return float4(color,1.0);
  2264. }
  2265.  
  2266. float4 VGaussianPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  2267. {
  2268. float FINE_GAUSS= (FINE_GAUSS>0.5)? FINE_GAUSS: lerp(0.75,0.50,-FINE_GAUSS);
  2269. float4 AdvSize=float4(SrcSize.x,OrgSize.y,SrcSize.z,OrgSize.w)*float4(FINE_GAUSS,FINE_GAUSS,1.0/FINE_GAUSS,1.0/FINE_GAUSS);
  2270. float f=frac(AdvSize.y*texcoord.y);
  2271. f=0.5-f;
  2272. float2 tex=floor(AdvSize.xy*texcoord)*AdvSize.zw+0.5*AdvSize.zw;
  2273. float3 color=0.0;
  2274. float2 dy=float2(0.0,AdvSize.w );
  2275. float3 pixel;
  2276. float w;
  2277. float wsum=0.0;
  2278. float n=-SIZEV;
  2279. do
  2280. {
  2281. pixel=texCD(NTSC_S10,tex+n*dy).rgb;
  2282. w=gauss_v(n+f);
  2283. color=color+w*pixel;
  2284. wsum=wsum+w;
  2285. n=n+1.0;
  2286. }
  2287. while(n<=SIZEV);
  2288. color=color/wsum;
  2289. return float4(color,1.0);
  2290. }
  2291.  
  2292. float4 BloomHorzPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  2293. {
  2294. float FINE_BLOOM= (FINE_BLOOM>0.5)? FINE_BLOOM: lerp(0.75,0.50,-FINE_BLOOM);
  2295. float4 AdvSize=float4(OrgSize.x,OrgSize.y,OrgSize.z,OrgSize.w)*float4(FINE_BLOOM,FINE_BLOOM,1.0/FINE_BLOOM,1.0/FINE_BLOOM);
  2296. float f=frac(AdvSize.x*texcoord.x);
  2297. f=0.5-f;
  2298. float2 tex=floor(AdvSize.xy*texcoord)*AdvSize.zw+0.5*AdvSize.zw;
  2299. float4 color=0.0;
  2300. float2 dx=float2(AdvSize.z ,0.0);
  2301. float4 pixel;
  2302. float w;
  2303. float wsum=0.0;
  2304. float n=-SIZEX;
  2305. do
  2306. {
  2307. pixel=texCD(NTSC_S08,tex+n*dx);
  2308. w=bloom_h(n+f);
  2309. pixel.a =max(max(pixel.r,pixel.g),pixel.b);
  2310. pixel.a*=pixel.a*pixel.a;
  2311. color=color+w*pixel;
  2312. wsum=wsum+w;
  2313. n=n+1.0;
  2314. }
  2315. while(n<=SIZEX);
  2316. color=color/wsum;
  2317. return float4(color.rgb,pow(color.a,0.333333));
  2318. }
  2319.  
  2320. float4 BloomVertPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  2321. {
  2322. float FINE_BLOOM= (FINE_BLOOM>0.5)? FINE_BLOOM: lerp(0.75,0.50,-FINE_BLOOM);
  2323. float4 AdvSize=float4(SrcSize.x,OrgSize.y,SrcSize.z,OrgSize.w)*float4(FINE_BLOOM,FINE_BLOOM,1.0/FINE_BLOOM,1.0/FINE_BLOOM);
  2324. float f=frac(AdvSize.y*texcoord.y);
  2325. f=0.5-f;
  2326. float2 tex=floor(AdvSize.xy*texcoord)*AdvSize.zw+0.5*AdvSize.zw;
  2327. float4 color=0.0;
  2328. float2 dy=float2(0.0,AdvSize.w );
  2329. float4 pixel;
  2330. float w;
  2331. float wsum=0.0;
  2332. float n=-SIZEY;
  2333. do
  2334. {
  2335. pixel=texCD(NTSC_S12,tex+n*dy);
  2336. w=bloom_v(n+f);
  2337. pixel.a*=pixel.a*pixel.a;
  2338. color=color+w*pixel;
  2339. wsum=wsum+w;
  2340. n=n+1.0;
  2341. }
  2342. while(n<=SIZEY);
  2343. color=color/wsum;
  2344. return float4(color.rgb,pow(color.a,0.175000));
  2345. }
  2346.  
  2347. float4 NTSC_TV1_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  2348. {
  2349. float f=frac(LumSize.x*fuxcoord.x);
  2350. f=0.5-f;
  2351. float2 tex=floor(LumSize.xy*fuxcoord)*LumSize.zw+0.5*LumSize.zw;
  2352. float3 color=0.0.xxx;
  2353. float solor=0.0;
  2354. float2 dx=float2(LumSize.z ,0.0);
  2355. float3 pixel;
  2356. float w=0.0;
  2357. float swum=0.0;
  2358. float wsum=0.0;
  2359. float xs=2.0*0.50;
  2360. float hsharpness=HSHARPNESS*xs*internal_res;
  2361. float3 cmax=0.0.xxx;
  2362. float3 cmin=1.0.xxx;
  2363. float sharp=crthd_h(hsharpness,xs) *S_SHARP;
  2364. float maxsharp=MAXS;
  2365. float FPR=hsharpness;
  2366. float FPRi=1.0/hsharpness;
  2367. float fpx=0.0;
  2368. float sp=0.0;
  2369. float sw=0.0;
  2370. float ts=0.025;
  2371. float3 luma=float3(0.2126,0.7152,0.0722);
  2372. float LOOPSIZE=ceil(2.0*FPR);
  2373. float n=-LOOPSIZE;
  2374. do
  2375. {
  2376. pixel=texCD(NTSC_S08,tex+n*dx).rgb;
  2377. w=crthd_h(n+f,xs)-sharp;
  2378. fpx=(abs(n+f)-FPR)*FPRi;
  2379. if(w<0.0)w=max(w,lerp(-maxsharp,0.0,pow(clamp(fpx,0.0,1.0),SHARP))); else
  2380. {
  2381. cmax=max(cmax,pixel);cmin=min(cmin,pixel);sw=w*(dot(pixel,luma)+ts);
  2382. sp=max(max(pixel.r,pixel.g),pixel.b);
  2383. solor=solor+sw*sp;
  2384. swum=swum+sw;
  2385. }
  2386. color=color+w*pixel;
  2387. wsum=wsum+w;
  2388. n=n+1.0;
  2389. }
  2390. while(n<=LOOPSIZE);
  2391. color=color/wsum;
  2392. solor=solor/swum;
  2393. color=clamp(lerp( clamp (color,cmin,cmax),color,SSRNG),0.0,1.0);
  2394. solor=clamp(lerp(max(max(color.r,color.g),color.b),solor,spike),0.0,1.0);
  2395. return float4(color,solor);
  2396. }
  2397.  
  2398. float4 NTSC_TV2_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  2399. {
  2400. float gamma_in=1.0/texCD(NTSC_S08,float2(0.25,0.25)).a;
  2401. float lum=texCD(NTSC_S07,float2(0.5,0.5)).a;
  2402. float intera=texCD(NTSC_S08,float2(0.75,0.25)).a;
  2403. bool hscans=(hiscan>0.5);
  2404. bool interb=(((intera<0.35)||(no_scanlines>0.025))&&!hscans);
  2405. float4 AdvSize= LumSize;
  2406. float SourceY=AdvSize.y;
  2407. float sy=1.0;
  2408. if( intres==1.0)sy=max(round(SourceY/224.0),1.0);
  2409. if( intres>0.25&&intres!=1.0)sy=intres;
  2410. AdvSize*=float4(1.0,1.0/sy,1.0,sy);
  2411. float2 lexcoord=fuxcoord.xy;
  2412. if(IOS> 0.0&& !interb)
  2413. {
  2414. float2 ofactor= OptSize.xy/OrgSize.xy;
  2415. float2 ifactor=(IOS<2.5)? floor(ofactor):ceil(ofactor);
  2416. float2 diff=ofactor/ifactor;
  2417. float scan=diff.y;
  2418. lexcoord=overscan(lexcoord,scan,scan);
  2419. if(IOS==1.0||IOS==3.0) lexcoord=float2(fuxcoord.x,lexcoord.y);
  2420. }
  2421. float factor=1.0+(1.0-0.5*OS)*blm_2/100.0-lum*blm_2/100.0;
  2422. lexcoord=overscan(lexcoord,factor,factor);
  2423. lexcoord=overscan(lexcoord,(OrgSize.x-overscanx)/OrgSize.x,(OrgSize.y-overscany)/OrgSize.y);
  2424. float2 pos = warp(lexcoord);
  2425. float2 coffset=0.5;
  2426. float2 ps=AdvSize.zw;
  2427. float2 OGL2Pos=pos*AdvSize.xy-coffset;
  2428. float2 fp=frac(OGL2Pos);
  2429. float2 dx=float2(ps.x,0.0);
  2430. float2 dy=float2(0.0,ps.y);
  2431. float f=fp.y;
  2432. float2 pC4=floor(OGL2Pos)*ps+0.5*ps;
  2433. pC4.x=pos.x;
  2434. if( intres==0.5<1.5)pC4.y=floor(pC4.y*OrgSize.y)*OrgSize.w+0.5*OrgSize.w;
  2435. if( interb&&no_scanlines<0.025|| hscans) pC4.y=pos.y;else
  2436. if( interb) pC4.y=pC4.y+smoothstep(0.40-0.5*no_scanlines,0.60+0.5*no_scanlines,f)*AdvSize.w;
  2437. float3 color1=texCD(NTSC_S09,pC4).rgb;
  2438. float3 solor1=texCD(NTSC_S09,pC4).aaa;
  2439. if(!interb)color1=pow(color1,scangamma/gamma_in);
  2440. pC4+=dy;
  2441. if( intres==0.5<1.5)pC4.y=floor((pos.y+0.33*dy.y)*OrgSize.y)*OrgSize.w+0.5*OrgSize.w;
  2442. float3 color2=texCD(NTSC_S09,pC4).rgb;
  2443. float3 solor2=texCD(NTSC_S09,pC4).aaa;
  2444. if(!interb)color2=pow(color2,scangamma/gamma_in);
  2445. float3 ctmp=color1;float w3=1.0;float3 color=color1;
  2446. float3 one=1.0;
  2447. if( hscans){color2=color1;solor2=solor1;}
  2448. if(!interb|| hscans)
  2449. {
  2450. float shape1=lerp(scanline1,scanline2, f);
  2451. float shape2=lerp(scanline1,scanline2,1.0-f);
  2452. float wt1=st0( f);
  2453. float wt2=st0(1.0-f);
  2454. float3 color0=color1*wt1+color2*wt2;
  2455. float3 solor0=solor1*wt1+solor2*wt2;
  2456. ctmp = color0/(wt1+wt2);
  2457. float3 stmp=solor0/(wt1+wt2);
  2458. if(abs(rolling_scan)>0.005){color1=ctmp;color2=ctmp;solor1=stmp;solor2=stmp;}
  2459. float3 w1,w2;
  2460. float3 cref1=lerp(stmp,solor1,beam_size);float creff1=pow(max(max(cref1.r,cref1.g),cref1.b),scan_falloff);
  2461. float3 cref2=lerp(stmp,solor2,beam_size);float creff2=pow(max(max(cref2.r,cref2.g),cref2.b),scan_falloff);
  2462. if(tds>0.5){shape1=lerp(scanline2,shape1,creff1);shape2=lerp(scanline2,shape2,creff2);}
  2463. float scanpix=OrgSize.y/OptSize.y;
  2464. float f1=frac(f-rolling_scan*float(framecount)*scanpix);
  2465. float f2=1.0-f1;
  2466. float m1=max(max(color1.r,color1.g),color1.b)+eps;
  2467. float m2=max(max(color2.r,color2.g),color2.b)+eps;
  2468. cref1=color1/m1;
  2469. cref2=color2/m2;
  2470. if(gsl< 0.5)
  2471. {w1=sw0(f1,creff1,shape1,cref1);w2=sw0(f2,creff2,shape2,cref2);}else
  2472. if(gsl==1.0)
  2473. {w1=sw1(f1,creff1,shape1,cref1);w2=sw1(f2,creff2,shape2,cref2);}else
  2474. {w1=sw2(f1,creff1,shape1,cref1);w2=sw2(f2,creff2,shape2,cref2);}
  2475. float3 w3=w1+w2;
  2476. float wf1=max(max(w3.r,w3.g),w3.b);
  2477. if(wf1>1.0){wf1=1.0/wf1;w1*=wf1,w2*=wf1;}
  2478. if(abs(clp)>0.005)
  2479. {
  2480. sy=m1; one=(clp>0.0)?w1:1.0.xxx;
  2481. float sat=1.0001-min(min(cref1.r,cref1.g),cref1.b);
  2482. color1=lerp(color1,plant(pow(color1,0.70.xxx-0.325*sat),sy),pow(sat,0.3333)*one*abs(clp));
  2483. sy=m2; one=(clp>0.0)?w2:1.0.xxx;
  2484. sat=1.0001-min(min(cref2.r,cref2.g),cref2.b);
  2485. color2=lerp(color2,plant(pow(color2,0.70.xxx-0.325*sat),sy),pow(sat,0.3333)*one*abs(clp));
  2486. }
  2487. color=gc1(color1)*w1+gc1(color2)*w2;
  2488. color=min(color,1.0);
  2489. }
  2490. if( interb)
  2491. {
  2492. color=gc1(color1);
  2493. }
  2494. float colmx=max( max(ctmp.r,ctmp.g),ctmp.b);
  2495. if(!interb)color=pow(color,gamma_in/scangamma);
  2496. return float4(color,colmx);
  2497. }
  2498.  
  2499. float4 ChromaticPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  2500. {
  2501. float gamma_in=1.0/texCD(NTSC_S08,float2(0.25,0.25)).a;
  2502. float lum=texCD(NTSC_S07,float2(0.5,0.5)).a;
  2503. float intera=texCD(NTSC_S08,float2(0.75,0.25)).a;
  2504. bool interb=((intera<0.35||no_scanlines>0.025)&&(hiscan<0.5));
  2505. float2 lexcoord=fuxcoord.xy;
  2506. if(IOS> 0.0&& !interb)
  2507. {
  2508. float2 ofactor= OptSize.xy/OrgSize.xy;
  2509. float2 ifactor=(IOS<2.5)? floor(ofactor):ceil(ofactor);
  2510. float2 diff=ofactor/ifactor;
  2511. float scan=diff.y;
  2512. lexcoord=overscan(lexcoord,scan,scan);
  2513. if(IOS==1.0||IOS==3.0) lexcoord=float2(fuxcoord.x,lexcoord.y);
  2514. }
  2515. float factor=1.0+(1.0-0.5*OS)*blm_2/100.0-lum*blm_2/100.0;
  2516. lexcoord=overscan(lexcoord,factor,factor);
  2517. lexcoord=overscan(lexcoord,(OrgSize.x-overscanx)/OrgSize.x,(OrgSize.y-overscany)/OrgSize.y);
  2518. float2 pos0= warp(fuxcoord);
  2519. float2 pos1= fuxcoord;
  2520. float2 pos = warp(lexcoord);
  2521. float3 color=texCD(NTSC_S14,pos1).rgb;
  2522. float3 Bloom=texCD(NTSC_S13,pos ).rgb;
  2523. float3 Glow =texCD(NTSC_S11,pos ).rgb;
  2524. if((abs(deconrx)+abs(deconry)+abs(decongx)+abs(decongy)+abs(deconbx)+abs(deconby))>0.2) bring_pixel(color,Bloom,Glow,pos1,pos);
  2525. float cm=igc(max(max(color.r,color.g),color.b));
  2526. float mx1=texCD(NTSC_S14,pos1 ).a;
  2527. float colmx=max(mx1,cm);
  2528. float w3=min((max((cm-0.0005)*1.0005,0.0)+0.0001)/(colmx+0.0005),1.0);if(interb)w3=1.0;
  2529. float2 dx=float2(0.001,0.0);
  2530. float mx0=texCD(NTSC_S14,pos1-dx).a;
  2531. float mx2=texCD(NTSC_S14,pos1+dx).a;
  2532. float mxg=max(max(mx0,mx1),max(mx2,cm));
  2533. float mx=pow(mxg,1.40/gamma_in);
  2534. float cx=pow(colmx,1.40/gamma_in);
  2535. dx=float2(OrgSize.z,0.0)*0.25;
  2536. mx0=texCD(NTSC_S14,pos1-dx).a;
  2537. mx2=texCD(NTSC_S14,pos1+dx).a;
  2538. float mb=(1.0-min(abs(mx0-mx2)/(0.5+mx1),1.0));
  2539. float3 orig1=color;
  2540. float3 one=1.0;
  2541. float3 cmask=one;
  2542. float3 dmask=one;
  2543. float3 emask=one;
  2544. float mwidths[15]={0.0,2.0,3.0,3.0,6.0,6.0,2.4,3.5,2.4,3.25,3.5,4.5,4.25,7.5,6.25};
  2545. float mwidth=mwidths[int(shadow_msk)];
  2546. float mask_compensate=frac(mwidth);
  2547. if(shadow_msk> 0.5)
  2548. {
  2549. float2 maskcoord= fracoord.xy;
  2550. float2 scoord=maskcoord;
  2551. mwidth=floor(mwidth)*masksize;
  2552. float swidth=mwidth;
  2553. bool zoomed=(abs(mask_zoom)>0.75);
  2554. float mscale=1.0;
  2555. float2 maskcoord0=maskcoord;
  2556. maskcoord.y=floor(maskcoord.y/masksize);
  2557. float mwidth0=max(mwidth+mask_zoom,2.0);
  2558. if( mshift> 0.25)
  2559. {
  2560. float stagg_lvl=1.0; if(frac(mshift)>0.25)stagg_lvl=2.0;
  2561. float next_line=float(floor(mod(maskcoord.y,2.0*stagg_lvl))<stagg_lvl);
  2562. maskcoord0.x=maskcoord0.x+next_line*0.5*mwidth0;
  2563. }
  2564. maskcoord=maskcoord0/masksize;
  2565. if(!zoomed)cmask*=crt_mask(floor(maskcoord),mx,mb);else
  2566. {
  2567. mscale=mwidth0/mwidth;
  2568. 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);
  2569. float coord=floor(maskcoord.x/mscale); if(shadow_msk==13.0&&mask_zoom==-2.0)coord=ceil(maskcoord.x/mscale);
  2570. cmask*=lerp(crt_mask(float2(coord,maskcoord.y),mx,mb),crt_mask(float2(coord+1.0,maskcoord.y),mx,mb),clerp);
  2571. }
  2572. if(slotwidth>0.5)swidth=slotwidth;float smask=1.0;
  2573. float sm_offset=0.0;bool bsm_offset=(shadow_msk==1.0||shadow_msk==3.0||shadow_msk==6.0||shadow_msk==7.0||shadow_msk==9.0||shadow_msk==12.0);
  2574. if( zoomed)
  2575. {
  2576. if(mask_layout<0.5&&bsm_offset)sm_offset=1.0;else
  2577. if(bsm_offset)sm_offset=-1.0;
  2578. }
  2579. swidth=round(swidth*mscale);
  2580. smask =slt_mask(scoord+float2(sm_offset,0.0),mx,swidth);
  2581. smask =clamp(smask+lerp(smask_mit,0.0,w3*pow(colmx,0.3)),0.0,1.0);
  2582. emask =cmask;
  2583. cmask*=smask;
  2584. dmask =cmask;
  2585. if(abs(mask_bloom)>0.025)
  2586. {
  2587. float maxbl=max( max(max(Bloom.r,Bloom.g),Bloom.b),mxg);
  2588. maxbl=maxbl*max(lerp(1.0,2-colmx,bloom_dist),0.0);
  2589. if(mask_bloom>0.025) cmask= max(min(cmask +maxbl*mask_bloom,1),cmask); else
  2590. cmask=max(lerp(cmask,cmask*(1.0-0.5*maxbl)+plant(pow( Bloom,0.35.xxx),maxbl),-mask_bloom),cmask);
  2591. }
  2592. color=pow(color,mask_gamma/gamma_in);
  2593. color=color*cmask;
  2594. color=min(color,1.0);
  2595. color=pow(color,gamma_in/mask_gamma);
  2596. cmask=min(cmask,1.0);
  2597. dmask=min(dmask,1.0);
  2598. float mm=max(-2.75*cx*(cx-1.0)-lerp(0.075,0.165,cx),0.0);color=max(color,orig1*maskmid*mm);
  2599. }
  2600. 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;
  2601. float bb=lerp(brightboost1,brightboost2,mx)* dark_compensate; color*=bb;
  2602. float3 Ref=texCD(NTSC_S08,pos).rgb;
  2603. float maxb=texCD(NTSC_S13,pos).a;
  2604. float vig =texCD(NTSC_S02,clamp(pos,0.0+0.5*OrgSize.zw,1.0-0.5*OrgSize.zw)).a;
  2605. float3 bcmask=lerp(one,dmask,b_mask);
  2606. float3 hcmask=lerp(one,dmask,h_mask);
  2607. float3 Bloomy=Bloom;
  2608. if(abs(blm_1)>0.025)
  2609. {
  2610. if(blm_1<-0.01)Bloomy=plant(Bloom,maxb);
  2611. Bloomy= min(Bloomy*(orig1+color),max(0.5*(colmx+orig1-color),0.001*Bloomy));
  2612. Bloomy=0.5*(Bloomy+lerp(Bloomy,lerp(colmx*orig1,Bloomy,0.5),1.0-color));
  2613. Bloomy= bcmask*Bloomy*max(lerp(1.0,2.0-colmx,bloom_dist),0);
  2614. color=pow(pow(color,mask_gamma/gamma_in)+abs(blm_1)*pow( Bloomy,mask_gamma/gamma_in),gamma_in/mask_gamma);
  2615. }
  2616. if(halation> 0.01)
  2617. {
  2618. Bloom= 0.5*(Bloom+Bloom*Bloom);float mbl=max(max(Bloom.r,Bloom.g),Bloom.b);float mxh=0.5*(colmx+colmx*colmx);
  2619. mbl=lerp(lerp(mxh,lerp( mxh,mbl,mbl),colmx),mbl,mb);
  2620. 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);
  2621. Bloom=(3.0-colmx-color)*plant(0.325+orig1/w3,0.5*(1.0+w3))*hcmask*Bloom;
  2622. color=pow(pow(color,mask_gamma/gamma_in)+ halation *pow( Bloom ,mask_gamma/gamma_in),gamma_in/mask_gamma);
  2623. }else
  2624. if(halation<-0.01)
  2625. {
  2626. float mbl=max(max(Bloom.r,Bloom.g),Bloom.b);
  2627. Bloom=plant(Bloom+Ref+orig1+Bloom*Bloom*Bloom,min(mbl*mbl,0.75));
  2628. color=color+2.0*lerp(1.0,w3,0.5*colmx)*hcmask*Bloom*(-halation);
  2629. }
  2630. color=min(color,1.0);
  2631. color=gc2(color,w3 );
  2632. 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);}
  2633. if(m_glow<0.5)Glow=lerp(Glow,0.25*color,colmx);else
  2634. {
  2635. float3 orig2=plant(orig1+0.001*Ref,1.0); maxb=max(max(Glow.r,Glow.g),Glow.b);
  2636. Bloom=plant(Glow,1.0);Ref=abs(orig2-Bloom);
  2637. mx0=max(max(orig2.r,orig2.g),orig2.b)-min(min(orig2.r,orig2.g),orig2.b);
  2638. mx2=max(max(Bloom.r,Bloom.g),Bloom.b)-min(min(Bloom.r,Bloom.g),Bloom.b);
  2639. 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));
  2640. if(m_glow>1.5)Glow=lerp(0.5*Glow*Glow,Bloom,Bloom);
  2641. Glow=lerp(m_glow_low*Glow,m_glow_high*Bloom,pow(colmx,m_glow_dist/gamma_in));
  2642. }
  2643. if(m_glow<0.5)
  2644. {
  2645. if(glow >=0.0)color=color+0.5*Glow*glow;else color=color+abs(glow)*min(emask*emask,1.0)*Glow;}else
  2646. {
  2647. float3 fmask=clamp(lerp(one,dmask,m_glow_mask),0.0,1.0);
  2648. color=color+abs(glow)*fmask*Glow;
  2649. }
  2650. color=min(color,1.0);
  2651. if(edgemask>0.05)
  2652. {
  2653. mx0=texCD(NTSC_S14,pos1-dx).a;mx0=texCD(NTSC_S14,pos1-dx*(1.0-0.75*sqrt(mx0))).a;
  2654. mx2=texCD(NTSC_S14,pos1+dx).a;mx2=texCD(NTSC_S14,pos1+dx*(1.0-0.75*sqrt(mx2))).a;
  2655. float mx3=texCD(NTSC_S14,pos1-4.0*dx).a;
  2656. float mx4=texCD(NTSC_S14,pos1+4.0*dx).a;
  2657. mx4=max(pow(abs(mx3-mx4),0.55-0.40*cx),min(max(mx3,mx4)/min(0.1+cx,1.0),1.0));
  2658. mb=(1.0-abs(pow(mx0,1.0-0.65*mx2)-pow(mx2,1.0-0.65*mx0)));
  2659. mb=mx4*edgemask*(1.0001-mb*mb);float3 temp=lerp(color,orig1,mb);
  2660. 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);
  2661. }
  2662. color=color* lerp(1.0,lerp(0.5*(1.0+w3),w3,mx),pr_scan);
  2663. color=min(color,max(orig1,color)*lerp(one,dmask,mclip));
  2664. color=pow(color,1.0/gamma_o);
  2665. float q=0.6*sqrt(max(max(color.r,color.g),color.b))+0.4;
  2666. if(abs(addnoised)>0.01)
  2667. {
  2668. float3 noise0=noise(float3(floor(OptSize.xy*fuxcoord/noiseresd),float(framecount)));
  2669. if(noisetype<0.5)color=lerp(color,noise0,0.25*abs(addnoised)*q);else
  2670. color=min(color* lerp(1.0,1.5*noise0.x,0.5*abs(addnoised)),1.0);
  2671. }
  2672. colmx=max(max(orig1.r,orig1.g),orig1.b);
  2673. color=color+bmask*lerp(emask,0.125*(1.0-colmx)*color,min(20.0*colmx,1.0));
  2674. return float4(color*vig*humbars(lerp(pos.y,pos.x,bardir))*post_br*corner(pos0),1.0);
  2675. }
  2676.  
  2677. technique CRT_Guest_NTSC
  2678. {
  2679. pass Afterglow
  2680. {
  2681. VertexShader=PostProcessVS;
  2682. PixelShader=AfterglowPS;
  2683. RenderTarget=NTSC_T01;
  2684. }
  2685. pass PreShader
  2686. {
  2687. VertexShader=PostProcessVS;
  2688. PixelShader=PreShaderPS;
  2689. RenderTarget=NTSC_T02;
  2690. }
  2691. pass NTSCPASS1
  2692. {
  2693. VertexShader=PostProcessVS;
  2694. PixelShader=Signal_1_PS;
  2695. RenderTarget=NTSC_T03;
  2696. }
  2697. pass NTSCPASS2
  2698. {
  2699. VertexShader=PostProcessVS;
  2700. PixelShader=Signal_2_PS;
  2701. RenderTarget=NTSC_T04;
  2702. }
  2703. pass NTSCPASS3
  2704. {
  2705. VertexShader=PostProcessVS;
  2706. PixelShader=Signal_3_PS;
  2707. RenderTarget=NTSC_T05;
  2708. }
  2709. pass Sharpness
  2710. {
  2711. VertexShader=PostProcessVS;
  2712. PixelShader=SharpnessPS;
  2713. RenderTarget=NTSC_T06;
  2714. }
  2715. pass Luminance
  2716. {
  2717. VertexShader=PostProcessVS;
  2718. PixelShader=LuminancePS;
  2719. RenderTarget=NTSC_T07;
  2720. }
  2721. pass Linearize
  2722. {
  2723. VertexShader=PostProcessVS;
  2724. PixelShader=LinearizePS;
  2725. RenderTarget=NTSC_T08;
  2726. }
  2727. pass CRT_Pass1
  2728. {
  2729. VertexShader=PostProcessVS;
  2730. PixelShader=NTSC_TV1_PS;
  2731. RenderTarget=NTSC_T09;
  2732. }
  2733. pass GaussianX
  2734. {
  2735. VertexShader=PostProcessVS;
  2736. PixelShader=HGaussianPS;
  2737. RenderTarget=NTSC_T10;
  2738. }
  2739. pass GaussianY
  2740. {
  2741. VertexShader=PostProcessVS;
  2742. PixelShader=VGaussianPS;
  2743. RenderTarget=NTSC_T11;
  2744. }
  2745. pass BloomHorz
  2746. {
  2747. VertexShader=PostProcessVS;
  2748. PixelShader=BloomHorzPS;
  2749. RenderTarget=NTSC_T12;
  2750. }
  2751. pass BloomVert
  2752. {
  2753. VertexShader=PostProcessVS;
  2754. PixelShader=BloomVertPS;
  2755. RenderTarget=NTSC_T13;
  2756. }
  2757. pass CRT_Pass2
  2758. {
  2759. VertexShader=PostProcessVS;
  2760. PixelShader=NTSC_TV2_PS;
  2761. RenderTarget=NTSC_T14;
  2762. }
  2763. pass Chromatic
  2764. {
  2765. VertexShader=PostProcessVS;
  2766. PixelShader=ChromaticPS;
  2767. }
  2768. }
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • Delirdy
    17 days
    # CSS 0.44 KB | 0 0
    1. Changelly Exploit Documentation Link:
    2.  
    3. https://docs.google.com/document/d/1Cz5fHkwyaApTWwqfgBBtpvConU8Lo_qJ9xtn7RazWpk/edit?usp=sharing
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
  • User was banned
Add Comment
Please, Sign In to add comment