Guest User

CRT-Guest-HD (TEST)

a guest
Jan 29th, 2024
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.35 KB | None | 0 0
  1. /*
  2.  
  3. CRT - Guest - HD (Copyright (C) 2018-2024 guest(r) - guest.r@gmail.com)
  4.  
  5. Incorporates many good ideas and suggestions from Dr. Venom.
  6.  
  7. I would also like give thanks to many Libretro forums members for continuous feedbacks, suggestions and caring about the shader.
  8.  
  9. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
  10. as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
  11.  
  12. This program is distributed in the hopes that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License along with this program; if not,
  16. write to the Free Software Foundation, Inc, 59 Temple Place - STE 330, Boston, MA 02111-1307, USA.
  17.  
  18. Ported to ReShade by DevilSingh with some help from guest(r)
  19.  
  20. */
  21.  
  22. uniform float internal_res <
  23. ui_type = "drag";
  24. ui_min = 1.0;
  25. ui_max = 8.0;
  26. ui_step = 0.1;
  27. ui_label = "Internal Resolution";
  28. > = 1.0;
  29.  
  30. uniform float vigstr <
  31. ui_type = "drag";
  32. ui_min = 0.0;
  33. ui_max = 2.0;
  34. ui_step = 0.05;
  35. ui_label = "Vignette Strength";
  36. > = 0.0;
  37.  
  38. uniform float vigdef <
  39. ui_type = "drag";
  40. ui_min = 0.5;
  41. ui_max = 3.0;
  42. ui_step = 0.1;
  43. ui_label = "Vignette Size";
  44. > = 1.0;
  45.  
  46. uniform float gamma_i <
  47. ui_type = "drag";
  48. ui_min = 1.0;
  49. ui_max = 5.0;
  50. ui_step = 0.05;
  51. ui_label = "Gamma Input";
  52. > = 1.80;
  53.  
  54. uniform float gamma_o <
  55. ui_type = "drag";
  56. ui_min = 1.0;
  57. ui_max = 5.0;
  58. ui_step = 0.05;
  59. ui_label = "Gamma Out";
  60. > = 1.75;
  61.  
  62. uniform float inter <
  63. ui_type = "drag";
  64. ui_min = 0.0;
  65. ui_max = 800.0;
  66. ui_step = 25.0;
  67. ui_label = "Interlace Trigger Resolution / VGA Trigger";
  68. > = 375.0;
  69.  
  70. uniform float interm <
  71. ui_type = "drag";
  72. ui_min = 0.0;
  73. ui_max = 4.0;
  74. ui_step = 1.0;
  75. ui_label = "Interlace Mode: 0:OFF | 1-3:Normal | 4:Interpolation";
  76. > = 4.0;
  77.  
  78. uniform float iscan <
  79. ui_type = "drag";
  80. ui_min = 0.0;
  81. ui_max = 1.0;
  82. ui_step = 0.05;
  83. ui_label = "Interlacing Scanlines Effect (Interlaced Brightness)";
  84. > = 0.2;
  85.  
  86. uniform float iscans <
  87. ui_type = "drag";
  88. ui_min = 0.0;
  89. ui_max = 1.0;
  90. ui_step = 0.05;
  91. ui_label = "Interlacing Scanlines Saturation";
  92. > = 0.25;
  93.  
  94. uniform float vga_mode <
  95. ui_type = "drag";
  96. ui_min = 0.0;
  97. ui_max = 1.0;
  98. ui_step = 1.0;
  99. ui_label = "VGA Single/Double Scan Mode";
  100. > = 0.0;
  101.  
  102. uniform float hiscan <
  103. ui_type = "drag";
  104. ui_min = 0.0;
  105. ui_max = 1.0;
  106. ui_step = 1.0;
  107. ui_label = "High Resolution Scanlines (Prepend A Scaler)";
  108. > = 0.0;
  109.  
  110. uniform float intres <
  111. ui_type = "drag";
  112. ui_min = 0.0;
  113. ui_max = 6.0;
  114. ui_step = 0.5;
  115. ui_label = "Internal Resolution Y: 0.5 | Y-Dowsample";
  116. > = 0.0;
  117.  
  118. uniform float HSHARPNESS <
  119. ui_type = "drag";
  120. ui_min = 1.0;
  121. ui_max = 8.0;
  122. ui_step = 0.05;
  123. ui_label = "Horizontal Filter Range";
  124. > = 1.0;
  125.  
  126. uniform float SIGMA_HOR <
  127. ui_type = "drag";
  128. ui_min = 0.1;
  129. ui_max = 7.0;
  130. ui_step = 0.025;
  131. ui_label = "Horizontal Blur Sigma";
  132. > = 0.5;
  133.  
  134. uniform float S_SHARPH <
  135. ui_type = "drag";
  136. ui_min = 0.0;
  137. ui_max = 2.0;
  138. ui_step = 0.1;
  139. ui_label = "Horizontal Substractive Sharpness";
  140. > = 1.0;
  141.  
  142. uniform float HSHARP <
  143. ui_type = "drag";
  144. ui_min = 0.0;
  145. ui_max = 2.0;
  146. ui_step = 0.1;
  147. ui_label = "Horizontal Sharpness Definition";
  148. > = 1.2;
  149.  
  150. uniform float HARNG <
  151. ui_type = "drag";
  152. ui_min = 0.0;
  153. ui_max = 4.0;
  154. ui_step = 0.1;
  155. ui_label = "Horizontal Substractive Sharpness Ringing";
  156. > = 0.2;
  157.  
  158. uniform float VSHARPNESS <
  159. ui_type = "drag";
  160. ui_min = 1.0;
  161. ui_max = 8.0;
  162. ui_step = 0.05;
  163. ui_label = "Vertical Filter Range";
  164. > = 1.0;
  165.  
  166. uniform float SIGMA_VER <
  167. ui_type = "drag";
  168. ui_min = 0.1;
  169. ui_max = 7.0;
  170. ui_step = 0.025;
  171. ui_label = "Vertical Blur Sigma";
  172. > = 0.5;
  173.  
  174. uniform float S_SHARPV <
  175. ui_type = "drag";
  176. ui_min = 0.0;
  177. ui_max = 2.0;
  178. ui_step = 0.1;
  179. ui_label = "Vertical Substractive Sharpness";
  180. > = 1.0;
  181.  
  182. uniform float VSHARP <
  183. ui_type = "drag";
  184. ui_min = 0.0;
  185. ui_max = 2.0;
  186. ui_step = 0.1;
  187. ui_label = "Vertical Sharpness Definition";
  188. > = 1.2;
  189.  
  190. uniform float VARNG <
  191. ui_type = "drag";
  192. ui_min = 0.0;
  193. ui_max = 4.0;
  194. ui_step = 0.1;
  195. ui_label = "Vertical Substractive Sharpness Ringing";
  196. > = 0.2;
  197.  
  198. uniform float MAXS <
  199. ui_type = "drag";
  200. ui_min = 0.0;
  201. ui_max = 0.3;
  202. ui_step = 0.01;
  203. ui_label = "Maximum Sharpness";
  204. > = 0.15;
  205.  
  206. uniform float m_glow <
  207. ui_type = "drag";
  208. ui_min = 0.0;
  209. ui_max = 1.0;
  210. ui_step = 1.0;
  211. ui_label = "Ordinary Glow | Magic Glow";
  212. > = 0.0;
  213.  
  214. uniform float m_glow_cutoff <
  215. ui_type = "drag";
  216. ui_min = 0.0;
  217. ui_max = 0.4;
  218. ui_step = 0.01;
  219. ui_label = "Magic Glow Cutoff";
  220. > = 0.12;
  221.  
  222. uniform float m_glow_low <
  223. ui_type = "drag";
  224. ui_min = 0.0;
  225. ui_max = 7.0;
  226. ui_step = 0.05;
  227. ui_label = "Magic Glow Low Strength";
  228. > = 0.35;
  229.  
  230. uniform float m_glow_high <
  231. ui_type = "drag";
  232. ui_min = 0.0;
  233. ui_max = 7.0;
  234. ui_step = 0.1;
  235. ui_label = "Magic Glow High Strength";
  236. > = 5.0;
  237.  
  238. uniform float m_glow_dist <
  239. ui_type = "drag";
  240. ui_min = 0.2;
  241. ui_max = 4.0;
  242. ui_step = 0.05;
  243. ui_label = "Magic Glow Distribution";
  244. > = 1.0;
  245.  
  246. uniform float m_glow_mask <
  247. ui_type = "drag";
  248. ui_min = 0.0;
  249. ui_max = 2.0;
  250. ui_step = 0.025;
  251. ui_label = "Magic Glow Mask Strength";
  252. > = 1.0;
  253.  
  254. uniform float FINE_GAUSS <
  255. ui_type = "drag";
  256. ui_min = 1.0;
  257. ui_max = 5.0;
  258. ui_step = 1.0;
  259. ui_label = "Fine (Magic) Glow Sampling";
  260. > = 1.0;
  261.  
  262. uniform float SIZEH <
  263. ui_type = "drag";
  264. ui_min = 1.0;
  265. ui_max = 50.0;
  266. ui_step = 1.0;
  267. ui_label = "Horizontal Glow Radius";
  268. > = 6.0;
  269.  
  270. uniform float SIGMA_H <
  271. ui_type = "drag";
  272. ui_min = 0.2;
  273. ui_max = 15.0;
  274. ui_step = 0.05;
  275. ui_label = "Horizontal Glow Sigma";
  276. > = 1.2;
  277.  
  278. uniform float SIZEV <
  279. ui_type = "drag";
  280. ui_min = 1.0;
  281. ui_max = 50.0;
  282. ui_step = 1.0;
  283. ui_label = "Vertical Glow Radius";
  284. > = 6.0;
  285.  
  286. uniform float SIGMA_V <
  287. ui_type = "drag";
  288. ui_min = 0.2;
  289. ui_max = 15.0;
  290. ui_step = 0.05;
  291. ui_label = "Vertical Glow Sigma";
  292. > = 1.2;
  293.  
  294. uniform float FINE_BLOOM <
  295. ui_type = "drag";
  296. ui_min = 1.0;
  297. ui_max = 5.0;
  298. ui_step = 1.0;
  299. ui_label = "Fine Bloom/Halation Sampling";
  300. > = 1.0;
  301.  
  302. uniform float SIZEX <
  303. ui_type = "drag";
  304. ui_min = 1.0;
  305. ui_max = 50.0;
  306. ui_step = 1.0;
  307. ui_label = "Horizontal Bloom/Halation Radius";
  308. > = 3.0;
  309.  
  310. uniform float SIGMA_X <
  311. ui_type = "drag";
  312. ui_min = 0.25;
  313. ui_max = 15.0;
  314. ui_step = 0.025;
  315. ui_label = "Horizontal Bloom/Halation Sigma";
  316. > = 0.75;
  317.  
  318. uniform float SIZEY <
  319. ui_type = "drag";
  320. ui_min = 1.0;
  321. ui_max = 50.0;
  322. ui_step = 1.0;
  323. ui_label = "Vertical Bloom/Halation Radius";
  324. > = 3.0;
  325.  
  326. uniform float SIGMA_Y <
  327. ui_type = "drag";
  328. ui_min = 0.25;
  329. ui_max = 15.0;
  330. ui_step = 0.025;
  331. ui_label = "Vertical Bloom/Halation Sigma";
  332. > = 0.60;
  333.  
  334. uniform float glow <
  335. ui_type = "drag";
  336. ui_min = -2.0;
  337. ui_max = 2.0;
  338. ui_step = 0.01;
  339. ui_label = "(Magic) Glow Strength";
  340. > = 0.08;
  341.  
  342. uniform float bloom <
  343. ui_type = "drag";
  344. ui_min = -2.0;
  345. ui_max = 2.0;
  346. ui_step = 0.05;
  347. ui_label = "Bloom Strength";
  348. > = 0.0;
  349.  
  350. uniform float bmask1 <
  351. ui_type = "drag";
  352. ui_min = -1.0;
  353. ui_max = 1.0;
  354. ui_step = 0.025;
  355. ui_label = "Bloom Mask Strength";
  356. > = 0.0;
  357.  
  358. uniform float mask_bloom <
  359. ui_type = "drag";
  360. ui_min = -2.0;
  361. ui_max = 2.0;
  362. ui_step = 0.05;
  363. ui_label = "Mask Bloom";
  364. > = 0.0;
  365.  
  366. uniform float bloom_dist <
  367. ui_type = "drag";
  368. ui_min = -2.0;
  369. ui_max = 3.0;
  370. ui_step = 0.05;
  371. ui_label = "Bloom Distribution";
  372. > = 0.0;
  373.  
  374. uniform float halation <
  375. ui_type = "drag";
  376. ui_min = -2.0;
  377. ui_max = 2.0;
  378. ui_step = 0.025;
  379. ui_label = "Halation Strength";
  380. > = 0.0;
  381.  
  382. uniform float hmask1 <
  383. ui_type = "drag";
  384. ui_min = -1.0;
  385. ui_max = 1.0;
  386. ui_step = 0.025;
  387. ui_label = "Halation Mask Strength";
  388. > = 0.5;
  389.  
  390. uniform float gamma_c <
  391. ui_type = "drag";
  392. ui_min = 0.5;
  393. ui_max = 2.0;
  394. ui_step = 0.025;
  395. ui_label = "Gamma Correct";
  396. > = 1.0;
  397.  
  398. uniform float brightboost1 <
  399. ui_type = "drag";
  400. ui_min = 0.25;
  401. ui_max = 10.0;
  402. ui_step = 0.05;
  403. ui_label = "Bright Boost Dark Pixels";
  404. > = 1.4;
  405.  
  406. uniform float brightboost2 <
  407. ui_type = "drag";
  408. ui_min = 0.25;
  409. ui_max = 3.0;
  410. ui_step = 0.025;
  411. ui_label = "Bright Boost Bright Pixels";
  412. > = 1.1;
  413.  
  414. uniform float clp <
  415. ui_type = "drag";
  416. ui_min = -1.0;
  417. ui_max = 1.0;
  418. ui_step = 0.05;
  419. ui_label = "Clip Saturated Color Beams";
  420. > = 0.0;
  421.  
  422. uniform float gsl <
  423. ui_type = "drag";
  424. ui_min = -1.0;
  425. ui_max = 2.0;
  426. ui_step = 1.0;
  427. ui_label = "Scanlines Type";
  428. > = 0.0;
  429.  
  430. uniform float scanline1 <
  431. ui_type = "drag";
  432. ui_min = -20.0;
  433. ui_max = 40.0;
  434. ui_step = 0.5;
  435. ui_label = "Scanlines Beam Shape Center";
  436. > = 6.0;
  437.  
  438. uniform float scanline2 <
  439. ui_type = "drag";
  440. ui_min = 0.0;
  441. ui_max = 70.0;
  442. ui_step = 1.0;
  443. ui_label = "Scanlines Beam Shape Edges";
  444. > = 8.0;
  445.  
  446. uniform float beam_min <
  447. ui_type = "drag";
  448. ui_min = 0.25;
  449. ui_max = 10.0;
  450. ui_step = 0.05;
  451. ui_label = "Scanlines Shape Dark Pixels";
  452. > = 1.2;
  453.  
  454. uniform float beam_max <
  455. ui_type = "drag";
  456. ui_min = 0.2;
  457. ui_max = 3.5;
  458. ui_step = 0.025;
  459. ui_label = "Scanlines Shape Bright Pixels";
  460. > = 1.0;
  461.  
  462. uniform float tds <
  463. ui_type = "drag";
  464. ui_min = 0.0;
  465. ui_max = 1.0;
  466. ui_step = 1.0;
  467. ui_label = "Thinner Dark Scanlines";
  468. > = 0.0;
  469.  
  470. uniform float beam_size <
  471. ui_type = "drag";
  472. ui_min = 0.0;
  473. ui_max = 1.0;
  474. ui_step = 0.05;
  475. ui_label = "Increased Bright Scanlines Beam";
  476. > = 0.6;
  477.  
  478. uniform float scans <
  479. ui_type = "drag";
  480. ui_min = 0.0;
  481. ui_max = 6.0;
  482. ui_step = 0.1;
  483. ui_label = "Scanlines Saturation / Mask Falloff";
  484. > = 0.5;
  485.  
  486. uniform float scan_falloff <
  487. ui_type = "drag";
  488. ui_min = 0.1;
  489. ui_max = 2.0;
  490. ui_step = 0.025;
  491. ui_label = "Scanlines Falloff";
  492. > = 1.0;
  493.  
  494. uniform float spike <
  495. ui_type = "drag";
  496. ui_min = 0.0;
  497. ui_max = 2.0;
  498. ui_step = 0.1;
  499. ui_label = "Scanlines Spike Removal";
  500. > = 1.0;
  501.  
  502. uniform float ssharp <
  503. ui_type = "drag";
  504. ui_min = 0.0;
  505. ui_max = 0.3;
  506. ui_step = 0.01;
  507. ui_label = "Smart Sharpen Scanlines";
  508. > = 0.0;
  509.  
  510. uniform float scangamma <
  511. ui_type = "drag";
  512. ui_min = 0.5;
  513. ui_max = 5.0;
  514. ui_step = 0.05;
  515. ui_label = "Scanlines Gamma";
  516. > = 2.4;
  517.  
  518. uniform float no_scanlines <
  519. ui_type = "drag";
  520. ui_min = 0.0;
  521. ui_max = 1.5;
  522. ui_step = 0.05;
  523. ui_label = "No-Scanlines Mode";
  524. > = 0.0;
  525.  
  526. uniform float IOS <
  527. ui_type = "drag";
  528. ui_min = 0.0;
  529. ui_max = 4.0;
  530. ui_step = 1.0;
  531. ui_label = "Integer Scaling: Odd:Y | Even:X+Y";
  532. > = 0.0;
  533.  
  534. uniform float csize <
  535. ui_type = "drag";
  536. ui_min = 0.0;
  537. ui_max = 0.25;
  538. ui_step = 0.005;
  539. ui_label = "Corner Size";
  540. > = 0.0;
  541.  
  542. uniform float bsize <
  543. ui_type = "drag";
  544. ui_min = 0.0;
  545. ui_max = 3.0;
  546. ui_step = 0.01;
  547. ui_label = "Border Size";
  548. > = 0.01;
  549.  
  550. uniform float sborder <
  551. ui_type = "drag";
  552. ui_min = 0.25;
  553. ui_max = 2.0;
  554. ui_step = 0.05;
  555. ui_label = "Border Intensity";
  556. > = 0.75;
  557.  
  558. uniform float barspeed <
  559. ui_type = "drag";
  560. ui_min = 5.0;
  561. ui_max = 200.0;
  562. ui_step = 1.0;
  563. ui_label = "Hum Bar Speed";
  564. > = 50.0;
  565.  
  566. uniform float barintensity <
  567. ui_type = "drag";
  568. ui_min = -1.0;
  569. ui_max = 1.0;
  570. ui_step = 0.01;
  571. ui_label = "Hum Bar Intensity";
  572. > = 0.0;
  573.  
  574. uniform float bardir <
  575. ui_type = "drag";
  576. ui_min = 0.0;
  577. ui_max = 1.0;
  578. ui_step = 1.0;
  579. ui_label = "Hum Bar Direction";
  580. > = 0.0;
  581.  
  582. uniform float warpx <
  583. ui_type = "drag";
  584. ui_min = 0.0;
  585. ui_max = 0.25;
  586. ui_step = 0.01;
  587. ui_label = "Curvature X (Default 0.03)";
  588. > = 0.0;
  589.  
  590. uniform float warpy <
  591. ui_type = "drag";
  592. ui_min = 0.0;
  593. ui_max = 0.25;
  594. ui_step = 0.01;
  595. ui_label = "Curvature Y (Default 0.04)";
  596. > = 0.0;
  597.  
  598. uniform float c_shape <
  599. ui_type = "drag";
  600. ui_min = 0.05;
  601. ui_max = 0.6;
  602. ui_step = 0.05;
  603. ui_label = "Curvature Shape";
  604. > = 0.25;
  605.  
  606. uniform float overscanx <
  607. ui_type = "drag";
  608. ui_min = -200.0;
  609. ui_max = 200.0;
  610. ui_step = 1.0;
  611. ui_label = "Overscan X Original Pixels";
  612. > = 0.0;
  613.  
  614. uniform float overscany <
  615. ui_type = "drag";
  616. ui_min = -200.0;
  617. ui_max = 200.0;
  618. ui_step = 1.0;
  619. ui_label = "Overscan Y Original Pixels";
  620. > = 0.0;
  621.  
  622. uniform float shadow_msk <
  623. ui_type = "drag";
  624. ui_min = 0.0;
  625. ui_max = 14.0;
  626. ui_step = 1.0;
  627. ui_label = "CRT Mask: 1:CGWG | 2-5:Lottes | 6-14:Trinitron";
  628. > = 1.0;
  629.  
  630. uniform float maskstr <
  631. ui_type = "drag";
  632. ui_min = -0.5;
  633. ui_max = 1.0;
  634. ui_step = 0.025;
  635. ui_label = "Mask Strength (1, 6-14)";
  636. > = 0.3;
  637.  
  638. uniform float mcut <
  639. ui_type = "drag";
  640. ui_min = 0.0;
  641. ui_max = 2.0;
  642. ui_step = 0.05;
  643. ui_label = "Mask 6-14 Low Strength";
  644. > = 1.1;
  645.  
  646. uniform float maskboost <
  647. ui_type = "drag";
  648. ui_min = 1.0;
  649. ui_max = 3.0;
  650. ui_step = 0.05;
  651. ui_label = "CRT Mask Boost";
  652. > = 1.0;
  653.  
  654. uniform float masksize <
  655. ui_type = "drag";
  656. ui_min = 1.0;
  657. ui_max = 4.0;
  658. ui_step = 1.0;
  659. ui_label = "CRT Mask Size";
  660. > = 1.0;
  661.  
  662. uniform float mask_zoom <
  663. ui_type = "drag";
  664. ui_min = -5.0;
  665. ui_max = 5.0;
  666. ui_step = 1.0;
  667. ui_label = "CRT Mask Zoom (+ Mask Width)";
  668. > = 0.0;
  669.  
  670. uniform float zoom_mask <
  671. ui_type = "drag";
  672. ui_min = 0.0;
  673. ui_max = 1.0;
  674. ui_step = 0.05;
  675. ui_label = "CRT Mask Zoom Sharpen";
  676. > = 0.0;
  677.  
  678. uniform float mshift <
  679. ui_type = "drag";
  680. ui_min = 0.0;
  681. ui_max = 1.0;
  682. ui_step = 0.5;
  683. ui_label = "(Transform to) Shadow Mask";
  684. > = 0.0;
  685.  
  686. uniform float mask_layout <
  687. ui_type = "drag";
  688. ui_min = 0.0;
  689. ui_max = 1.0;
  690. ui_step = 1.0;
  691. ui_label = "Mask Layout: RGB or BGR (Check LCD Panel)";
  692. > = 0.0;
  693.  
  694. uniform float mask_drk <
  695. ui_type = "drag";
  696. ui_min = 0.0;
  697. ui_max = 2.0;
  698. ui_step = 0.05;
  699. ui_label = "Lottes Mask Dark";
  700. > = 0.5;
  701.  
  702. uniform float mask_lgt <
  703. ui_type = "drag";
  704. ui_min = 0.0;
  705. ui_max = 2.0;
  706. ui_step = 0.05;
  707. ui_label = "Lottes Mask Bright";
  708. > = 1.5;
  709.  
  710. uniform float mask_gamma <
  711. ui_type = "drag";
  712. ui_min = 1.0;
  713. ui_max = 5.0;
  714. ui_step = 0.05;
  715. ui_label = "Mask Gamma";
  716. > = 2.4;
  717.  
  718. uniform float slotmask1 <
  719. ui_type = "drag";
  720. ui_min = 0.0;
  721. ui_max = 1.0;
  722. ui_step = 0.05;
  723. ui_label = "Slot Mask Strength Bright Pixels";
  724. > = 0.0;
  725.  
  726. uniform float slotmask2 <
  727. ui_type = "drag";
  728. ui_min = 0.0;
  729. ui_max = 1.0;
  730. ui_step = 0.05;
  731. ui_label = "Slot Mask Strength Dark Pixels";
  732. > = 0.0;
  733.  
  734. uniform float slotwidth <
  735. ui_type = "drag";
  736. ui_min = 0.0;
  737. ui_max = 16.0;
  738. ui_step = 1.0;
  739. ui_label = "Slot Mask Width (0:Auto)";
  740. > = 0.0;
  741.  
  742. uniform float double_slot <
  743. ui_type = "drag";
  744. ui_min = 1.0;
  745. ui_max = 4.0;
  746. ui_step = 1.0;
  747. ui_label = "Slot Mask Height: 2x1 or 4x1";
  748. > = 2.0;
  749.  
  750. uniform float slotms <
  751. ui_type = "drag";
  752. ui_min = 1.0;
  753. ui_max = 4.0;
  754. ui_step = 1.0;
  755. ui_label = "Slot Mask Thickness";
  756. > = 1.0;
  757.  
  758. uniform float smoothmask <
  759. ui_type = "drag";
  760. ui_min = 0.0;
  761. ui_max = 1.0;
  762. ui_step = 1.0;
  763. ui_label = "Smooth Masks In Bright Scanlines";
  764. > = 0.0;
  765.  
  766. uniform float smask_mit <
  767. ui_type = "drag";
  768. ui_min = 0.0;
  769. ui_max = 1.0;
  770. ui_step = 0.05;
  771. ui_label = "Mitigate Slot Mask Interaction";
  772. > = 0.0;
  773.  
  774. uniform float bmask <
  775. ui_type = "drag";
  776. ui_min = 0.0;
  777. ui_max = 0.25;
  778. ui_step = 0.01;
  779. ui_label = "Base (Black) Mask Strength";
  780. > = 0.0;
  781.  
  782. uniform float dctypex <
  783. ui_type = "drag";
  784. ui_min = 0.0;
  785. ui_max = 0.75;
  786. ui_step = 0.05;
  787. ui_label = "Deconvergence Type X: 0:Static | Other:Dynamic";
  788. > = 0.0;
  789.  
  790. uniform float dctypey <
  791. ui_type = "drag";
  792. ui_min = 0.0;
  793. ui_max = 0.75;
  794. ui_step = 0.05;
  795. ui_label = "Deconvergence Type Y: 0:Static | Other:Dynamic";
  796. > = 0.0;
  797.  
  798. uniform float deconrx <
  799. ui_type = "drag";
  800. ui_min = -15.0;
  801. ui_max = 15.0;
  802. ui_step = 0.25;
  803. ui_label = "Horizontal Deconvergence 'R' Range";
  804. > = 0.0;
  805.  
  806. uniform float decongx <
  807. ui_type = "drag";
  808. ui_min = -15.0;
  809. ui_max = 15.0;
  810. ui_step = 0.25;
  811. ui_label = "Horizontal Deconvergence 'G' Range";
  812. > = 0.0;
  813.  
  814. uniform float deconbx <
  815. ui_type = "drag";
  816. ui_min = -15.0;
  817. ui_max = 15.0;
  818. ui_step = 0.25;
  819. ui_label = "Horizontal Deconvergence 'B' Range";
  820. > = 0.0;
  821.  
  822. uniform float deconry <
  823. ui_type = "drag";
  824. ui_min = -15.0;
  825. ui_max = 15.0;
  826. ui_step = 0.25;
  827. ui_label = "Vertical Deconvergence 'R' Range";
  828. > = 0.0;
  829.  
  830. uniform float decongy <
  831. ui_type = "drag";
  832. ui_min = -15.0;
  833. ui_max = 15.0;
  834. ui_step = 0.25;
  835. ui_label = "Vertical Deconvergence 'G' Range";
  836. > = 0.0;
  837.  
  838. uniform float deconby <
  839. ui_type = "drag";
  840. ui_min = -15.0;
  841. ui_max = 15.0;
  842. ui_step = 0.25;
  843. ui_label = "Vertical Deconvergence 'B' Range";
  844. > = 0.0;
  845.  
  846. uniform float decons <
  847. ui_type = "drag";
  848. ui_min = 0.0;
  849. ui_max = 3.0;
  850. ui_step = 0.1;
  851. ui_label = "Deconvergence Strength";
  852. > = 1.0;
  853.  
  854. uniform float addnoised <
  855. ui_type = "drag";
  856. ui_min = -1.0;
  857. ui_max = 1.0;
  858. ui_step = 0.02;
  859. ui_label = "Add Noise";
  860. > = 0.0;
  861.  
  862. uniform float noiseresd <
  863. ui_type = "drag";
  864. ui_min = 1.0;
  865. ui_max = 10.0;
  866. ui_step = 1.0;
  867. ui_label = "Noise Resolution";
  868. > = 2.0;
  869.  
  870. uniform float noisetype <
  871. ui_type = "drag";
  872. ui_min = 0.0;
  873. ui_max = 1.0;
  874. ui_step = 1.0;
  875. ui_label = "Noise Type: Colored | Luma";
  876. > = 0.0;
  877.  
  878. uniform float post_br <
  879. ui_type = "drag";
  880. ui_min = 0.25;
  881. ui_max = 5.0;
  882. ui_step = 0.01;
  883. ui_label = "Post Brightness";
  884. > = 1.0;
  885.  
  886. #include "ReShade.fxh"
  887.  
  888. #define TexSize float2(Resolution_X,Resolution_Y)
  889. #define IptSize float2(800.00000000,600.00000000)
  890. #define OptSize float4(BUFFER_SCREEN_SIZE,1.0/BUFFER_SCREEN_SIZE)
  891. #define OrgSize float4(TexSize,1.0/TexSize)
  892. #define SrcSize float4(IptSize,1.0/IptSize)
  893. #define fuxcoord (texcoord*1.00001)
  894. #define scans 1.5*scans
  895. #define internal_res internal_res*(1.0/(1.0+hiscan))
  896. #define eps 1e-10
  897. #define fracoord (fuxcoord*OptSize.xy)
  898. #define COMPAT_TEXTURE(c,d) tex2D(c,d)
  899. #define inv_sqr_h 1.0/(2.0*SIGMA_H*SIGMA_H)
  900. #define inv_sqr_v 1.0/(2.0*SIGMA_V*SIGMA_V)
  901. #define inv_sqr_x 1.0/(2.0*SIGMA_X*SIGMA_X)
  902. #define inv_sqr_y 1.0/(2.0*SIGMA_Y*SIGMA_Y)
  903. #define invsigmah 1.0/(2.0*SIGMA_HOR*SIGMA_HOR*internal_res*internal_res)
  904. #define invsigmav 1.0/(2.0*SIGMA_VER*SIGMA_VER*internal_res*internal_res)
  905.  
  906. #ifndef Resolution_X
  907. #define Resolution_X 320
  908. #endif
  909.  
  910. #ifndef Resolution_Y
  911. #define Resolution_Y 240
  912. #endif
  913.  
  914. #define CRTHD_S0 ReShade::BackBuffer
  915.  
  916. texture CRTHD_T1{Width=Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
  917. sampler CRTHD_S1{Texture=CRTHD_T1;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  918.  
  919. texture CRTHD_T2{Width=BUFFER_WIDTH;Height=Resolution_Y ;Format=RGBA16F;};
  920. sampler CRTHD_S2{Texture=CRTHD_T2;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  921.  
  922. texture CRTHD_T3{Width=800.00000000;Height=600.00000000 ;Format=RGBA16F;};
  923. sampler CRTHD_S3{Texture=CRTHD_T3;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  924.  
  925. texture CRTHD_T4{Width=800.00000000;Height=600.00000000 ;Format=RGBA16F;};
  926. sampler CRTHD_S4{Texture=CRTHD_T4;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  927.  
  928. texture CRTHD_T5{Width=800.00000000;Height=600.00000000 ;Format=RGBA16F;};
  929. sampler CRTHD_S5{Texture=CRTHD_T5;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  930.  
  931. texture CRTHD_T6{Width=800.00000000;Height=600.00000000 ;Format=RGBA16F;};
  932. sampler CRTHD_S6{Texture=CRTHD_T6;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  933.  
  934. texture CRTHD_T7{Width=BUFFER_WIDTH;Height=BUFFER_HEIGHT;Format=RGBA16F;};
  935. sampler CRTHD_S7{Texture=CRTHD_T7;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  936.  
  937. uniform int framecount<source="framecount";>;
  938.  
  939. float3 plant(float3 tar,float r)
  940. {
  941. float t=max(max(tar.r,tar.g),tar.b)+0.00001;
  942. return tar*r/t;
  943. }
  944.  
  945. float vignette(float2 pos)
  946. {
  947. float2 b=vigdef*float2(1.0,OrgSize.x/OrgSize.y)*0.125;
  948. pos=clamp(pos,0.0,1.0);
  949. pos=abs(2.0*(pos-0.5));
  950. float2 res=lerp(0.0.xx,1.0.xx,smoothstep(1.0.xx,1.0.xx-b,sqrt(pos)));
  951. res=pow(res,0.70.xx);
  952. return max(lerp(1.0,sqrt(res.x*res.y),vigstr),0.0);
  953. }
  954.  
  955. float gauss_h(float x)
  956. {
  957. return exp(-x*x*inv_sqr_h);
  958. }
  959.  
  960. float gauss_v(float x)
  961. {
  962. return exp(-x*x*inv_sqr_v);
  963. }
  964.  
  965. float bloom_h(float x)
  966. {
  967. return exp(-x*x*inv_sqr_x);
  968. }
  969.  
  970. float bloom_v(float x)
  971. {
  972. return exp(-x*x*inv_sqr_y);
  973. }
  974.  
  975. float crthd_h(float x)
  976. {
  977. return exp(-x*x*invsigmah);
  978. }
  979.  
  980. float crthd_v(float x)
  981. {
  982. return exp(-x*x*invsigmav);
  983. }
  984.  
  985. float mod(float x,float y)
  986. {
  987. return x-y* floor(x/y);
  988. }
  989.  
  990. float st0(float x)
  991. {
  992. return exp2(-10.0*x*x);
  993. }
  994.  
  995. float st1(float x)
  996. {
  997. return exp2(- 8.0*x*x);
  998. }
  999.  
  1000. float3 sw0(float x,float color,float scanline,float3 c)
  1001. {
  1002. float3 xe=lerp(1.0.xxx+scans,1.0.xxx,c);
  1003. float tmp=lerp(beam_min,beam_max,color);
  1004. float ex=x*tmp;
  1005. ex=(gsl>-0.5)?ex*ex:lerp(ex*ex,ex*ex*ex,0.4);
  1006. return exp2(-scanline*ex*xe);
  1007. }
  1008.  
  1009. float3 sw1(float x,float color,float scanline,float3 c)
  1010. {
  1011. float3 xe=lerp(1.0.xxx+scans,1.0.xxx,c);
  1012. x=lerp(x,beam_min*x,max(x-0.4*color,0.0));
  1013. float tmp=lerp(1.2*beam_min,beam_max,color);
  1014. float ex=x*tmp;
  1015. return exp2(-scanline*ex*ex*xe);
  1016. }
  1017.  
  1018. float3 sw2(float x,float color,float scanline,float3 c)
  1019. {
  1020. float3 xe=lerp(1.0.xxx+scans,1.0.xxx,c);
  1021. float tmp=lerp((2.5-0.5*color)*beam_min,beam_max,color);
  1022. tmp=lerp(beam_max,tmp,pow(x,color+0.3));
  1023. float ex=x*tmp;
  1024. return exp2(-scanline*ex*ex*xe);
  1025. }
  1026.  
  1027. float2 overscan(float2 pos,float dx,float dy)
  1028. {
  1029. pos=pos*2.0-1.0;
  1030. pos*=float2(dx,dy);
  1031. return pos*0.5+0.5;
  1032. }
  1033.  
  1034. float2 warp(float2 pos)
  1035. {
  1036. pos=pos*2.0-1.0;
  1037. 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);
  1038. return pos*0.5+0.5;
  1039. }
  1040.  
  1041. float3 gc(float3 c)
  1042. {
  1043. float mc=max(max(c.r,c.g),c.b);
  1044. float mg=pow(mc,1.0/gamma_c);
  1045. return c*mg/(mc+eps);
  1046. }
  1047.  
  1048. float3 v_resample(float2 tex0,float4 size)
  1049. {
  1050. float f=frac(size.y*tex0.y);
  1051. f=0.5-f;
  1052. float2 tex=tex0;
  1053. tex.y=floor(size.y*tex.y)*size.w+0.5*size.w;
  1054. float3 color=0.0.xxx;
  1055. float2 dy=float2(0.0,size.w);
  1056. float w=0.0;
  1057. float wsum=0.0;
  1058. float3 pixel;
  1059. float vsharpness=max(VSHARPNESS *internal_res,0.6);
  1060. float3 cmax=0.0.xxx;
  1061. float3 cmin=1.0.xxx;
  1062. float sharp= crthd_v(vsharpness)*S_SHARPV;
  1063. float maxsharp=MAXS;
  1064. float FPR=vsharpness;
  1065. float fpx=0.0;
  1066. float LOOPSIZE=ceil(2.0*FPR);
  1067. float CLAMPSIZE=round(2.0*LOOPSIZE/3.0);
  1068. float n=-LOOPSIZE;
  1069. do
  1070. {
  1071. pixel=tex2Dlod(CRTHD_S2, float4(tex+n*dy,0,0)).rgb;
  1072. w=crthd_v(n+f)-sharp;
  1073. fpx=abs(n+f-sign(n)*FPR)/FPR;
  1074. if(abs(n)<=CLAMPSIZE){cmax=max(cmax,pixel);cmin=min(cmin,pixel);}
  1075. if(w<0.0)w=clamp(w,lerp(-maxsharp,0.0,pow(clamp(fpx,0.0,1.0),VSHARP)),0.0);
  1076. color=color+w*pixel;
  1077. wsum=wsum+w;
  1078. n=n+1.0;
  1079. }while(n<=LOOPSIZE);
  1080. color=color/wsum;
  1081. color=clamp(lerp(clamp(color,cmin,cmax),color,VARNG),0.0,1.0);
  1082. return color;
  1083. }
  1084.  
  1085. float3 crt_mask(float2 pos,float mx,float mb)
  1086. {
  1087. float3 mask=mask_drk;
  1088. float3 one=1.0;
  1089. if(shadow_msk== 1.0)
  1090. {
  1091. float mc=1.0-max(maskstr,0.0);
  1092. pos.x=frac(pos.x*0.5);
  1093. if(pos.x<0.49)
  1094. {
  1095. mask.r=1.0;mask.g= mc;mask.b=1.0;
  1096. }else
  1097. {
  1098. mask.r= mc;mask.g=1.0;mask.b= mc;
  1099. }
  1100. }else
  1101. if(shadow_msk== 2.0)
  1102. {
  1103. float line=mask_lgt;
  1104. float odd=0.0;
  1105. if(frac(pos.x/6.0)<0.49)odd=1.0;
  1106. if(frac((pos.y+odd)/2.0)<0.49)line=mask_drk;
  1107. pos.x=floor(mod(pos.x,3.0));
  1108. if(pos.x<0.5)mask.r=mask_lgt;else
  1109. if(pos.x<1.5)mask.g=mask_lgt;else
  1110. mask.b= mask_lgt;
  1111. mask*=line;
  1112. }else
  1113. if(shadow_msk== 3.0)
  1114. {
  1115. pos.x=floor(mod(pos.x,3.0));
  1116. if(pos.x<0.5)mask.r=mask_lgt;else
  1117. if(pos.x<1.5)mask.g=mask_lgt;else
  1118. mask.b= mask_lgt;
  1119. }else
  1120. if(shadow_msk== 4.0)
  1121. {
  1122. pos.x+=pos.y*3.0;
  1123. pos.x=frac(pos.x/6.0);
  1124. if(pos.x<0.3)mask.r=mask_lgt;else
  1125. if(pos.x<0.6)mask.g=mask_lgt;else
  1126. mask.b= mask_lgt;
  1127. }else
  1128. if(shadow_msk== 5.0)
  1129. {
  1130. pos.xy=floor(pos.xy*float2(1.0,0.5));
  1131. pos.x+=pos.y*3.0;
  1132. pos.x=frac(pos.x/6.0);
  1133. if(pos.x<0.3)mask.r=mask_lgt;else
  1134. if(pos.x<0.6)mask.g=mask_lgt;else
  1135. mask.b= mask_lgt;
  1136. }else
  1137. if(shadow_msk== 6.0)
  1138. {
  1139. mask=0.0;
  1140. pos.x=frac(pos.x/2.0);
  1141. if(pos.x<0.49)
  1142. {
  1143. mask.r=1.0;
  1144. mask.b=1.0;
  1145. }else
  1146. mask.g=1.0;
  1147. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1148. }else
  1149. if(shadow_msk== 7.0)
  1150. {
  1151. mask=0.0;
  1152. pos.x=floor(mod(pos.x,3.0));
  1153. if(pos.x<0.5)mask.r=1.0;else
  1154. if(pos.x<1.5)mask.g=1.0;else
  1155. mask.b=1.0;
  1156. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1157. }else
  1158. if(shadow_msk== 8.0)
  1159. {
  1160. mask=0.0;
  1161. pos.x=frac(pos.x/2.0);
  1162. if(pos.x<0.49)
  1163. {
  1164. mask=0.0.xxx;
  1165. }else
  1166. mask=1.0.xxx;
  1167. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1168. }else
  1169. if(shadow_msk== 9.0)
  1170. {
  1171. mask=0.0;
  1172. pos.x=frac(pos.x/3.0);
  1173. if(pos.x<0.3)mask=0.0.xxx;else
  1174. if(pos.x<0.6)mask=1.0.xxx;else
  1175. mask=1.0.xxx;
  1176. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1177. }else
  1178. if(shadow_msk==10.0)
  1179. {
  1180. mask=0.0;
  1181. pos.x=frac(pos.x/3.0);
  1182. if(pos.x<0.3)mask =0.0.xxx;else
  1183. if(pos.x<0.6)mask.rb=1.0.xx ;else
  1184. mask.g=1.0;
  1185. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1186. }else
  1187. if(shadow_msk==11.0)
  1188. {
  1189. mask=0.0;
  1190. pos.x=frac(pos.x*0.25);
  1191. if(pos.x<0.2)mask =0.0.xxx;else
  1192. if(pos.x<0.4)mask.r=1.0 ;else
  1193. if(pos.x<0.7)mask.g=1.0 ;else
  1194. mask.b=1.0;
  1195. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1196. }else
  1197. if(shadow_msk==12.0)
  1198. {
  1199. mask=0.0;
  1200. pos.x=frac(pos.x*0.25);
  1201. if(pos.x<0.2)mask.r =1.0 ;else
  1202. if(pos.x<0.4)mask.rg=1.0.xx;else
  1203. if(pos.x<0.7)mask.gb=1.0.xx;else
  1204. mask.b=1.0;mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1205. }else
  1206. if(shadow_msk==13.0)
  1207. {
  1208. mask=0.0;
  1209. pos.x=floor(mod(pos.x,7.0));
  1210. if(pos.x<0.5)mask =0.0.xxx;else
  1211. if(pos.x<2.5)mask.r=1.0 ;else
  1212. if(pos.x<4.5)mask.g=1.0 ;else
  1213. mask.b=1.0;
  1214. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1215. }else
  1216. {
  1217. mask=0.0;
  1218. pos.x=floor(mod(pos.x,6.0));
  1219. if(pos.x<0.5)mask =0.0.xxx;else
  1220. if(pos.x<1.5)mask.r =1.0 ;else
  1221. if(pos.x<2.5)mask.rg =1.0.xx ;else
  1222. if(pos.x<3.5)mask.rgb=1.0.xxx;else
  1223. if(pos.x<4.5)mask.gb =1.0.xx ;else
  1224. mask.b=1.0;
  1225. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1226. }
  1227. if(mask_layout>0.5)mask=mask.rbg;
  1228. float maskmin=min(min(mask.r,mask.g),mask.b);
  1229. return (mask-maskmin)*(1.0+(maskboost-1.0)*mb)+maskmin;
  1230. }
  1231.  
  1232. float slt_mask(float2 pos,float m,float swidth)
  1233. {
  1234. if ((slotmask1+slotmask2)==0.0)return 1.0;else
  1235. {
  1236. pos.y=floor(pos.y/slotms);
  1237. float mlen=swidth*2.0;
  1238. float px=floor( mod(pos.x, 0.99999*mlen));
  1239. float py=floor(frac(pos.y/(2.0*double_slot))*2.0*double_slot);
  1240. float slot_dark=lerp(1.0-slotmask2,1.0-slotmask1,m);
  1241. float slot=1.0;
  1242. if(py==0.0&&px<swidth) slot=slot_dark;else
  1243. if(py==double_slot&&px>=swidth) slot=slot_dark;
  1244. return slot;
  1245. }
  1246. }
  1247.  
  1248. float humbars(float pos)
  1249. {
  1250. if (barintensity==0.0)return 1.0;else
  1251. {
  1252. pos=(barintensity>=0.0)?pos:(1.0-pos);
  1253. pos=frac(pos+ mod(float(framecount),barspeed)/(barspeed-1.0));
  1254. pos=(barintensity< 0.0)?pos:(1.0-pos);
  1255. return (1.0-barintensity)+barintensity*pos;
  1256. }
  1257. }
  1258.  
  1259. float corner(float2 pos)
  1260. {
  1261. float2 b=bsize * float2(1.0,OptSize.x/OptSize.y)*0.05;
  1262. pos=clamp(pos,0.0,1.0);
  1263. pos=abs(2.0*(pos-0.5));
  1264. float csize1=lerp(400.0,7.0,pow(4.0*csize,0.10));
  1265. float crn=dot(pow(pos,csize1.xx),float2(1.0,OptSize.y/OptSize.x));
  1266. crn=(csize==0.0)?max(pos.x,pos.y):pow(crn,1.0/csize1);
  1267. pos=max(pos,crn);
  1268. float2 res=(bsize ==0.0)?1.0.xx:lerp(0.0.xx,1.0.xx,smoothstep(1.0.xx,1.0.xx-b,sqrt(pos)));
  1269. res=pow(res, sborder.xx);
  1270. return sqrt(res.x*res.y);
  1271. }
  1272.  
  1273. float3 declip(float3 c,float b)
  1274. {
  1275. float m=max(max(c.r,c.g),c.b);
  1276. if(m>b)c=c*b/m;
  1277. return c;
  1278. }
  1279.  
  1280. float igc(float mc)
  1281. {
  1282. return pow(mc,gamma_c);
  1283. }
  1284.  
  1285. float3 noise(float3 v)
  1286. {
  1287. if(addnoised<0.0)v.z=-addnoised; else v.z= mod(v.z,6001.0)/1753.0;
  1288. v =frac(v)+frac(v*1e4)+frac(v*1e-4);
  1289. v+=float3(0.12345,0.6789,0.314159);
  1290. v =frac(v*dot(v,v)*123.456);
  1291. v =frac(v*dot(v,v)*123.456);
  1292. v =frac(v*dot(v,v)*123.456);
  1293. v =frac(v*dot(v,v)*123.456);
  1294. return v;
  1295. }
  1296.  
  1297. void bring_pixel(inout float3 c,inout float3 b,inout float3 g,float2 coord,float2 boord)
  1298. {
  1299. float stepx=OptSize.z;
  1300. float stepy=OptSize.w;
  1301. float2 dx=float2(stepx,0.0);
  1302. float2 dy=float2(0.0,stepy);
  1303. float posx= 2.0*coord.x-1.0;
  1304. float posy= 2.0*coord.y-1.0;
  1305. if(dctypex>0.025)
  1306. {
  1307. posx= sign(posx)*pow(abs(posx),1.05-dctypex);
  1308. dx=posx*dx;
  1309. }
  1310. if(dctypey>0.025)
  1311. {
  1312. posy= sign(posy)*pow(abs(posy),1.05-dctypey);
  1313. dy=posy*dy;
  1314. }
  1315. float2 rc=deconrx*dx+deconry*dy;
  1316. float2 gc=decongx*dx+decongy*dy;
  1317. float2 bc=deconbx*dx+deconby*dy;
  1318. float r1=COMPAT_TEXTURE(CRTHD_S7,coord+rc).r;
  1319. float g1=COMPAT_TEXTURE(CRTHD_S7,coord+gc).g;
  1320. float b1=COMPAT_TEXTURE(CRTHD_S7,coord+bc).b;
  1321. float ds=decons;
  1322. float3 d=float3(r1,g1,b1);
  1323. c=clamp(lerp(c,d,ds),0.0,1.0);
  1324. r1=COMPAT_TEXTURE(CRTHD_S6,boord+rc).r;
  1325. g1=COMPAT_TEXTURE(CRTHD_S6,boord+gc).g;
  1326. b1=COMPAT_TEXTURE(CRTHD_S6,boord+bc).b;
  1327. d=float3(r1,g1,b1);
  1328. b=g=lerp(b,d,min(ds,1.0));
  1329. r1=COMPAT_TEXTURE(CRTHD_S4,boord+rc).r;
  1330. g1=COMPAT_TEXTURE(CRTHD_S4,boord+gc).g;
  1331. b1=COMPAT_TEXTURE(CRTHD_S4,boord+bc).b;
  1332. d=float3(r1,g1,b1);
  1333. g=lerp(g,d,min(ds,1.0));
  1334. }
  1335.  
  1336. float4 LinearizePS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1337. {
  1338. float3 c1=tex2Dlod(CRTHD_S0,float4(fuxcoord,0,0)).rgb;
  1339. float3 c2=tex2Dlod(CRTHD_S0,float4(fuxcoord+float2(0.0,OrgSize.w),0,0)).rgb;
  1340. float3 c=c1;
  1341. float intera=1.0;
  1342. float gamma_in=clamp(gamma_i,1.0,5.0);
  1343. float m1=max(max(c1.r,c1.g),c1.b);
  1344. float m2=max(max(c2.r,c2.g),c2.b);
  1345. float3 df=abs(c1-c2);
  1346. float d=max(max(df.r,df.g),df.b);
  1347. if(interm==2.0)d=lerp(0.1*d,10.0*d,step(m1/(m2+0.0001),m2/(m1+0.0001)));
  1348. float r=m1;
  1349. float yres_div=1.0; if(intres>1.25)yres_div=intres;
  1350. bool hscan=(hiscan>0.5);
  1351. if(inter <=OrgSize.y/yres_div&&interm>0.5&&intres!=1.0&&intres!=0.5&&vga_mode<0.5||hscan)
  1352. {
  1353. intera=0.25;
  1354. float liine_no=clamp(floor( mod(OrgSize.y*fuxcoord.y,2.0)),0.0,1.0);
  1355. float frame_no=clamp(floor( mod(float(framecount),2.0)),0.0,1.0);
  1356. float ii=abs(liine_no-frame_no);
  1357. if(interm< 3.5)
  1358. {
  1359. c2=plant(lerp(c2,c2*c2,iscans),max(max(c2.r,c2.g),c2.b));
  1360. r=clamp(max(m1*ii,(1.0-iscan)*min(m1,m2)),0.0,1.0);
  1361. 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);
  1362. if(interm==3.0)c=(1.0-0.5*iscan)*lerp(c2,c1,ii);
  1363. }
  1364. 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*iscan);}
  1365. if(hscan)c=c1;
  1366. }
  1367. if(vga_mode>0.5)
  1368. {
  1369. c=c1;if(inter<=OrgSize.y)intera=0.75; else intera=0.5;
  1370. }
  1371. c=pow(c,gamma_in);
  1372. if(fuxcoord.x>0.5)gamma_in=intera; else gamma_in=1.0/gamma_in;
  1373. return float4(c,gamma_in);
  1374. }
  1375.  
  1376. float4 HGaussianPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1377. {
  1378. float4 GaussSize=float4(OrgSize.x,OrgSize.y,OrgSize.z,OrgSize.w)*lerp(1.0.xxxx,float4(FINE_GAUSS,FINE_GAUSS,1.0/FINE_GAUSS,1.0/FINE_GAUSS),min(FINE_GAUSS-1.0,1.0));
  1379. float f=frac(GaussSize.x*texcoord.x);
  1380. f=0.5-f;
  1381. float2 tex=floor(GaussSize.xy*texcoord)*GaussSize.zw+0.5*GaussSize.zw;
  1382. float3 color=0.0;
  1383. float2 dx=float2(GaussSize.z,0.0);
  1384. float3 pixel;
  1385. float w;
  1386. float wsum=0.0;
  1387. float n=-SIZEH;
  1388. do
  1389. {
  1390. pixel=tex2Dlod(CRTHD_S1, float4(tex+n*dx,0,0)).rgb;
  1391. if(m_glow>0.5)
  1392. {
  1393. pixel=max(pixel-m_glow_cutoff,0.0);
  1394. pixel=plant(pixel,max(max(max(pixel.r,pixel.g),pixel.b)-m_glow_cutoff,0.0));
  1395. }
  1396. w=gauss_h(n+f);
  1397. color=color+w*pixel;
  1398. wsum=wsum+w;
  1399. n=n+1.0;
  1400. }while(n<=SIZEH);
  1401. color=color/wsum;
  1402. return float4(color,1.0);
  1403. }
  1404.  
  1405. float4 VGaussianPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1406. {
  1407. float4 GaussSize=float4(SrcSize.x,OrgSize.y,SrcSize.z,OrgSize.w)*lerp(1.0.xxxx,float4(FINE_GAUSS,FINE_GAUSS,1.0/FINE_GAUSS,1.0/FINE_GAUSS),min(FINE_GAUSS-1.0,1.0));
  1408. float f=frac(GaussSize.y*texcoord.y);
  1409. f=0.5-f;
  1410. float2 tex=floor(GaussSize.xy*texcoord)*GaussSize.zw+0.5*GaussSize.zw;
  1411. float3 color=0.0;
  1412. float2 dy=float2(0.0,GaussSize.w);
  1413. float3 pixel;
  1414. float w;
  1415. float wsum=0.0;
  1416. float n=-SIZEV;
  1417. do
  1418. {
  1419. pixel=tex2Dlod(CRTHD_S3, float4(tex+n*dy,0,0)).rgb;
  1420. w=gauss_v(n+f);
  1421. color=color+w*pixel;
  1422. wsum=wsum+w;
  1423. n=n+1.0;
  1424. }while(n<=SIZEV);
  1425. color=color/wsum;
  1426. return float4(color,1.0);
  1427. }
  1428.  
  1429. float4 BloomHorzPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1430. {
  1431. float4 BloomSize=float4(OrgSize.x,OrgSize.y,OrgSize.z,OrgSize.w)*lerp(1.0.xxxx,float4(FINE_BLOOM,FINE_BLOOM,1.0/FINE_BLOOM,1.0/FINE_BLOOM),min(FINE_BLOOM-1.0,1.0));
  1432. float f=frac(BloomSize.x*texcoord.x);
  1433. f=0.5-f;
  1434. float2 tex=floor(BloomSize.xy*texcoord)*BloomSize.zw+0.5*BloomSize.zw;
  1435. float4 color=0.0;
  1436. float2 dx=float2(BloomSize.z,0.0);
  1437. float4 pixel;
  1438. float w;
  1439. float wsum=0.0;
  1440. float n=-SIZEX;
  1441. do
  1442. {
  1443. pixel=tex2Dlod(CRTHD_S1, float4(tex+n*dx,0,0));
  1444. w=bloom_h(n+f);
  1445. pixel.a =max(max(pixel.r,pixel.g),pixel.b);
  1446. pixel.a*=pixel.a*pixel.a;
  1447. color=color+w*pixel;
  1448. wsum=wsum+w;
  1449. n=n+1.0;
  1450. }while(n<=SIZEX);
  1451. color=color/wsum;
  1452. return float4(color.rgb,pow(color.a,0.333333));
  1453. }
  1454.  
  1455. float4 BloomVertPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1456. {
  1457. float4 BloomSize=float4(SrcSize.x,OrgSize.y,SrcSize.z,OrgSize.w)*lerp(1.0.xxxx,float4(FINE_BLOOM,FINE_BLOOM,1.0/FINE_BLOOM,1.0/FINE_BLOOM),min(FINE_BLOOM-1.0,1.0));
  1458. float f=frac(BloomSize.y*texcoord.y);
  1459. f=0.5-f;
  1460. float2 tex=floor(BloomSize.xy*texcoord)*BloomSize.zw+0.5*BloomSize.zw;
  1461. float4 color=0.0;
  1462. float2 dy=float2(0.0,BloomSize.w);
  1463. float4 pixel;
  1464. float w;
  1465. float wsum=0.0;
  1466. float n=-SIZEY;
  1467. do
  1468. {
  1469. pixel=tex2Dlod(CRTHD_S5, float4(tex+n*dy,0,0));
  1470. w=bloom_v(n+f);
  1471. pixel.a*=pixel.a*pixel.a;
  1472. color=color+w*pixel;
  1473. wsum=wsum+w;
  1474. n=n+1.0;
  1475. }while(n<=SIZEY);
  1476. color=color/wsum;
  1477. return float4(color.rgb,pow(color.a,0.175000));
  1478. }
  1479.  
  1480. float4 HD_Pass1_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1481. {
  1482. float2 prescalex=float2(tex2Dsize(CRTHD_S1,0))/OrgSize.xy;
  1483. float4 PALSize=OrgSize*float4(prescalex.x,prescalex.y,1.0/prescalex.x,1.0/prescalex.y);
  1484. float f=frac(PALSize.x*fuxcoord.x);
  1485. f=0.5-f;
  1486. float2 tex=floor(PALSize.xy*fuxcoord)*PALSize.zw+0.5*PALSize.zw;
  1487. float3 color=0.0.xxx;
  1488. float scolor=0.0;
  1489. float2 dx=float2(PALSize.z,0.0);
  1490. float w=0.0;
  1491. float swsum=0.0;
  1492. float wsum=0.0;
  1493. float3 pixel;
  1494. float hsharpness=HSHARPNESS*internal_res;
  1495. float3 cmax=0.0.xxx;
  1496. float3 cmin=1.0.xxx;
  1497. float sharp=crthd_h(hsharpness)*S_SHARPH;
  1498. float maxsharp=MAXS;
  1499. float FPR=hsharpness;
  1500. float fpx=0.0;
  1501. float sp=0.0;
  1502. float sw=0.0;
  1503. float ts=0.025;
  1504. float3 luma=float3(0.2126,0.7152,0.0722);
  1505. float LOOPSIZE=ceil(2.0*FPR);
  1506. float CLAMPSIZE=round(2.0*LOOPSIZE/3.0);
  1507. float n=-LOOPSIZE;
  1508. do
  1509. {
  1510. pixel=tex2Dlod(CRTHD_S1, float4(tex+n*dx,0,0)).rgb;
  1511. sp=max(max(pixel.r,pixel.g),pixel.b);
  1512. w=crthd_h(n+f)-sharp;
  1513. fpx=abs(n+f-sign(n)*FPR)/FPR;
  1514. if(abs(n)<=CLAMPSIZE){cmax=max(cmax,pixel);cmin=min(cmin,pixel);}
  1515. if(w<0.0)w=clamp(w,lerp(-maxsharp,0.0,pow(clamp(fpx,0.0,1.0),HSHARP)),0.0);
  1516. color=color+w*pixel;
  1517. wsum=wsum+w;
  1518. sw=max(w,0.0)*(dot(pixel,luma)+ts);
  1519. scolor=scolor+sw*sp;
  1520. swsum=swsum+sw;
  1521. n=n+1.0;
  1522. }while(n<=LOOPSIZE);
  1523. color =color/wsum;
  1524. scolor=scolor/swsum;
  1525. color =clamp(lerp(clamp(color,cmin,cmax),color,HARNG),0.0,1.0);
  1526. scolor=clamp(lerp(max(max(color.r,color.g),color.b),scolor,spike),0.0,1.0);
  1527. return float4(color,scolor);
  1528. }
  1529.  
  1530. float4 HD_Pass2_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1531. {
  1532. float2 prescalex=float2(tex2Dsize(CRTHD_S1,0))/OrgSize.xy;
  1533. float4 PALSize=float4(OrgSize.x,OrgSize.y,OrgSize.z,OrgSize.w);
  1534. float gamma_in=1.0/COMPAT_TEXTURE(CRTHD_S1,0.25).a;
  1535. float intera=COMPAT_TEXTURE(CRTHD_S1,float2(0.75,0.25)).a;
  1536. bool hscan=(hiscan>0.5);
  1537. bool interb=(((intera<0.35)||(no_scanlines>0.025))&&!hscan);
  1538. bool vgascan=((abs(intera-0.5)<0.05)&&(no_scanlines==0.0));
  1539. float SourceY=PALSize.y;
  1540. float sy=1.0;
  1541. if( intres==1.0)sy=SourceY/224.0;
  1542. if( intres>0.25&&intres!=1.0)sy=intres;
  1543. if(vgascan)sy=0.5; else if(abs(intera-0.75)<0.05)sy=1.0;
  1544. PALSize*=float4(1.0,1.0/sy,1.0,sy);
  1545. float2 lexcoord = fuxcoord.xy;
  1546. if(IOS> 0.0&&!interb)
  1547. {
  1548. float2 ofactor=OptSize.xy/OrgSize.xy;
  1549. float2 intfactor=(IOS<2.5)?floor(ofactor):ceil(ofactor);
  1550. float2 diff=ofactor/intfactor;
  1551. float scan=diff.y;
  1552. lexcoord=overscan(lexcoord,scan,scan);
  1553. if(IOS==1.0||IOS==3.0)lexcoord=float2(fuxcoord.x,lexcoord.y);
  1554. }
  1555. lexcoord=overscan(lexcoord,(OrgSize.x-overscanx)/OrgSize.x,(OrgSize.y-overscany)/OrgSize.y);
  1556. float2 pos=warp(lexcoord);
  1557. float coffset=0.5;
  1558. float2 ps=PALSize.zw;
  1559. float OGL2Pos=pos.y*PALSize.y-coffset;
  1560. float f=frac(OGL2Pos);
  1561. float2 dx=float2(ps.x,0.0);
  1562. float2 dy=float2(0.0,ps.y);
  1563. float2 pC4;
  1564. pC4.y=floor(OGL2Pos)*ps.y+0.5*ps.y;
  1565. pC4.x=pos.x;
  1566. if((intres==0.5&&prescalex.y<1.5)||vgascan)pC4.y=floor(pC4.y*OrgSize.y)*OrgSize.w+0.5*OrgSize.w;
  1567. if( interb&&no_scanlines>0.025)pC4.y=pC4.y+smoothstep(0.40-0.5*no_scanlines,0.60+0.5*no_scanlines,f)*PALSize.w;
  1568. float3 color1=tex2Dlod(CRTHD_S2,float4(pC4,0,0)).rgb;
  1569. float3 scolor1=tex2Dlod(CRTHD_S2,float4(pC4,0,0)).aaa;
  1570. float prescaley=float(tex2Dsize(CRTHD_S1,0).y)/OrgSize.y;
  1571. if( interb&&no_scanlines<0.05||hscan&&vgascan||hscan)color1=v_resample(pos,PALSize*float4(1.0,prescaley,1.0,1.0/prescaley));
  1572. color1=pow(color1,scangamma/gamma_in);
  1573. pC4+=dy;
  1574. if((intres==0.5&&prescalex.y<1.5)||vgascan)pC4.y=floor((pos.y+0.33*dy.y)*OrgSize.y)*OrgSize.w+0.5*OrgSize.w;
  1575. float3 color2=tex2Dlod(CRTHD_S2,float4(pC4,0,0)).rgb;
  1576. float3 scolor2=tex2Dlod(CRTHD_S2,float4(pC4,0,0)).aaa;
  1577. color2=pow(color2,scangamma/gamma_in);
  1578. float3 ctmp=color1;float w3=1.0;float3 color=color1;
  1579. float3 one=1.0;
  1580. if(hscan){color2=color1;scolor2=scolor1;}
  1581. if(!interb||hscan)
  1582. {
  1583. float3 luma=float3(0.2126,0.7152,0.0722);
  1584. float ssub=ssharp*max(abs(scolor1.x-scolor2.x),abs(dot(color1,luma)-dot(color2,luma)));
  1585. float shape1=lerp(scanline1,scanline2+ssub*scolor1.x*35.0, f);
  1586. float shape2=lerp(scanline1,scanline2+ssub*scolor2.x*35.0,1.0-f);
  1587. float wt1=st0( f);
  1588. float wt2=st0(1.0- f);
  1589. float3 color0= color1*wt1+ color2*wt2;
  1590. float3 scolor0=scolor1*wt1+scolor2*wt2;
  1591. ctmp=color0/(wt1+wt2);
  1592. float3 sctmp=max(scolor0/(wt1+wt2),ctmp);
  1593. float3 w1,w2;
  1594. float3 cref1=lerp(sctmp,scolor1,beam_size);float creff1=pow(max(max(cref1.r,cref1.g),cref1.b),scan_falloff);
  1595. float3 cref2=lerp(sctmp,scolor2,beam_size);float creff2=pow(max(max(cref2.r,cref2.g),cref2.b),scan_falloff);
  1596. if(tds>0.5){shape1=lerp(scanline2,shape1,creff1);shape2=lerp(scanline2,shape2,creff2);}
  1597. float f1= f;
  1598. float f2=1.0- f;
  1599. float m1=max(max(color1.r,color1.g),color1.b)+eps;
  1600. float m2=max(max(color2.r,color2.g),color2.b)+eps;
  1601. cref1=color1/m1;
  1602. cref2=color2/m2;
  1603. if(gsl< 0.5)
  1604. {w1=sw0(f1,creff1,shape1,cref1);w2=sw0(f2,creff2,shape2,cref2);}else
  1605. if(gsl==1.0)
  1606. {w1=sw1(f1,creff1,shape1,cref1);w2=sw1(f2,creff2,shape2,cref2);}else
  1607. {w1=sw2(f1,creff1,shape1,cref1);w2=sw2(f2,creff2,shape2,cref2);}
  1608. float3 w3=w1+w2;
  1609. float wf1=max(max(w3.r,w3.g),w3.b);
  1610. if(wf1> 1.0) {wf1=1.0/wf1; w1*=wf1, w2*=wf1;}
  1611. if(abs(clp)>0.005)
  1612. {
  1613. sy=m1; one=(clp>0.0)?w1:1.0.xxx;
  1614. float sat=1.0001-min(min(cref1.r,cref1.g),cref1.b);
  1615. color1=lerp(color1,plant(pow(color1,0.70.xxx-0.325*sat),sy),pow(sat,0.3333)*one*abs(clp));
  1616. sy=m2; one=(clp>0.0)?w2:1.0.xxx;
  1617. sat=1.0001-min(min(cref2.r,cref2.g),cref2.b);
  1618. color2=lerp(color2,plant(pow(color2,0.70.xxx-0.325*sat),sy),pow(sat,0.3333)*one*abs(clp));
  1619. }
  1620. color=(gc(color1)*w1+gc(color2)*w2);
  1621. color=min(color,1.0);
  1622. }
  1623. if( interb)
  1624. {
  1625. color=gc(color1);
  1626. }
  1627. float colmx=max(max(ctmp.r,ctmp.g),ctmp.b);
  1628. color=pow(color,gamma_in/scangamma);
  1629. return float4(color,colmx);
  1630. }
  1631.  
  1632. float4 ChromaticPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1633. {
  1634. float gamma_in=1.0/COMPAT_TEXTURE(CRTHD_S1,0.25).a;
  1635. float intera=COMPAT_TEXTURE(CRTHD_S1,float2(0.75,0.25)).a;
  1636. bool interb=((intera<0.35||no_scanlines>0.025)&&(hiscan<0.5));
  1637. float2 lexcoord = fuxcoord.xy;
  1638. if(IOS> 0.0&&!interb)
  1639. {
  1640. float2 ofactor= OptSize.xy/OrgSize.xy;
  1641. float2 intfactor=(IOS<2.5)?floor(ofactor):ceil(ofactor);
  1642. float2 diff=ofactor/intfactor;
  1643. float scan=diff.y;
  1644. lexcoord=overscan(lexcoord,scan,scan);
  1645. if(IOS==1.0||IOS==3.0)lexcoord=float2(fuxcoord.x,lexcoord.y);
  1646. }
  1647. lexcoord=overscan(lexcoord,(OrgSize.x-overscanx)/OrgSize.x,(OrgSize.y-overscany)/OrgSize.y);
  1648. float2 pos0=warp(fuxcoord.xy);
  1649. float2 pos1=fuxcoord.xy;
  1650. float2 pos=warp(lexcoord);
  1651. float3 color=COMPAT_TEXTURE(CRTHD_S7,pos1).rgb;
  1652. float3 Bloom=COMPAT_TEXTURE(CRTHD_S6,pos).rgb;
  1653. float3 Glow=COMPAT_TEXTURE(CRTHD_S4,pos).rgb;
  1654. if((abs(deconrx)+abs(deconry)+abs(decongx)+abs(decongy)+abs(deconbx)+abs(deconby))>0.2)
  1655. bring_pixel(color,Bloom,Glow,pos1,pos);
  1656. float cm=igc(max(max(color.r,color.g),color.b));
  1657. float mx1=COMPAT_TEXTURE(CRTHD_S7,pos1 ).a;
  1658. float colmx=max(mx1,cm);
  1659. float w3=min((cm+0.0001)/(colmx+0.0005),1.0); if(interb)w3=1.0;
  1660. float2 dx=float2(0.001,0.0);
  1661. float mx0=tex2Dlod(CRTHD_S7,float4(pos1-dx,0,0)).a;
  1662. float mx2=tex2Dlod(CRTHD_S7,float4(pos1+dx,0,0)).a;
  1663. float mxg=max(max(mx0,mx1),max(mx2,cm));
  1664. float mx=pow(mxg,1.40/gamma_in);
  1665. dx=float2(OrgSize.z,0.0)*0.25;
  1666. mx0=tex2Dlod(CRTHD_S7,float4(pos1-dx,0,0)).a;
  1667. mx2=tex2Dlod(CRTHD_S7,float4(pos1+dx,0,0)).a;
  1668. float mb=(1.0-min(abs(mx0-mx2)/(0.5+mx1),1.0));
  1669. float3 orig1=color;
  1670. float3 one=1.0;
  1671. float3 cmask=one;
  1672. float3 dmask=one;
  1673. float3 emask=one;
  1674. float mwidths[15]={0.0,2.0,3.0,3.0,3.0,6.0,2.4,3.5,2.4,3.25,3.5,4.5,4.25,7.5,6.25};
  1675. float mwidth=mwidths[int(shadow_msk)];
  1676. float mask_compensate=frac(mwidth);
  1677. if(shadow_msk> 0.5)
  1678. {
  1679. float2 maskcoord=fracoord.xy* 1.00001;
  1680. float2 scoord=maskcoord;
  1681. mwidth=floor(mwidth)*masksize;
  1682. float swidth=mwidth;
  1683. bool zoomed=(abs(mask_zoom)>0.75);
  1684. float mscale=1.0;
  1685. float2 maskcoord0=maskcoord;
  1686. maskcoord.y=floor(maskcoord.y/masksize);
  1687. float mwidth1=max(mwidth+mask_zoom,2.0);
  1688. if( mshift> 0.25)
  1689. {
  1690. float stagg_lvl=1.0; if(frac(mshift)>0.25)stagg_lvl=2.0;
  1691. float next_line=float(floor(mod(maskcoord.y,2.0*stagg_lvl))<stagg_lvl);
  1692. maskcoord0.x=maskcoord0.x+next_line*0.5*mwidth1;
  1693. }
  1694. maskcoord=maskcoord0/masksize;
  1695. if(!zoomed)cmask*=crt_mask(floor(maskcoord),mx,mb);else
  1696. {
  1697. mscale=mwidth1/mwidth;
  1698. float mlerp= frac(maskcoord.x/mscale); if(zoom_mask>0.025)mlerp=(1.0+zoom_mask)*mlerp-0.5*zoom_mask;
  1699. float mcoord=floor(maskcoord.x/mscale); if(shadow_msk==13.0&&mask_zoom==-2.0)mcoord=ceil(maskcoord.x/mscale);
  1700. cmask*=max(lerp(crt_mask(float2(mcoord,maskcoord.y),mx,mb),crt_mask(float2(mcoord+1.0,maskcoord.y),mx,mb),mlerp),0.0);
  1701. }
  1702. if(slotwidth>0.5)swidth=slotwidth;float smask=1.0;
  1703. 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);
  1704. if( zoomed)
  1705. {
  1706. if(mask_layout<0.5&&bsm_offset)sm_offset=1.0;else
  1707. if(bsm_offset)sm_offset=-1.0;
  1708. }
  1709. swidth=round(swidth*mscale);
  1710. smask=slt_mask(scoord+float2(sm_offset,0.0),mx,swidth);
  1711. smask=clamp(smask+lerp(smask_mit,0.0,min(w3,pow(w3*max(max(orig1.r,orig1.g),orig1.b),0.33333))),0.0,1.0);
  1712. emask =cmask;
  1713. cmask*=smask;
  1714. dmask =cmask;
  1715. if(abs(mask_bloom)>0.025)
  1716. {
  1717. float maxbl=max(max(max(Bloom.r,Bloom.g),Bloom.b),mxg);
  1718. maxbl=maxbl*max(lerp(1.0,2.0-colmx,bloom_dist),0.0);
  1719. if(mask_bloom>0.025)cmask=max(min(cmask+maxbl*mask_bloom,1.0),cmask);else
  1720. cmask=max(lerp(cmask,cmask*(1.0-0.5*maxbl)+plant(pow(Bloom,0.35.xxx),maxbl),-mask_bloom),cmask);
  1721. }
  1722. color=pow(color,mask_gamma/gamma_in);
  1723. color=color*cmask;
  1724. color=min(color,1.0);
  1725. color=pow(color,gamma_in/mask_gamma);
  1726. cmask=min(cmask,1.0);
  1727. dmask=min(dmask,1.0);
  1728. }
  1729. 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;
  1730. float bb=lerp(brightboost1,brightboost2,mx)* dark_compensate; color*=bb;
  1731. float3 Ref=COMPAT_TEXTURE(CRTHD_S1,pos).rgb;
  1732. float maxb=COMPAT_TEXTURE(CRTHD_S6,pos).a;
  1733. float3 bcmask=lerp(one,cmask,bmask1);
  1734. float3 hcmask=lerp(one,cmask,hmask1);
  1735. float3 Bloom1=Bloom;
  1736. if(abs(bloom)>0.025)
  1737. {
  1738. if(bloom<-0.01)Bloom1=plant(Bloom,maxb);
  1739. Bloom1= min(Bloom1*(orig1+color), max(0.5*(colmx+orig1-color),0.001*Bloom1));
  1740. Bloom1=0.5*(Bloom1+lerp(Bloom1,lerp(colmx*orig1,Bloom1,0.5),1.0-color));
  1741. Bloom1=bcmask*Bloom1*max(lerp(1.0,2.0-colmx,bloom_dist),0.0);
  1742. color=pow(pow(color,mask_gamma/gamma_in)+abs(bloom)*pow(Bloom1,mask_gamma/gamma_in),gamma_in/mask_gamma);
  1743. }
  1744. if(!interb) color=declip(min(color,1.0), lerp(1.0,w3,0.6));
  1745. if(halation> 0.01)
  1746. {
  1747. Bloom=lerp(0.5*(Bloom+Bloom*Bloom),0.75*Bloom*Bloom,colmx);
  1748. color=color+2.0*max((2.0*lerp(maxb*maxb,maxb,colmx)-0.5*max(max(Ref.r,Ref.g),Ref.b)),0.25)*lerp(1.0,w3,0.5*colmx)*hcmask*Bloom*halation;
  1749. }else
  1750. if(halation<-0.01)
  1751. {
  1752. float mbl=max(max(Bloom.r,Bloom.g),Bloom.b);
  1753. Bloom=plant(Bloom+Ref+orig1+Bloom*Bloom*Bloom,min(mbl*mbl,0.75));
  1754. color=color+2.0*lerp(1.0,w3,0.5*colmx)*hcmask*Bloom*(-halation);
  1755. }
  1756. float w=0.25+0.60*lerp(w3,1.0,sqrt(colmx));
  1757. if(smoothmask>0.5)
  1758. {
  1759. color=min(color,1.0); color=max(min(color/w3,1.0)*w3, min(orig1*bb,color*(1.0-w3)));
  1760. }
  1761. if(m_glow<0.5)Glow=lerp(Glow,0.25*color,colmx);else
  1762. {
  1763. float3 orig2=plant(orig1+0.001*Ref,1.0);
  1764. maxb=max(max(Glow.r,Glow.g),Glow.b);
  1765. Bloom=plant(Glow,1.0);Ref=abs(orig2-Bloom);
  1766. mx0=max(max(orig2.g,orig2.g),orig2.b)-min(min(orig2.g,orig2.g),orig2.b);
  1767. mx2=max(max(Bloom.g,Bloom.g),Bloom.b)-min(min(Bloom.g,Bloom.g),Bloom.b);
  1768. Bloom=lerp(maxb*min(Bloom,orig2),w*lerp(lerp(Glow,max(max(Ref.g,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));
  1769. Glow=lerp(m_glow_low*Glow,m_glow_high*Bloom,pow(colmx,m_glow_dist/gamma_in));
  1770. }
  1771. if(m_glow<0.5)
  1772. {
  1773. if(glow >=0.0)color=color+0.5*Glow*glow;else color=color+abs(glow)*min(emask*emask,1.0)*Glow;}else
  1774. {
  1775. dmask= clamp(lerp(one,dmask,m_glow_mask),0.0,1.0); color=color+abs(glow)*dmask*Glow;
  1776. }
  1777. float vig=vignette(pos);
  1778. color=min(color,1.0);
  1779. color=pow(color,1.0/gamma_o);
  1780. float rc=0.6*sqrt(max(max(color.r,color.g),color.b))+0.4;
  1781. if(abs(addnoised)>0.01)
  1782. {
  1783. float3 noise0=noise(float3(floor(OptSize.xy*lexcoord/noiseresd),float(framecount)));
  1784. if(noisetype<0.5)color=lerp(color,noise0,0.25*abs(addnoised)*rc);else
  1785. color=min(color*lerp(1.0,1.5*noise0.x,0.5*abs(addnoised)),1.0);
  1786. }
  1787. colmx=max(max(orig1.r,orig1.g),orig1.b);
  1788. color=color+bmask*lerp(emask,0.125*(1.0-colmx)*color,min(20.0*colmx,1.0));
  1789. return float4(color*vig*humbars(lerp(pos.y,pos.x,bardir))*post_br*corner(pos0),1.0);
  1790. }
  1791.  
  1792. technique CRT_Guest_HD
  1793. {
  1794. pass Linearize
  1795. {
  1796. VertexShader=PostProcessVS;
  1797. PixelShader=LinearizePS;
  1798. RenderTarget=CRTHD_T1;
  1799. }
  1800. pass CRT_Pass1
  1801. {
  1802. VertexShader=PostProcessVS;
  1803. PixelShader=HD_Pass1_PS;
  1804. RenderTarget=CRTHD_T2;
  1805. }
  1806. pass GaussianX
  1807. {
  1808. VertexShader=PostProcessVS;
  1809. PixelShader=HGaussianPS;
  1810. RenderTarget=CRTHD_T3;
  1811. }
  1812. pass GaussianY
  1813. {
  1814. VertexShader=PostProcessVS;
  1815. PixelShader=VGaussianPS;
  1816. RenderTarget=CRTHD_T4;
  1817. }
  1818. pass BloomHorz
  1819. {
  1820. VertexShader=PostProcessVS;
  1821. PixelShader=BloomHorzPS;
  1822. RenderTarget=CRTHD_T5;
  1823. }
  1824. pass BloomVert
  1825. {
  1826. VertexShader=PostProcessVS;
  1827. PixelShader=BloomVertPS;
  1828. RenderTarget=CRTHD_T6;
  1829. }
  1830. pass CRT_Pass2
  1831. {
  1832. VertexShader=PostProcessVS;
  1833. PixelShader=HD_Pass2_PS;
  1834. RenderTarget=CRTHD_T7;
  1835. }
  1836. pass Chromatic
  1837. {
  1838. VertexShader=PostProcessVS;
  1839. PixelShader=ChromaticPS;
  1840. }
  1841. }
Add Comment
Please, Sign In to add comment