Guest User

JobimaCRT_guest_advancedV8

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