Advertisement
Guest User

CRT-Guest-Advanced (TEST)

a guest
Jan 29th, 2024
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 50.25 KB | None | 0 0
  1. /*
  2.  
  3. CRT - Guest - Advanced (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 vigstr <
  23. ui_type = "drag";
  24. ui_min = 0.0;
  25. ui_max = 2.0;
  26. ui_step = 0.05;
  27. ui_label = "Vignette Strength";
  28. > = 0.0;
  29.  
  30. uniform float vigdef <
  31. ui_type = "drag";
  32. ui_min = 0.5;
  33. ui_max = 3.0;
  34. ui_step = 0.1;
  35. ui_label = "Vignette Size";
  36. > = 1.0;
  37.  
  38. uniform float lsmooth <
  39. ui_type = "drag";
  40. ui_min = 0.5;
  41. ui_max = 1.0;
  42. ui_step = 0.01;
  43. ui_label = "Raster Bloom Effect Smoothing";
  44. > = 0.7;
  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. > = 2.4;
  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. > = 2.4;
  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 = 5.0;
  74. ui_step = 1.0;
  75. ui_label = "Interlace Mode: 0:OFF | 1-3:Normal | 4-5:Interpolation";
  76. > = 1.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 downsample_levelx <
  119. ui_type = "drag";
  120. ui_min = 0.0;
  121. ui_max = 3.0;
  122. ui_step = 0.05;
  123. ui_label = "Downsampling-X (High-Res Content, Pre-Scalers)";
  124. > = 0.0;
  125.  
  126. uniform float downsample_levely <
  127. ui_type = "drag";
  128. ui_min = 0.0;
  129. ui_max = 3.0;
  130. ui_step = 0.05;
  131. ui_label = "Downsampling-Y (High-Res Content, Pre-Scalers)";
  132. > = 0.0;
  133.  
  134. uniform float m_glow <
  135. ui_type = "drag";
  136. ui_min = 0.0;
  137. ui_max = 1.0;
  138. ui_step = 1.0;
  139. ui_label = "Ordinary Glow | Magic Glow";
  140. > = 0.0;
  141.  
  142. uniform float m_glow_cutoff <
  143. ui_type = "drag";
  144. ui_min = 0.0;
  145. ui_max = 0.4;
  146. ui_step = 0.01;
  147. ui_label = "Magic Glow Cutoff";
  148. > = 0.12;
  149.  
  150. uniform float m_glow_low <
  151. ui_type = "drag";
  152. ui_min = 0.0;
  153. ui_max = 7.0;
  154. ui_step = 0.05;
  155. ui_label = "Magic Glow Low Strength";
  156. > = 0.35;
  157.  
  158. uniform float m_glow_high <
  159. ui_type = "drag";
  160. ui_min = 0.0;
  161. ui_max = 7.0;
  162. ui_step = 0.1;
  163. ui_label = "Magic Glow High Strength";
  164. > = 5.0;
  165.  
  166. uniform float m_glow_dist <
  167. ui_type = "drag";
  168. ui_min = 0.2;
  169. ui_max = 4.0;
  170. ui_step = 0.05;
  171. ui_label = "Magic Glow Distribution";
  172. > = 1.0;
  173.  
  174. uniform float m_glow_mask <
  175. ui_type = "drag";
  176. ui_min = 0.0;
  177. ui_max = 2.0;
  178. ui_step = 0.025;
  179. ui_label = "Magic Glow Mask Strength";
  180. > = 1.0;
  181.  
  182. uniform float FINE_GAUSS <
  183. ui_type = "drag";
  184. ui_min = 1.0;
  185. ui_max = 5.0;
  186. ui_step = 1.0;
  187. ui_label = "Fine (Magic) Glow Sampling";
  188. > = 1.0;
  189.  
  190. uniform float SIZEH <
  191. ui_type = "drag";
  192. ui_min = 1.0;
  193. ui_max = 50.0;
  194. ui_step = 1.0;
  195. ui_label = "Horizontal Glow Radius";
  196. > = 6.0;
  197.  
  198. uniform float SIGMA_H <
  199. ui_type = "drag";
  200. ui_min = 0.2;
  201. ui_max = 15.0;
  202. ui_step = 0.05;
  203. ui_label = "Horizontal Glow Sigma";
  204. > = 1.2;
  205.  
  206. uniform float SIZEV <
  207. ui_type = "drag";
  208. ui_min = 1.0;
  209. ui_max = 50.0;
  210. ui_step = 1.0;
  211. ui_label = "Vertical Glow Radius";
  212. > = 6.0;
  213.  
  214. uniform float SIGMA_V <
  215. ui_type = "drag";
  216. ui_min = 0.2;
  217. ui_max = 15.0;
  218. ui_step = 0.05;
  219. ui_label = "Vertical Glow Sigma";
  220. > = 1.2;
  221.  
  222. uniform float FINE_BLOOM <
  223. ui_type = "drag";
  224. ui_min = 1.0;
  225. ui_max = 5.0;
  226. ui_step = 1.0;
  227. ui_label = "Fine Bloom/Halation Sampling";
  228. > = 1.0;
  229.  
  230. uniform float SIZEX <
  231. ui_type = "drag";
  232. ui_min = 1.0;
  233. ui_max = 50.0;
  234. ui_step = 1.0;
  235. ui_label = "Horizontal Bloom/Halation Radius";
  236. > = 3.0;
  237.  
  238. uniform float SIGMA_X <
  239. ui_type = "drag";
  240. ui_min = 0.25;
  241. ui_max = 15.0;
  242. ui_step = 0.025;
  243. ui_label = "Horizontal Bloom/Halation Sigma";
  244. > = 0.75;
  245.  
  246. uniform float SIZEY <
  247. ui_type = "drag";
  248. ui_min = 1.0;
  249. ui_max = 50.0;
  250. ui_step = 1.0;
  251. ui_label = "Vertical Bloom/Halation Radius";
  252. > = 3.0;
  253.  
  254. uniform float SIGMA_Y <
  255. ui_type = "drag";
  256. ui_min = 0.25;
  257. ui_max = 15.0;
  258. ui_step = 0.025;
  259. ui_label = "Vertical Bloom/Halation Sigma";
  260. > = 0.60;
  261.  
  262. uniform float glow <
  263. ui_type = "drag";
  264. ui_min = -2.0;
  265. ui_max = 2.0;
  266. ui_step = 0.01;
  267. ui_label = "(Magic) Glow Strength";
  268. > = 0.08;
  269.  
  270. uniform float blm_1 <
  271. ui_type = "drag";
  272. ui_min = -2.0;
  273. ui_max = 2.0;
  274. ui_step = 0.05;
  275. ui_label = "Bloom Strength";
  276. > = 0.0;
  277.  
  278. uniform float bmask1 <
  279. ui_type = "drag";
  280. ui_min = -1.0;
  281. ui_max = 1.0;
  282. ui_step = 0.025;
  283. ui_label = "Bloom Mask Strength";
  284. > = 0.0;
  285.  
  286. uniform float mask_bloom <
  287. ui_type = "drag";
  288. ui_min = -2.0;
  289. ui_max = 2.0;
  290. ui_step = 0.05;
  291. ui_label = "Mask Bloom";
  292. > = 0.0;
  293.  
  294. uniform float bloom_dist <
  295. ui_type = "drag";
  296. ui_min = -2.0;
  297. ui_max = 3.0;
  298. ui_step = 0.05;
  299. ui_label = "Bloom Distribution";
  300. > = 0.0;
  301.  
  302. uniform float halation <
  303. ui_type = "drag";
  304. ui_min = -2.0;
  305. ui_max = 2.0;
  306. ui_step = 0.025;
  307. ui_label = "Halation Strength";
  308. > = 0.0;
  309.  
  310. uniform float hmask1 <
  311. ui_type = "drag";
  312. ui_min = -1.0;
  313. ui_max = 1.0;
  314. ui_step = 0.025;
  315. ui_label = "Halation Mask Strength";
  316. > = 0.5;
  317.  
  318. uniform float gamma_c <
  319. ui_type = "drag";
  320. ui_min = 0.5;
  321. ui_max = 2.0;
  322. ui_step = 0.025;
  323. ui_label = "Gamma Correct";
  324. > = 1.0;
  325.  
  326. uniform float brightboost1 <
  327. ui_type = "drag";
  328. ui_min = 0.25;
  329. ui_max = 10.0;
  330. ui_step = 0.05;
  331. ui_label = "Bright Boost Dark Pixels";
  332. > = 1.4;
  333.  
  334. uniform float brightboost2 <
  335. ui_type = "drag";
  336. ui_min = 0.25;
  337. ui_max = 3.0;
  338. ui_step = 0.025;
  339. ui_label = "Bright Boost Bright Pixels";
  340. > = 1.1;
  341.  
  342. uniform float clp <
  343. ui_type = "drag";
  344. ui_min = -1.0;
  345. ui_max = 1.0;
  346. ui_step = 0.05;
  347. ui_label = "Clip Saturated Color Beams";
  348. > = 0.0;
  349.  
  350. uniform float gsl <
  351. ui_type = "drag";
  352. ui_min = -1.0;
  353. ui_max = 2.0;
  354. ui_step = 1.0;
  355. ui_label = "Scanlines Type";
  356. > = 0.0;
  357.  
  358. uniform float scanline1 <
  359. ui_type = "drag";
  360. ui_min = -20.0;
  361. ui_max = 40.0;
  362. ui_step = 0.5;
  363. ui_label = "Scanlines Beam Shape Center";
  364. > = 6.0;
  365.  
  366. uniform float scanline2 <
  367. ui_type = "drag";
  368. ui_min = 0.0;
  369. ui_max = 70.0;
  370. ui_step = 1.0;
  371. ui_label = "Scanlines Beam Shape Edges";
  372. > = 8.0;
  373.  
  374. uniform float beam_min <
  375. ui_type = "drag";
  376. ui_min = 0.25;
  377. ui_max = 10.0;
  378. ui_step = 0.05;
  379. ui_label = "Scanlines Shape Dark Pixels";
  380. > = 1.3;
  381.  
  382. uniform float beam_max <
  383. ui_type = "drag";
  384. ui_min = 0.2;
  385. ui_max = 3.5;
  386. ui_step = 0.025;
  387. ui_label = "Scanlines Shape Bright Pixels";
  388. > = 1.0;
  389.  
  390. uniform float tds <
  391. ui_type = "drag";
  392. ui_min = 0.0;
  393. ui_max = 1.0;
  394. ui_step = 1.0;
  395. ui_label = "Thinner Dark Scanlines";
  396. > = 0.0;
  397.  
  398. uniform float beam_size <
  399. ui_type = "drag";
  400. ui_min = 0.0;
  401. ui_max = 1.0;
  402. ui_step = 0.05;
  403. ui_label = "Increased Bright Scanlines Beam";
  404. > = 0.6;
  405.  
  406. uniform float scans <
  407. ui_type = "drag";
  408. ui_min = 0.0;
  409. ui_max = 6.0;
  410. ui_step = 0.1;
  411. ui_label = "Scanlines Saturation / Mask Falloff";
  412. > = 0.5;
  413.  
  414. uniform float scan_falloff <
  415. ui_type = "drag";
  416. ui_min = 0.1;
  417. ui_max = 2.0;
  418. ui_step = 0.025;
  419. ui_label = "Scanlines Falloff";
  420. > = 1.0;
  421.  
  422. uniform float spike <
  423. ui_type = "drag";
  424. ui_min = 0.0;
  425. ui_max = 2.0;
  426. ui_step = 0.1;
  427. ui_label = "Scanlines Spike Removal";
  428. > = 1.0;
  429.  
  430. uniform float ssharp <
  431. ui_type = "drag";
  432. ui_min = 0.0;
  433. ui_max = 0.3;
  434. ui_step = 0.01;
  435. ui_label = "Smart Sharpen Scanlines";
  436. > = 0.0;
  437.  
  438. uniform float scangamma <
  439. ui_type = "drag";
  440. ui_min = 0.5;
  441. ui_max = 5.0;
  442. ui_step = 0.05;
  443. ui_label = "Scanlines Gamma";
  444. > = 2.4;
  445.  
  446. uniform float no_scanlines <
  447. ui_type = "drag";
  448. ui_min = 0.0;
  449. ui_max = 1.5;
  450. ui_step = 0.05;
  451. ui_label = "No-Scanlines Mode";
  452. > = 0.0;
  453.  
  454. uniform float h_sharp <
  455. ui_type = "drag";
  456. ui_min = 0.2;
  457. ui_max = 15.0;
  458. ui_step = 0.1;
  459. ui_label = "Horizontal Sharpness";
  460. > = 5.2;
  461.  
  462. uniform float s_sharp <
  463. ui_type = "drag";
  464. ui_min = 0.0;
  465. ui_max = 2.0;
  466. ui_step = 0.1;
  467. ui_label = "Substractive Sharpness (1.0 Recommended)";
  468. > = 0.5;
  469.  
  470. uniform float ring <
  471. ui_type = "drag";
  472. ui_min = 0.0;
  473. ui_max = 3.0;
  474. ui_step = 0.05;
  475. ui_label = "Substractive Sharpness Ringing";
  476. > = 0.0;
  477.  
  478. uniform float smart_ei <
  479. ui_type = "drag";
  480. ui_min = 0.0;
  481. ui_max = 0.75;
  482. ui_step = 0.01;
  483. ui_label = "Smart Edges Effect Strength";
  484. > = 0.0;
  485.  
  486. uniform float ei_limit <
  487. ui_type = "drag";
  488. ui_min = 0.0;
  489. ui_max = 0.75;
  490. ui_step = 0.01;
  491. ui_label = "Smart Edges Effect Strength Limit";
  492. > = 0.25;
  493.  
  494. uniform float sth <
  495. ui_type = "drag";
  496. ui_min = 0.0;
  497. ui_max = 1.0;
  498. ui_step = 0.01;
  499. ui_label = "Smart Edges Smoothing Threshold";
  500. > = 0.23;
  501.  
  502. uniform float TATE <
  503. ui_type = "drag";
  504. ui_min = 0.0;
  505. ui_max = 1.0;
  506. ui_step = 1.0;
  507. ui_label = "TATE Mode";
  508. > = 0.0;
  509.  
  510. uniform float IOS <
  511. ui_type = "drag";
  512. ui_min = 0.0;
  513. ui_max = 4.0;
  514. ui_step = 1.0;
  515. ui_label = "Integer Scaling: Odd:Y | Even:X+Y";
  516. > = 0.0;
  517.  
  518. uniform float OS <
  519. ui_type = "drag";
  520. ui_min = 0.0;
  521. ui_max = 2.0;
  522. ui_step = 1.0;
  523. ui_label = "Raster Bloom Overscan Mode";
  524. > = 1.0;
  525.  
  526. uniform float blm_2 <
  527. ui_type = "drag";
  528. ui_min = 0.0;
  529. ui_max = 20.0;
  530. ui_step = 1.0;
  531. ui_label = "Raster Bloom %";
  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 eps 1e-10
  896. #define fracoord (fuxcoord*OptSize.xy)
  897. #define COMPAT_TEXTURE(c,d) tex2D(c,d)
  898. #define inv_sqr_h 1.0/(2.0*SIGMA_H*SIGMA_H)
  899. #define inv_sqr_v 1.0/(2.0*SIGMA_V*SIGMA_V)
  900. #define inv_sqr_x 1.0/(2.0*SIGMA_X*SIGMA_X)
  901. #define inv_sqr_y 1.0/(2.0*SIGMA_Y*SIGMA_Y)
  902.  
  903. #ifndef Resolution_X
  904. #define Resolution_X 320
  905. #endif
  906.  
  907. #ifndef Resolution_Y
  908. #define Resolution_Y 240
  909. #endif
  910.  
  911. #define GUEST_S0 ReShade::BackBuffer
  912.  
  913. texture GUEST_T1{Width=Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
  914. sampler GUEST_S1{Texture=GUEST_T1;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  915.  
  916. texture GUEST_T2{Width=Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
  917. sampler GUEST_S2{Texture=GUEST_T2;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  918.  
  919. texture GUEST_T3{Width=800.00000000;Height=600.00000000 ;Format=RGBA16F;};
  920. sampler GUEST_S3{Texture=GUEST_T3;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  921.  
  922. texture GUEST_T4{Width=800.00000000;Height=600.00000000 ;Format=RGBA16F;};
  923. sampler GUEST_S4{Texture=GUEST_T4;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  924.  
  925. texture GUEST_T5{Width=800.00000000;Height=600.00000000 ;Format=RGBA16F;};
  926. sampler GUEST_S5{Texture=GUEST_T5;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  927.  
  928. texture GUEST_T6{Width=800.00000000;Height=600.00000000 ;Format=RGBA16F;};
  929. sampler GUEST_S6{Texture=GUEST_T6;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  930.  
  931. texture GUEST_T7{Width=BUFFER_WIDTH;Height=BUFFER_HEIGHT;Format=RGBA16F;};
  932. sampler GUEST_S7{Texture=GUEST_T7;AddressU=BORDER;AddressV=BORDER;AddressW=BORDER;MagFilter=LINEAR;MinFilter=LINEAR;MipFilter=LINEAR;};
  933.  
  934. uniform int framecount<source="framecount";>;
  935.  
  936. float3 plant(float3 tar,float r)
  937. {
  938. float t=max(max(tar.r,tar.g),tar.b)+0.00001;
  939. return tar*r/t;
  940. }
  941.  
  942. float dist(float3 A,float3 B)
  943. {
  944. float r=0.5*(A.r+B.r);
  945. float3 d=A-B;
  946. float3 c=float3(2.+r,4.,3.-r);
  947. return sqrt(dot(c*d,d))/3.;
  948. }
  949.  
  950. float vignette(float2 pos)
  951. {
  952. float2 b=vigdef*float2(1.0,OrgSize.x/OrgSize.y)*0.125;
  953. pos=clamp(pos,0.0,1.0);
  954. pos=abs(2.0*(pos-0.5));
  955. float2 res=lerp(0.0.xx,1.0.xx,smoothstep(1.0.xx,1.0.xx-b,sqrt(pos)));
  956. res=pow(res,0.70.xx);
  957. return max(lerp(1.0,sqrt(res.x*res.y),vigstr),0.0);
  958. }
  959.  
  960. float3 fetch_pixel(float2 coord)
  961. {
  962. float2 dx=float2(OrgSize.z,0.0)*downsample_levelx;
  963. float2 dy=float2(0.0,OrgSize.w)*downsample_levely;
  964. float2 d1=dx+dy;
  965. float2 d2=dx-dy;
  966. float sum=15.0;
  967. float3 result=3.0*COMPAT_TEXTURE(GUEST_S0,coord).rgb+2.0*COMPAT_TEXTURE(GUEST_S0,coord+dx).rgb+2.0*COMPAT_TEXTURE(GUEST_S0,coord-dx).rgb+
  968. 2.0*COMPAT_TEXTURE(GUEST_S0,coord+dy).rgb+2.0*COMPAT_TEXTURE(GUEST_S0,coord-dy).rgb+COMPAT_TEXTURE(GUEST_S0,coord+d1).rgb+
  969. COMPAT_TEXTURE(GUEST_S0,coord-d1).rgb+COMPAT_TEXTURE(GUEST_S0,coord+d2).rgb+COMPAT_TEXTURE(GUEST_S0,coord-d2).rgb;
  970. return result/sum;
  971. }
  972.  
  973. float gauss_h(float x)
  974. {
  975. return exp(-x*x*inv_sqr_h);
  976. }
  977.  
  978. float gauss_v(float x)
  979. {
  980. return exp(-x*x*inv_sqr_v);
  981. }
  982.  
  983. float bloom_h(float x)
  984. {
  985. return exp(-x*x*inv_sqr_x);
  986. }
  987.  
  988. float bloom_v(float x)
  989. {
  990. return exp(-x*x*inv_sqr_y);
  991. }
  992.  
  993. float mod(float x,float y)
  994. {
  995. return x-y* floor(x/y);
  996. }
  997.  
  998. float st0(float x)
  999. {
  1000. return exp2(-10.0*x*x);
  1001. }
  1002.  
  1003. float st1(float x)
  1004. {
  1005. return exp2(- 8.0*x*x);
  1006. }
  1007.  
  1008. float3 sw0(float x,float color,float scanline,float3 c)
  1009. {
  1010. float3 xe=lerp(1.0.xxx+scans,1.0.xxx,c);
  1011. float tmp=lerp(beam_min,beam_max,color);
  1012. float ex=x*tmp;
  1013. ex=(gsl>-0.5)?ex*ex:lerp(ex*ex,ex*ex*ex,0.4);
  1014. return exp2(-scanline*ex*xe);
  1015. }
  1016.  
  1017. float3 sw1(float x,float color,float scanline,float3 c)
  1018. {
  1019. float3 xe=lerp(1.0.xxx+scans,1.0.xxx,c);
  1020. x=lerp(x,beam_min*x,max(x-0.4*color,0.0));
  1021. float tmp=lerp(1.2*beam_min,beam_max,color);
  1022. float ex=x*tmp;
  1023. return exp2(-scanline*ex*ex*xe);
  1024. }
  1025.  
  1026. float3 sw2(float x,float color,float scanline,float3 c)
  1027. {
  1028. float3 xe=lerp(1.0.xxx+scans,1.0.xxx,c);
  1029. float tmp=lerp((2.5-0.5*color)*beam_min,beam_max,color);
  1030. tmp=lerp(beam_max,tmp,pow(x,color+0.3));
  1031. float ex=x*tmp;
  1032. return exp2(-scanline*ex*ex*xe);
  1033. }
  1034.  
  1035. float2 overscan(float2 pos,float dx,float dy)
  1036. {
  1037. pos=pos*2.0-1.0;
  1038. pos*=float2(dx,dy);
  1039. return pos*0.5+0.5;
  1040. }
  1041.  
  1042. float2 warp(float2 pos)
  1043. {
  1044. pos=pos*2.0-1.0;
  1045. 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);
  1046. return pos*0.5+0.5;
  1047. }
  1048.  
  1049. float3 gc(float3 c)
  1050. {
  1051. float mc=max(max(c.r,c.g),c.b);
  1052. float mg=pow(mc,1.0/gamma_c);
  1053. return c*mg/(mc+eps);
  1054. }
  1055.  
  1056. float3 crt_mask(float2 pos,float mx,float mb)
  1057. {
  1058. float3 mask=mask_drk;
  1059. float3 one=1.0;
  1060. if(shadow_msk== 1.0)
  1061. {
  1062. float mc=1.0-max(maskstr,0.0);
  1063. pos.x=frac(pos.x*0.5);
  1064. if(pos.x<0.49)
  1065. {
  1066. mask.r=1.0;mask.g= mc;mask.b=1.0;
  1067. }else
  1068. {
  1069. mask.r= mc;mask.g=1.0;mask.b= mc;
  1070. }
  1071. }else
  1072. if(shadow_msk== 2.0)
  1073. {
  1074. float line=mask_lgt;
  1075. float odd=0.0;
  1076. if(frac(pos.x/6.0)<0.49)odd=1.0;
  1077. if(frac((pos.y+odd)/2.0)<0.49)line=mask_drk;
  1078. pos.x=floor(mod(pos.x,3.0));
  1079. if(pos.x<0.5)mask.r=mask_lgt;else
  1080. if(pos.x<1.5)mask.g=mask_lgt;else
  1081. mask.b= mask_lgt;
  1082. mask*=line;
  1083. }else
  1084. if(shadow_msk== 3.0)
  1085. {
  1086. pos.x=floor(mod(pos.x,3.0));
  1087. if(pos.x<0.5)mask.r=mask_lgt;else
  1088. if(pos.x<1.5)mask.g=mask_lgt;else
  1089. mask.b= mask_lgt;
  1090. }else
  1091. if(shadow_msk== 4.0)
  1092. {
  1093. pos.x+=pos.y*3.0;
  1094. pos.x=frac(pos.x/6.0);
  1095. if(pos.x<0.3)mask.r=mask_lgt;else
  1096. if(pos.x<0.6)mask.g=mask_lgt;else
  1097. mask.b= mask_lgt;
  1098. }else
  1099. if(shadow_msk== 5.0)
  1100. {
  1101. pos.xy=floor(pos.xy*float2(1.0,0.5));
  1102. pos.x+=pos.y*3.0;
  1103. pos.x=frac(pos.x/6.0);
  1104. if(pos.x<0.3)mask.r=mask_lgt;else
  1105. if(pos.x<0.6)mask.g=mask_lgt;else
  1106. mask.b= mask_lgt;
  1107. }else
  1108. if(shadow_msk== 6.0)
  1109. {
  1110. mask=0.0;
  1111. pos.x=frac(pos.x/2.0);
  1112. if(pos.x<0.49)
  1113. {
  1114. mask.r=1.0;
  1115. mask.b=1.0;
  1116. }else
  1117. mask.g=1.0;
  1118. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1119. }else
  1120. if(shadow_msk== 7.0)
  1121. {
  1122. mask=0.0;
  1123. pos.x=floor(mod(pos.x,3.0));
  1124. if(pos.x<0.5)mask.r=1.0;else
  1125. if(pos.x<1.5)mask.g=1.0;else
  1126. mask.b=1.0;
  1127. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1128. }else
  1129. if(shadow_msk== 8.0)
  1130. {
  1131. mask=0.0;
  1132. pos.x=frac(pos.x/2.0);
  1133. if(pos.x<0.49)
  1134. {
  1135. mask=0.0.xxx;
  1136. }else
  1137. mask=1.0.xxx;
  1138. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1139. }else
  1140. if(shadow_msk== 9.0)
  1141. {
  1142. mask=0.0;
  1143. pos.x=frac(pos.x/3.0);
  1144. if(pos.x<0.3)mask=0.0.xxx;else
  1145. if(pos.x<0.6)mask=1.0.xxx;else
  1146. mask=1.0.xxx;
  1147. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1148. }else
  1149. if(shadow_msk==10.0)
  1150. {
  1151. mask=0.0;
  1152. pos.x=frac(pos.x/3.0);
  1153. if(pos.x<0.3)mask =0.0.xxx;else
  1154. if(pos.x<0.6)mask.rb=1.0.xx ;else
  1155. mask.g=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==11.0)
  1159. {
  1160. mask=0.0;
  1161. pos.x=frac(pos.x*0.25);
  1162. if(pos.x<0.2)mask =0.0.xxx;else
  1163. if(pos.x<0.4)mask.r=1.0 ;else
  1164. if(pos.x<0.7)mask.g=1.0 ;else
  1165. mask.b=1.0;
  1166. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1167. }else
  1168. if(shadow_msk==12.0)
  1169. {
  1170. mask=0.0;
  1171. pos.x=frac(pos.x*0.25);
  1172. if(pos.x<0.2)mask.r =1.0 ;else
  1173. if(pos.x<0.4)mask.rg=1.0.xx;else
  1174. if(pos.x<0.7)mask.gb=1.0.xx;else
  1175. mask.b=1.0;mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1176. }else
  1177. if(shadow_msk==13.0)
  1178. {
  1179. mask=0.0;
  1180. pos.x=floor(mod(pos.x,7.0));
  1181. if(pos.x<0.5)mask =0.0.xxx;else
  1182. if(pos.x<2.5)mask.r=1.0 ;else
  1183. if(pos.x<4.5)mask.g=1.0 ;else
  1184. mask.b=1.0;
  1185. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1186. }else
  1187. {
  1188. mask=0.0;
  1189. pos.x=floor(mod(pos.x,6.0));
  1190. if(pos.x<0.5)mask =0.0.xxx;else
  1191. if(pos.x<1.5)mask.r =1.0 ;else
  1192. if(pos.x<2.5)mask.rg =1.0.xx ;else
  1193. if(pos.x<3.5)mask.rgb=1.0.xxx;else
  1194. if(pos.x<4.5)mask.gb =1.0.xx ;else
  1195. mask.b=1.0;
  1196. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1197. }
  1198. if(mask_layout>0.5)mask=mask.rbg;
  1199. float maskmin=min(min(mask.r,mask.g),mask.b);
  1200. return (mask-maskmin)*(1.0+(maskboost-1.0)*mb)+maskmin;
  1201. }
  1202.  
  1203. float slt_mask(float2 pos,float m,float swidth)
  1204. {
  1205. if ((slotmask1+slotmask2)==0.0)return 1.0;else
  1206. {
  1207. pos.y=floor(pos.y/slotms);
  1208. float mlen=swidth*2.0;
  1209. float px=floor( mod(pos.x, 0.99999*mlen));
  1210. float py=floor(frac(pos.y/(2.0*double_slot))*2.0*double_slot);
  1211. float slot_dark=lerp(1.0-slotmask2,1.0-slotmask1,m);
  1212. float slot=1.0;
  1213. if(py==0.0&&px<swidth) slot=slot_dark;else
  1214. if(py==double_slot&&px>=swidth) slot=slot_dark;
  1215. return slot;
  1216. }
  1217. }
  1218.  
  1219. float humbars(float pos)
  1220. {
  1221. if (barintensity==0.0)return 1.0;else
  1222. {
  1223. pos=(barintensity>=0.0)?pos:(1.0-pos);
  1224. pos=frac(pos+ mod(float(framecount),barspeed)/(barspeed-1.0));
  1225. pos=(barintensity< 0.0)?pos:(1.0-pos);
  1226. return (1.0-barintensity)+barintensity*pos;
  1227. }
  1228. }
  1229.  
  1230. float corner(float2 pos)
  1231. {
  1232. float2 b=bsize * float2(1.0,OptSize.x/OptSize.y)*0.05;
  1233. pos=clamp(pos,0.0,1.0);
  1234. pos=abs(2.0*(pos-0.5));
  1235. float csize1=lerp(400.0,7.0,pow(4.0*csize,0.10));
  1236. float crn=dot(pow(pos,csize1.xx),float2(1.0,OptSize.y/OptSize.x));
  1237. crn=(csize==0.0)?max(pos.x,pos.y):pow(crn,1.0/csize1);
  1238. pos=max(pos,crn);
  1239. 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)));
  1240. res=pow(res, sborder.xx);
  1241. return sqrt(res.x*res.y);
  1242. }
  1243.  
  1244. float3 declip(float3 c,float b)
  1245. {
  1246. float m=max(max(c.r,c.g),c.b);
  1247. if(m>b)c=c*b/m;
  1248. return c;
  1249. }
  1250.  
  1251. float igc(float mc)
  1252. {
  1253. return pow(mc,gamma_c);
  1254. }
  1255.  
  1256. float3 noise(float3 v)
  1257. {
  1258. if(addnoised<0.0)v.z=-addnoised; else v.z= mod(v.z,6001.0)/1753.0;
  1259. v =frac(v)+frac(v*1e4)+frac(v*1e-4);
  1260. v+=float3(0.12345,0.6789,0.314159);
  1261. v =frac(v*dot(v,v)*123.456);
  1262. v =frac(v*dot(v,v)*123.456);
  1263. v =frac(v*dot(v,v)*123.456);
  1264. v =frac(v*dot(v,v)*123.456);
  1265. return v;
  1266. }
  1267.  
  1268. void bring_pixel(inout float3 c,inout float3 b,inout float3 g,float2 coord,float2 boord)
  1269. {
  1270. float stepx=OptSize.z;
  1271. float stepy=OptSize.w;
  1272. float2 dx=float2(stepx,0.0);
  1273. float2 dy=float2(0.0,stepy);
  1274. float posx= 2.0*coord.x-1.0;
  1275. float posy= 2.0*coord.y-1.0;
  1276. if(dctypex>0.025)
  1277. {
  1278. posx= sign(posx)*pow(abs(posx),1.05-dctypex);
  1279. dx=posx*dx;
  1280. }
  1281. if(dctypey>0.025)
  1282. {
  1283. posy= sign(posy)*pow(abs(posy),1.05-dctypey);
  1284. dy=posy*dy;
  1285. }
  1286. float2 rc=deconrx*dx+deconry*dy;
  1287. float2 gc=decongx*dx+decongy*dy;
  1288. float2 bc=deconbx*dx+deconby*dy;
  1289. float r1=COMPAT_TEXTURE(GUEST_S7,coord+rc).r;
  1290. float g1=COMPAT_TEXTURE(GUEST_S7,coord+gc).g;
  1291. float b1=COMPAT_TEXTURE(GUEST_S7,coord+bc).b;
  1292. float ds=decons;
  1293. float3 d=float3(r1,g1,b1);
  1294. c=clamp(lerp(c,d,ds),0.0,1.0);
  1295. r1=COMPAT_TEXTURE(GUEST_S6,boord+rc).r;
  1296. g1=COMPAT_TEXTURE(GUEST_S6,boord+gc).g;
  1297. b1=COMPAT_TEXTURE(GUEST_S6,boord+bc).b;
  1298. d=float3(r1,g1,b1);
  1299. b=g=lerp(b,d,min(ds,1.0));
  1300. r1=COMPAT_TEXTURE(GUEST_S4,boord+rc).r;
  1301. g1=COMPAT_TEXTURE(GUEST_S4,boord+gc).g;
  1302. b1=COMPAT_TEXTURE(GUEST_S4,boord+bc).b;
  1303. d=float3(r1,g1,b1);
  1304. g=lerp(g,d,min(ds,1.0));
  1305. }
  1306.  
  1307. float4 LuminancePS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1308. {
  1309. float m=max(log2(OrgSize.x),log2(OrgSize.y));
  1310. m=floor(max(m,1.0))-1.0;
  1311. float2 dx=float2(1.0/OrgSize.x,0.0);
  1312. float2 dy=float2(0.0,1.0/OrgSize.y);
  1313. float2 x2=2.0*dx;
  1314. float2 y2=2.0*dy;
  1315. float ltotal=0.0;
  1316. ltotal+=length( tex2Dlod(GUEST_S0,float4(float2(0.3,0.3),m,0)).rgb);
  1317. ltotal+=length( tex2Dlod(GUEST_S0,float4(float2(0.3,0.7),m,0)).rgb);
  1318. ltotal+=length( tex2Dlod(GUEST_S0,float4(float2(0.7,0.3),m,0)).rgb);
  1319. ltotal+=length( tex2Dlod(GUEST_S0,float4(float2(0.7,0.7),m,0)).rgb);
  1320. ltotal*=0.25;
  1321. ltotal=pow(0.577350269*ltotal,0.7);
  1322. float lhistory=tex2D(GUEST_S1,0.5).a;
  1323. ltotal=lerp(ltotal,lhistory,lsmooth);
  1324. float3 l1=COMPAT_TEXTURE(GUEST_S0,fuxcoord.xy ).rgb;
  1325. float3 r1=COMPAT_TEXTURE(GUEST_S0,fuxcoord.xy+dx).rgb;
  1326. float3 l2=COMPAT_TEXTURE(GUEST_S0,fuxcoord.xy-dx).rgb;
  1327. float3 r2=COMPAT_TEXTURE(GUEST_S0,fuxcoord.xy+x2).rgb;
  1328. float c1=dist(l2,l1);
  1329. float c2=dist(l1,r1);
  1330. float c3=dist(r2,r1);
  1331. return float4(c1,c2,c3,ltotal);
  1332. }
  1333.  
  1334. float4 LinearizePS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1335. {
  1336. float3 c1=tex2Dlod(GUEST_S0,float4(fuxcoord,0,0)).rgb;
  1337. float3 c2=tex2Dlod(GUEST_S0,float4(fuxcoord+float2(0.0,OrgSize.w),0,0)).rgb;
  1338. if((downsample_levelx+downsample_levely)>0.025)
  1339. {
  1340. c1=fetch_pixel(fuxcoord);
  1341. c2=fetch_pixel(fuxcoord+float2(0.0,OrgSize.w));
  1342. }
  1343. float3 c=c1;
  1344. float intera=1.0;
  1345. float gamma_in=clamp(gamma_i,1.0,5.0);
  1346. float m1=max(max(c1.r,c1.g),c1.b);
  1347. float m2=max(max(c2.r,c2.g),c2.b);
  1348. float3 df=abs(c1-c2);
  1349. float d=max(max(df.r,df.g),df.b);
  1350. if(interm==2.0)d=lerp(0.1*d,10.0*d,step(m1/(m2+0.0001),m2/(m1+0.0001)));
  1351. float r=m1;
  1352. float yres_div=1.0; if(intres>1.25)yres_div=intres;
  1353. bool hscan=(hiscan>0.5);
  1354. if(inter <=OrgSize.y/yres_div&&interm>0.5&&intres!=1.0&&intres!=0.5&&vga_mode<0.5||hscan)
  1355. {
  1356. intera=0.25;
  1357. float liine_no=clamp(floor( mod(OrgSize.y*fuxcoord.y,2.0)),0.0,1.0);
  1358. float frame_no=clamp(floor( mod(float(framecount),2.0)),0.0,1.0);
  1359. float ii=abs(liine_no-frame_no);
  1360. if(interm< 3.5)
  1361. {
  1362. c2=plant(lerp(c2,c2*c2,iscans),max(max(c2.r,c2.g),c2.b));
  1363. r=clamp(max(m1*ii,(1.0-iscan)*min(m1,m2)),0.0,1.0);
  1364. 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);
  1365. if(interm==3.0)c=(1.0-0.5*iscan)*lerp(c2,c1,ii);
  1366. }
  1367. 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);}
  1368. 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*iscan);}
  1369. if(hscan)c=c1;
  1370. }
  1371. if(vga_mode>0.5)
  1372. {
  1373. c=c1;if(inter<=OrgSize.y)intera=0.75; else intera=0.5;
  1374. }
  1375. c=pow(c,gamma_in);
  1376. if(fuxcoord.x>0.5)gamma_in=intera; else gamma_in=1.0/gamma_in;
  1377. return float4(c,gamma_in);
  1378. }
  1379.  
  1380. float4 HGaussianPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1381. {
  1382. 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));
  1383. float f=frac(GaussSize.x*texcoord.x);
  1384. f=0.5-f;
  1385. float2 tex=floor(GaussSize.xy*texcoord)*GaussSize.zw+0.5*GaussSize.zw;
  1386. float3 color=0.0;
  1387. float2 dx=float2(GaussSize.z,0.0);
  1388. float3 pixel;
  1389. float w;
  1390. float wsum=0.0;
  1391. float n=-SIZEH;
  1392. do
  1393. {
  1394. pixel=tex2Dlod(GUEST_S2, float4(tex+n*dx,0,0)).rgb;
  1395. if(m_glow>0.5)
  1396. {
  1397. pixel=max(pixel-m_glow_cutoff,0.0);
  1398. pixel=plant(pixel,max(max(max(pixel.r,pixel.g),pixel.b)-m_glow_cutoff,0.0));
  1399. }
  1400. w=gauss_h(n+f);
  1401. color=color+w*pixel;
  1402. wsum=wsum+w;
  1403. n=n+1.0;
  1404. }while(n<=SIZEH);
  1405. color=color/wsum;
  1406. return float4(color,1.0);
  1407. }
  1408.  
  1409. float4 VGaussianPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1410. {
  1411. 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));
  1412. float f=frac(GaussSize.y*texcoord.y);
  1413. f=0.5-f;
  1414. float2 tex=floor(GaussSize.xy*texcoord)*GaussSize.zw+0.5*GaussSize.zw;
  1415. float3 color=0.0;
  1416. float2 dy=float2(0.0,GaussSize.w);
  1417. float3 pixel;
  1418. float w;
  1419. float wsum=0.0;
  1420. float n=-SIZEV;
  1421. do
  1422. {
  1423. pixel=tex2Dlod(GUEST_S3, float4(tex+n*dy,0,0)).rgb;
  1424. w=gauss_v(n+f);
  1425. color=color+w*pixel;
  1426. wsum=wsum+w;
  1427. n=n+1.0;
  1428. }while(n<=SIZEV);
  1429. color=color/wsum;
  1430. return float4(color,1.0);
  1431. }
  1432.  
  1433. float4 BloomHorzPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1434. {
  1435. 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));
  1436. float f=frac(BloomSize.x*texcoord.x);
  1437. f=0.5-f;
  1438. float2 tex=floor(BloomSize.xy*texcoord)*BloomSize.zw+0.5*BloomSize.zw;
  1439. float4 color=0.0;
  1440. float2 dx=float2(BloomSize.z,0.0);
  1441. float4 pixel;
  1442. float w;
  1443. float wsum=0.0;
  1444. float n=-SIZEX;
  1445. do
  1446. {
  1447. pixel=tex2Dlod(GUEST_S2, float4(tex+n*dx,0,0));
  1448. w=bloom_h(n+f);
  1449. pixel.a =max(max(pixel.r,pixel.g),pixel.b);
  1450. pixel.a*=pixel.a*pixel.a;
  1451. color=color+w*pixel;
  1452. wsum=wsum+w;
  1453. n=n+1.0;
  1454. }while(n<=SIZEX);
  1455. color=color/wsum;
  1456. return float4(color.rgb,pow(color.a,0.333333));
  1457. }
  1458.  
  1459. float4 BloomVertPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1460. {
  1461. 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));
  1462. float f=frac(BloomSize.y*texcoord.y);
  1463. f=0.5-f;
  1464. float2 tex=floor(BloomSize.xy*texcoord)*BloomSize.zw+0.5*BloomSize.zw;
  1465. float4 color=0.0;
  1466. float2 dy=float2(0.0,BloomSize.w);
  1467. float4 pixel;
  1468. float w;
  1469. float wsum=0.0;
  1470. float n=-SIZEY;
  1471. do
  1472. {
  1473. pixel=tex2Dlod(GUEST_S5, float4(tex+n*dy,0,0));
  1474. w=bloom_v(n+f);
  1475. pixel.a*=pixel.a*pixel.a;
  1476. color=color+w*pixel;
  1477. wsum=wsum+w;
  1478. n=n+1.0;
  1479. }while(n<=SIZEY);
  1480. color=color/wsum;
  1481. return float4(color.rgb,pow(color.a,0.175000));
  1482. }
  1483.  
  1484. float4 Advanced_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1485. {
  1486. float2 prescalex=(tex2Dsize(GUEST_S2,0))/OrgSize.xy;
  1487. float4 AdvSize=OrgSize*lerp(float4(prescalex.x,1.0,1.0/prescalex.x,1.0),float4(1.0,prescalex.y,1.0,1.0/prescalex.y),TATE);
  1488. float gamma_in=1.0/COMPAT_TEXTURE(GUEST_S2,0.25).a;
  1489. float lum=COMPAT_TEXTURE(GUEST_S1,0.5).a;
  1490. float intera=COMPAT_TEXTURE(GUEST_S2,float2(0.75,0.25)).a;
  1491. bool hscan=(hiscan>0.5);
  1492. bool interb=(((intera<0.35)||(no_scanlines>0.025))&&!hscan);
  1493. bool notate=(TATE<0.5);
  1494. bool vgascan=((abs(intera-0.5)<0.05)&&(no_scanlines==0.0));
  1495. float SourceY=lerp(AdvSize.y,AdvSize.x,TATE);
  1496. float sy=1.0;
  1497. if( intres==1.0)sy=SourceY/224.0;
  1498. if( intres>0.25&&intres!=1.0)sy=intres;
  1499. if(vgascan)sy=0.5; else if(abs(intera-0.75)<0.05)sy=1.0;
  1500. if( notate)AdvSize*=float4(1.0,1.0/sy,1.0,sy);else AdvSize*=float4(1.0/sy,1.0,sy,1.0);
  1501. float2 lexcoord = fuxcoord.xy;
  1502. if(IOS> 0.0&&!interb)
  1503. {
  1504. float2 ofactor=OptSize.xy/OrgSize.xy;
  1505. float2 intfactor=(IOS<2.5)?floor(ofactor):ceil(ofactor);
  1506. float2 diff=ofactor/intfactor;
  1507. float scan=lerp(diff.y,diff.x,TATE);
  1508. lexcoord=overscan(lexcoord,scan,scan);
  1509. if(IOS==1.0||IOS==3.0)lexcoord=lerp(float2(fuxcoord.x,lexcoord.y),float2(lexcoord.x,fuxcoord.y),TATE);
  1510. }
  1511. float factor=1.0+(1.0-0.5*OS)*blm_2/100.0-lum*blm_2/100.0;
  1512. lexcoord=overscan(lexcoord,factor,factor);
  1513. lexcoord=overscan(lexcoord,(OrgSize.x-overscanx)/OrgSize.x,(OrgSize.y-overscany)/OrgSize.y);
  1514. float2 pos=warp(lexcoord);
  1515. bool smarte=(smart_ei>0.01&&notate);
  1516. float2 coffset=0.5;
  1517. float2 ps=AdvSize.zw;
  1518. float2 OGL2Pos=pos*AdvSize.xy-coffset;
  1519. float2 fp=frac(OGL2Pos);
  1520. float2 dx=float2(ps.x,0.0);
  1521. float2 dy=float2(0.0,ps.y);
  1522. float2 x2=2.0*dx;
  1523. float2 y2=2.0*dy;
  1524. float2 offx=dx;
  1525. float2 off2=x2;
  1526. float2 offy=dy;
  1527. float fpx=fp.x;
  1528. if(!notate){offx=dy;off2=y2;offy=dx;fpx=fp.y;}
  1529. float f=(notate)?fp.y:fp.x;
  1530. float2 pC4=floor(OGL2Pos)*ps+0.5*ps;
  1531. if((intres==0.5&& notate&&prescalex.y<1.5)|| vgascan )pC4.y=floor(pC4.y*OrgSize.y)*OrgSize.w+0.5*OrgSize.w;
  1532. if((intres==0.5&&!notate&&prescalex.x<1.5)||(vgascan&&!notate))pC4.x=floor(pC4.x*OrgSize.x)*OrgSize.z+0.5*OrgSize.z;
  1533. if( interb&&no_scanlines<0.025&&!hscan)pC4.y=pos.y;else
  1534. if( interb)pC4.y=pC4.y+smoothstep(0.40-0.5*no_scanlines,0.60+0.5*no_scanlines,f)*lerp(AdvSize.w,AdvSize.z,TATE);
  1535. if(hscan)pC4=lerp(float2(pC4.x,pos.y),float2(pos.x,pC4.y),TATE);
  1536. float zero=exp2(-h_sharp);
  1537. float idiv=clamp(lerp(AdvSize.x,AdvSize.y,TATE)/400.0,1.0,2.0);
  1538. float fdivider=max(min(lerp(prescalex.x,prescalex.y,TATE),2.0),idiv*float(interb));
  1539. float wl3=(2.0+fpx)/fdivider;
  1540. float wl2=(1.0+fpx)/fdivider;
  1541. float wl1=( fpx)/fdivider;
  1542. float wr1=(1.0-fpx)/fdivider;
  1543. float wr2=(2.0-fpx)/fdivider;
  1544. float wr3=(3.0-fpx)/fdivider;
  1545. wl3*=wl3;wl3=exp2(-h_sharp*wl3);
  1546. wl2*=wl2;wl2=exp2(-h_sharp*wl2);
  1547. wl1*=wl1;wl1=exp2(-h_sharp*wl1);
  1548. wr1*=wr1;wr1=exp2(-h_sharp*wr1);
  1549. wr2*=wr2;wr2=exp2(-h_sharp*wr2);
  1550. wr3*=wr3;wr3=exp2(-h_sharp*wr3);
  1551. float sharp1=s_sharp*zero;
  1552. float fp1=1.-fpx;
  1553. float twl3=max(wl3-sharp1, 0.0 );
  1554. float twl2=max(wl2-sharp1,lerp(-0.12,0.0,1.0-fp1*fp1));
  1555. float twl1=max(wl1-sharp1,-0.12);
  1556. float twr1=max(wr1-sharp1,-0.12);
  1557. float twr2=max(wr2-sharp1,lerp(-0.12,0.0,1.0-fpx*fpx));
  1558. float twr3=max(wr3-sharp1, 0.0 );
  1559. bool sharp=(sharp1>0.0);
  1560. float3 c1,c2;
  1561. if( smarte)
  1562. {
  1563. twl3=0.0;twr3=0.0;
  1564. c1=tex2Dlod(GUEST_S1,float4(pC4 ,0,0)).xyz;
  1565. c2=tex2Dlod(GUEST_S1,float4(pC4+offy,0,0)).xyz;
  1566. c1=max(c1-sth,0.0);
  1567. c2=max(c2-sth,0.0);
  1568. }
  1569. float3 l3,l2,l1,r1,r2,r3,color1,color2,colmin,colmax;
  1570. l3=tex2Dlod(GUEST_S2,float4(pC4-off2 ,0,0)).rgb;
  1571. l2=tex2Dlod(GUEST_S2,float4(pC4-offx ,0,0)).rgb;
  1572. l1=tex2Dlod(GUEST_S2,float4(pC4 ,0,0)).rgb;
  1573. r1=tex2Dlod(GUEST_S2,float4(pC4+offx ,0,0)).rgb;
  1574. r2=tex2Dlod(GUEST_S2,float4(pC4+off2 ,0,0)).rgb;
  1575. r3=tex2Dlod(GUEST_S2,float4(pC4+offx+off2,0,0)).rgb;
  1576. colmin=min(min(l1,r1),min(l2,r2));
  1577. colmax=max(max(l1,r1),max(l2,r2));
  1578. if( smarte)
  1579. {
  1580. float pc=min(smart_ei*c1.y,ei_limit);
  1581. float pl=min(smart_ei*max(c1.y,c1.x),ei_limit);
  1582. float pr=min(smart_ei*max(c1.y,c1.z),ei_limit);
  1583. twl1=max(wl1-pc,0.01*wl1);twr1=max(wr1-pc,0.01*wr1);
  1584. twl2=max(wl2-pl,0.01*wl2);twr2=max(wr2-pr,0.01*wr2);
  1585. }
  1586. color1=(l3*twl3+l2*twl2+l1*twl1+r1*twr1+r2*twr2+r3*twr3)/(twl3+twl2+twl1+twr1+twr2+twr3);
  1587. if(sharp)color1=clamp(lerp(clamp(color1,colmin,colmax),color1,ring),0.0,1.0);
  1588. float ts=0.025;
  1589. float3 luma=float3(0.2126,0.7152,0.0722);
  1590. float lm2=max(max(l2.r,l2.g),l2.b);
  1591. float lm1=max(max(l1.r,l1.g),l1.b);
  1592. float rm1=max(max(r1.r,r1.g),r1.b);
  1593. float rm2=max(max(r2.r,r2.g),r2.b);
  1594. float swl2=max(twl2,0.0)*(dot(l2,luma)+ts);
  1595. float swl1=max(twl1,0.0)*(dot(l1,luma)+ts);
  1596. float swr1=max(twr1,0.0)*(dot(r1,luma)+ts);
  1597. float swr2=max(twr2,0.0)*(dot(r2,luma)+ts);
  1598. float fscolor1=(lm2*swl2+lm1*swl1+rm1*swr1+rm2*swr2)/(swl2+swl1+swr1+swr2);
  1599. float3 scolor1=clamp(lerp(max(max(color1.r,color1.g),color1.b),fscolor1,spike),0.0,1.0);
  1600. if(!interb)color1=pow(color1,scangamma/gamma_in);
  1601. float3 scolor2;
  1602. if(!interb&&!hscan)
  1603. {
  1604. pC4+=offy;
  1605. if((intres==0.5&& notate&&prescalex.y<1.5)|| vgascan )pC4.y=floor((pos.y+0.33*offy.y)*OrgSize.y)*OrgSize.w+0.5*OrgSize.w;
  1606. if((intres==0.5&&!notate&&prescalex.x<1.5)||(vgascan&&!notate))pC4.x=floor((pos.x+0.33*offy.x)*OrgSize.x)*OrgSize.z+0.5*OrgSize.z;
  1607. l3=tex2Dlod(GUEST_S2,float4(pC4-off2 ,0,0)).rgb;
  1608. l2=tex2Dlod(GUEST_S2,float4(pC4-offx ,0,0)).rgb;
  1609. l1=tex2Dlod(GUEST_S2,float4(pC4 ,0,0)).rgb;
  1610. r1=tex2Dlod(GUEST_S2,float4(pC4+offx ,0,0)).rgb;
  1611. r2=tex2Dlod(GUEST_S2,float4(pC4+off2 ,0,0)).rgb;
  1612. r3=tex2Dlod(GUEST_S2,float4(pC4+offx+off2,0,0)).rgb;
  1613. colmin=min(min(l1,r1),min(l2,r2));
  1614. colmax=max(max(l1,r1),max(l2,r2));
  1615. if( smarte)
  1616. {
  1617. float pc=min(smart_ei*c2.y,ei_limit);
  1618. float pl=min(smart_ei*max(c2.y,c2.x),ei_limit);
  1619. float pr=min(smart_ei*max(c2.y,c2.z),ei_limit);
  1620. twl1=max(wl1-pc,0.01*wl1);twr1=max(wr1-pc,0.01*wr1);
  1621. twl2=max(wl2-pl,0.01*wl2);twr2=max(wr2-pr,0.01*wr2);
  1622. }
  1623. color2=(l3*twl3+l2*twl2+l1*twl1+r1*twr1+r2*twr2+r3*twr3)/(twl3+twl2+twl1+twr1+twr2+twr3);
  1624. if(sharp)color2=clamp(lerp(clamp(color2,colmin,colmax),color2,ring),0.0,1.0);
  1625. lm2=max(max(l2.r,l2.g),l2.b);
  1626. lm1=max(max(l1.r,l1.g),l1.b);
  1627. rm1=max(max(r1.r,r1.g),r1.b);
  1628. rm2=max(max(r2.r,r2.g),r2.b);
  1629. swl2=max(twl2,0.0)*(dot(l2,luma)+ts);
  1630. swl1=max(twl1,0.0)*(dot(l1,luma)+ts);
  1631. swr1=max(twr1,0.0)*(dot(r1,luma)+ts);
  1632. swr2=max(twr2,0.0)*(dot(r2,luma)+ts);
  1633. float fscolor2=(lm2*swl2+lm1*swl1+rm1*swr1+rm2*swr2)/(swl2+swl1+swr1+swr2);
  1634. scolor2=clamp(lerp(max(max(color2.r,color2.g),color2.b),fscolor2,spike),0.0,1.0);
  1635. color2=pow(color2,scangamma/gamma_in);
  1636. }
  1637. float3 ctmp=color1;float w3=1.0;float3 color=color1;
  1638. float3 one=1.0;
  1639. if(hscan){color2=color1;scolor2=scolor1;}
  1640. if(!interb)
  1641. {
  1642. float ssub=ssharp*max(abs(scolor1.x-scolor2.x),abs(dot(color1,luma)-dot(color2,luma)));
  1643. float shape1=lerp(scanline1,scanline2+ssub*scolor1.x*35.0, f);
  1644. float shape2=lerp(scanline1,scanline2+ssub*scolor2.x*35.0,1.0-f);
  1645. float wt1=st0( f);
  1646. float wt2=st0(1.0- f);
  1647. float3 color0= color1*wt1+ color2*wt2;
  1648. float3 scolor0=scolor1*wt1+scolor2*wt2;
  1649. ctmp=color0/(wt1+wt2);
  1650. float3 sctmp=scolor0/(wt1+wt2);
  1651. float3 w1,w2;
  1652. float3 cref1=lerp(sctmp,scolor1,beam_size);float creff1=pow(max(max(cref1.r,cref1.g),cref1.b),scan_falloff);
  1653. float3 cref2=lerp(sctmp,scolor2,beam_size);float creff2=pow(max(max(cref2.r,cref2.g),cref2.b),scan_falloff);
  1654. if(tds>0.5){shape1=lerp(scanline2,shape1,creff1);shape2=lerp(scanline2,shape2,creff2);}
  1655. float f1= f;
  1656. float f2=1.0- f;
  1657. float m1=max(max(color1.r,color1.g),color1.b)+eps;
  1658. float m2=max(max(color2.r,color2.g),color2.b)+eps;
  1659. cref1=color1/m1;
  1660. cref2=color2/m2;
  1661. if(gsl< 0.5)
  1662. {w1=sw0(f1,creff1,shape1,cref1);w2=sw0(f2,creff2,shape2,cref2);}else
  1663. if(gsl==1.0)
  1664. {w1=sw1(f1,creff1,shape1,cref1);w2=sw1(f2,creff2,shape2,cref2);}else
  1665. {w1=sw2(f1,creff1,shape1,cref1);w2=sw2(f2,creff2,shape2,cref2);}
  1666. float3 w3=w1+w2;
  1667. float wf1=max(max(w3.r,w3.g),w3.b);
  1668. if(wf1> 1.0) {wf1=1.0/wf1; w1*=wf1, w2*=wf1;}
  1669. if(abs(clp)>0.005)
  1670. {
  1671. sy=m1; one=(clp>0.0)?w1:1.0.xxx;
  1672. float sat=1.0001-min(min(cref1.r,cref1.g),cref1.b);
  1673. color1=lerp(color1,plant(pow(color1,0.70.xxx-0.325*sat),sy),pow(sat,0.3333)*one*abs(clp));
  1674. sy=m2; one=(clp>0.0)?w2:1.0.xxx;
  1675. sat=1.0001-min(min(cref2.r,cref2.g),cref2.b);
  1676. color2=lerp(color2,plant(pow(color2,0.70.xxx-0.325*sat),sy),pow(sat,0.3333)*one*abs(clp));
  1677. }
  1678. color=(gc(color1)*w1+gc(color2)*w2);
  1679. color=min(color,1.0);
  1680. }
  1681. if( interb)
  1682. {
  1683. color=gc(color1);
  1684. }
  1685. float colmx=max(max(ctmp.r,ctmp.g),ctmp.b);
  1686. if(!interb)color=pow(color,gamma_in/scangamma);
  1687. return float4(color,colmx);
  1688. }
  1689.  
  1690. float4 ChromaticPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1691. {
  1692. float gamma_in=1.0/COMPAT_TEXTURE(GUEST_S2,0.25).a;
  1693. float lum=COMPAT_TEXTURE(GUEST_S1,0.5).a;
  1694. float intera=COMPAT_TEXTURE(GUEST_S2,float2(0.75,0.25)).a;
  1695. bool interb=((intera<0.35||no_scanlines>0.025)&&(hiscan<0.5));
  1696. bool notate=(TATE<0.5);
  1697. float2 lexcoord = fuxcoord.xy;
  1698. if(IOS> 0.0&&!interb)
  1699. {
  1700. float2 ofactor= OptSize.xy/OrgSize.xy;
  1701. float2 intfactor=(IOS<2.5)?floor(ofactor):ceil(ofactor);
  1702. float2 diff=ofactor/intfactor;
  1703. float scan=lerp(diff.y,diff.x,TATE);
  1704. lexcoord=overscan(lexcoord,scan,scan);
  1705. if(IOS==1.0||IOS==3.0)lexcoord=lerp(float2(fuxcoord.x,lexcoord.y),float2(lexcoord.x,fuxcoord.y),TATE);
  1706. }
  1707. float factor=1.0+(1.0-0.5*OS)*blm_2/100.0-lum*blm_2/100.0;
  1708. lexcoord=overscan(lexcoord,factor,factor);
  1709. lexcoord=overscan(lexcoord,(OrgSize.x-overscanx)/OrgSize.x,(OrgSize.y-overscany)/OrgSize.y);
  1710. float2 pos0=warp(fuxcoord.xy);
  1711. float2 pos1=fuxcoord.xy;
  1712. float2 pos=warp(lexcoord);
  1713. float3 color=COMPAT_TEXTURE(GUEST_S7,pos1).rgb;
  1714. float3 Bloom=COMPAT_TEXTURE(GUEST_S6,pos).rgb;
  1715. float3 Glow=COMPAT_TEXTURE(GUEST_S4,pos).rgb;
  1716. if((abs(deconrx)+abs(deconry)+abs(decongx)+abs(decongy)+abs(deconbx)+abs(deconby))>0.2)
  1717. bring_pixel(color,Bloom,Glow,pos1,pos);
  1718. float cm=igc(max(max(color.r,color.g),color.b));
  1719. float mx1=COMPAT_TEXTURE(GUEST_S7,pos1 ).a;
  1720. float colmx=max(mx1,cm);
  1721. float w3=min((cm+0.0001)/(colmx+0.0005),1.0); if(interb)w3=1.0;
  1722. float2 dx= lerp(float2(0.001,0.0),float2(0.0,0.001),TATE);
  1723. float mx0=tex2Dlod(GUEST_S7,float4(pos1-dx,0,0)).a;
  1724. float mx2=tex2Dlod(GUEST_S7,float4(pos1+dx,0,0)).a;
  1725. float mxg=max(max(mx0,mx1),max(mx2,cm));
  1726. float mx=pow(mxg,1.40/gamma_in);
  1727. dx=lerp(float2(OrgSize.z,0.0),float2(0.0,OrgSize.w),TATE)*0.25;
  1728. mx0=tex2Dlod(GUEST_S7,float4(pos1-dx,0,0)).a;
  1729. mx2=tex2Dlod(GUEST_S7,float4(pos1+dx,0,0)).a;
  1730. float mb=(1.0-min(abs(mx0-mx2)/(0.5+mx1),1.0));
  1731. float3 orig1=color;
  1732. float3 one=1.0;
  1733. float3 cmask=one;
  1734. float3 dmask=one;
  1735. float3 emask=one;
  1736. 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};
  1737. float mwidth=mwidths[int(shadow_msk)];
  1738. float mask_compensate=frac(mwidth);
  1739. if(shadow_msk> 0.5)
  1740. {
  1741. float2 maskcoord=fracoord.yx* 1.00001;
  1742. if( notate)maskcoord=maskcoord.yx;
  1743. float2 scoord=maskcoord;
  1744. mwidth=floor(mwidth)*masksize;
  1745. float swidth=mwidth;
  1746. bool zoomed=(abs(mask_zoom)>0.75);
  1747. float mscale=1.0;
  1748. float2 maskcoord0=maskcoord;
  1749. maskcoord.y=floor(maskcoord.y/masksize);
  1750. float mwidth1=max(mwidth+mask_zoom,2.0);
  1751. if( mshift> 0.25)
  1752. {
  1753. float stagg_lvl=1.0; if(frac(mshift)>0.25)stagg_lvl=2.0;
  1754. float next_line=float(floor(mod(maskcoord.y,2.0*stagg_lvl))<stagg_lvl);
  1755. maskcoord0.x=maskcoord0.x+next_line*0.5*mwidth1;
  1756. }
  1757. maskcoord=maskcoord0/masksize;
  1758. if(!zoomed)cmask*=crt_mask(floor(maskcoord),mx,mb);else
  1759. {
  1760. mscale=mwidth1/mwidth;
  1761. float mlerp= frac(maskcoord.x/mscale); if(zoom_mask>0.025)mlerp=(1.0+zoom_mask)*mlerp-0.5*zoom_mask;
  1762. float mcoord=floor(maskcoord.x/mscale); if(shadow_msk==13.0&&mask_zoom==-2.0)mcoord=ceil(maskcoord.x/mscale);
  1763. cmask*=max(lerp(crt_mask(float2(mcoord,maskcoord.y),mx,mb),crt_mask(float2(mcoord+1.0,maskcoord.y),mx,mb),mlerp),0.0);
  1764. }
  1765. if(slotwidth>0.5)swidth=slotwidth;float smask=1.0;
  1766. 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);
  1767. if( zoomed)
  1768. {
  1769. if(mask_layout<0.5&&bsm_offset)sm_offset=1.0;else
  1770. if(bsm_offset)sm_offset=-1.0;
  1771. }
  1772. swidth=round(swidth*mscale);
  1773. smask=slt_mask(scoord+float2(sm_offset,0.0),mx,swidth);
  1774. 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);
  1775. emask =cmask;
  1776. cmask*=smask;
  1777. dmask =cmask;
  1778. if(abs(mask_bloom)>0.025)
  1779. {
  1780. float maxbl=max(max(max(Bloom.r,Bloom.g),Bloom.b),mxg);
  1781. maxbl=maxbl*max(lerp(1.0,2.0-colmx,bloom_dist),0.0);
  1782. if(mask_bloom>0.025)cmask=max(min(cmask+maxbl*mask_bloom,1.0),cmask);else
  1783. cmask=max(lerp(cmask,cmask*(1.0-0.5*maxbl)+plant(pow(Bloom,0.35.xxx),maxbl),-mask_bloom),cmask);
  1784. }
  1785. color=pow(color,mask_gamma/gamma_in);
  1786. color=color*cmask;
  1787. color=min(color,1.0);
  1788. color=pow(color,gamma_in/mask_gamma);
  1789. cmask=min(cmask,1.0);
  1790. dmask=min(dmask,1.0);
  1791. }
  1792. 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;
  1793. float bb=lerp(brightboost1,brightboost2,mx)* dark_compensate; color*=bb;
  1794. float3 Ref=COMPAT_TEXTURE(GUEST_S2,pos).rgb;
  1795. float maxb=COMPAT_TEXTURE(GUEST_S6,pos).a;
  1796. float3 bcmask=lerp(one,cmask,bmask1);
  1797. float3 hcmask=lerp(one,cmask,hmask1);
  1798. float3 Bloom1=Bloom;
  1799. if(abs(blm_1)>0.025)
  1800. {
  1801. if(blm_1<-0.01)Bloom1=plant(Bloom,maxb);
  1802. Bloom1= min(Bloom1*(orig1+color), max(0.5*(colmx+orig1-color),0.001*Bloom1));
  1803. Bloom1=0.5*(Bloom1+lerp(Bloom1,lerp(colmx*orig1,Bloom1,0.5),1.0-color));
  1804. Bloom1=bcmask*Bloom1*max(lerp(1.0,2.0-colmx,bloom_dist),0.0);
  1805. color=pow(pow(color,mask_gamma/gamma_in)+abs(blm_1)*pow(Bloom1,mask_gamma/gamma_in),gamma_in/mask_gamma);
  1806. }
  1807. if(!interb) color=declip(min(color,1.0), lerp(1.0,w3,0.6));
  1808. if(halation> 0.01)
  1809. {
  1810. Bloom=lerp(0.5*(Bloom+Bloom*Bloom),0.75*Bloom*Bloom,colmx);
  1811. 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;
  1812. }else
  1813. if(halation<-0.01)
  1814. {
  1815. float mbl=max(max(Bloom.r,Bloom.g),Bloom.b);
  1816. Bloom=plant(Bloom+Ref+orig1+Bloom*Bloom*Bloom,min(mbl*mbl,0.75));
  1817. color=color+2.0*lerp(1.0,w3,0.5*colmx)*hcmask*Bloom*(-halation);
  1818. }
  1819. float w=0.25+0.60*lerp(w3,1.0,sqrt(colmx));
  1820. if(smoothmask>0.5)
  1821. {
  1822. color=min(color,1.0); color=max(min(color/w3,1.0)*w3, min(orig1*bb,color*(1.0-w3)));
  1823. }
  1824. if(m_glow<0.5)Glow=lerp(Glow,0.25*color,colmx);else
  1825. {
  1826. float3 orig2=plant(orig1+0.001*Ref,1.0);
  1827. maxb=max(max(Glow.r,Glow.g),Glow.b);
  1828. Bloom=plant(Glow,1.0);Ref=abs(orig2-Bloom);
  1829. mx0=max(max(orig2.g,orig2.g),orig2.b)-min(min(orig2.g,orig2.g),orig2.b);
  1830. mx2=max(max(Bloom.g,Bloom.g),Bloom.b)-min(min(Bloom.g,Bloom.g),Bloom.b);
  1831. 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));
  1832. Glow=lerp(m_glow_low*Glow,m_glow_high*Bloom,pow(colmx,m_glow_dist/gamma_in));
  1833. }
  1834. if(m_glow<0.5)
  1835. {
  1836. if(glow >=0.0)color=color+0.5*Glow*glow;else color=color+abs(glow)*min(emask*emask,1.0)*Glow;}else
  1837. {
  1838. dmask= clamp(lerp(one,dmask,m_glow_mask),0.0,1.0); color=color+abs(glow)*dmask*Glow;
  1839. }
  1840. float vig=vignette(pos);
  1841. color=min(color,1.0);
  1842. color=pow(color,1.0/gamma_o);
  1843. float rc=0.6*sqrt(max(max(color.r,color.g),color.b))+0.4;
  1844. if(abs(addnoised)>0.01)
  1845. {
  1846. float3 noise0=noise(float3(floor(OptSize.xy*fuxcoord/noiseresd),float(framecount)));
  1847. if(noisetype<0.5)color=lerp(color,noise0,0.25*abs(addnoised)*rc);else
  1848. color=min(color*lerp(1.0,1.5*noise0.x,0.5*abs(addnoised)),1.0);
  1849. }
  1850. colmx=max(max(orig1.r,orig1.g),orig1.b);
  1851. color=color+bmask*lerp(emask,0.125*(1.0-colmx)*color,min(20.0*colmx,1.0));
  1852. return float4(color*vig*humbars(lerp(pos.y,pos.x,bardir))*post_br*corner(pos0),1.0);
  1853. }
  1854.  
  1855. technique CRT_Guest_Advanced
  1856. {
  1857. pass Luminance
  1858. {
  1859. VertexShader=PostProcessVS;
  1860. PixelShader=LuminancePS;
  1861. RenderTarget=GUEST_T1;
  1862. }
  1863. pass Linearize
  1864. {
  1865. VertexShader=PostProcessVS;
  1866. PixelShader=LinearizePS;
  1867. RenderTarget=GUEST_T2;
  1868. }
  1869. pass GaussianX
  1870. {
  1871. VertexShader=PostProcessVS;
  1872. PixelShader=HGaussianPS;
  1873. RenderTarget=GUEST_T3;
  1874. }
  1875. pass GaussianY
  1876. {
  1877. VertexShader=PostProcessVS;
  1878. PixelShader=VGaussianPS;
  1879. RenderTarget=GUEST_T4;
  1880. }
  1881. pass BloomHorz
  1882. {
  1883. VertexShader=PostProcessVS;
  1884. PixelShader=BloomHorzPS;
  1885. RenderTarget=GUEST_T5;
  1886. }
  1887. pass BloomVert
  1888. {
  1889. VertexShader=PostProcessVS;
  1890. PixelShader=BloomVertPS;
  1891. RenderTarget=GUEST_T6;
  1892. }
  1893. pass Guest_CRT
  1894. {
  1895. VertexShader=PostProcessVS;
  1896. PixelShader=Advanced_PS;
  1897. RenderTarget=GUEST_T7;
  1898. }
  1899. pass Chromatic
  1900. {
  1901. VertexShader=PostProcessVS;
  1902. PixelShader=ChromaticPS;
  1903. }
  1904. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement