Advertisement
Guest User

CRT-Guest-Advanced (DX9 Fix Test)

a guest
Jun 17th, 2023
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 56.24 KB | None | 0 0
  1. /*
  2.  
  3. CRT - Guest - Advanced (Copyright (C) 2018-2023 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 ResolutionX <
  23. ui_label = "Resolution X";
  24. > = 320.0;
  25.  
  26. uniform float ResolutionY <
  27. ui_label = "Resolution Y";
  28. > = 240.0;
  29.  
  30. uniform float PR <
  31. ui_type = "drag";
  32. ui_min = 0.0;
  33. ui_max = 0.5;
  34. ui_step = 0.01;
  35. ui_label = "Persistence Red";
  36. > = 0.32;
  37.  
  38. uniform float PG <
  39. ui_type = "drag";
  40. ui_min = 0.0;
  41. ui_max = 0.5;
  42. ui_step = 0.01;
  43. ui_label = "Persistence Green";
  44. > = 0.32;
  45.  
  46. uniform float PB <
  47. ui_type = "drag";
  48. ui_min = 0.0;
  49. ui_max = 0.5;
  50. ui_step = 0.01;
  51. ui_label = "Persistence Blue";
  52. > = 0.32;
  53.  
  54. uniform float AS <
  55. ui_type = "drag";
  56. ui_min = 0.0;
  57. ui_max = 0.6;
  58. ui_step = 0.01;
  59. ui_label = "Afterglow Strength";
  60. > = 0.2;
  61.  
  62. uniform float sat <
  63. ui_type = "drag";
  64. ui_min = 0.0;
  65. ui_max = 1.0;
  66. ui_step = 0.01;
  67. ui_label = "Afterglow Saturation";
  68. > = 0.5;
  69.  
  70. uniform float CS <
  71. ui_type = "drag";
  72. ui_min = 0.0;
  73. ui_max = 4.0;
  74. ui_step = 1.0;
  75. ui_label = "Display Gamut: sRGB | Modern | DCI | Adobe | Rec. 2020";
  76. > = 0.0;
  77.  
  78. uniform float CP <
  79. ui_type = "drag";
  80. ui_min = -1.0;
  81. ui_max = 5.0;
  82. ui_step = 1.0;
  83. ui_label = "CRT Profile: EBU | P22 | SMPTE-C | Philips | Trinitron";
  84. > = 0.0;
  85.  
  86. uniform float TNTC <
  87. ui_type = "drag";
  88. ui_min = 0.0;
  89. ui_max = 4.0;
  90. ui_step = 1.0;
  91. ui_label = "LUT Colors: Trinitron 1 | Trinitron 2 | Nec MultiSync | NTSC";
  92. > = 0.0;
  93.  
  94. uniform float LUTLOW <
  95. ui_type = "drag";
  96. ui_min = 0.0;
  97. ui_max = 50.0;
  98. ui_step = 1.0;
  99. ui_label = "Fix LUT Dark Range";
  100. > = 5.0;
  101.  
  102. uniform float LUTBR <
  103. ui_type = "drag";
  104. ui_min = 0.0;
  105. ui_max = 1.0;
  106. ui_step = 0.01;
  107. ui_label = "Fix LUT Brightness";
  108. > = 1.0;
  109.  
  110. uniform float WP <
  111. ui_type = "drag";
  112. ui_min = -100.0;
  113. ui_max = 100.0;
  114. ui_step = 5.0;
  115. ui_label = "Color Temperature %";
  116. > = 0.0;
  117.  
  118. uniform float wp_saturation <
  119. ui_type = "drag";
  120. ui_min = 0.0;
  121. ui_max = 2.0;
  122. ui_step = 0.05;
  123. ui_label = "Saturation Adjustment";
  124. > = 1.0;
  125.  
  126. uniform float pre_bb <
  127. ui_type = "drag";
  128. ui_min = 0.0;
  129. ui_max = 2.0;
  130. ui_step = 0.01;
  131. ui_label = "Brightness Adjustment";
  132. > = 1.0;
  133.  
  134. uniform float contr <
  135. ui_type = "drag";
  136. ui_min = -2.0;
  137. ui_max = 2.0;
  138. ui_step = 0.05;
  139. ui_label = "Contrast Adjustment";
  140. > = 0.0;
  141.  
  142. uniform float sega_fix <
  143. ui_type = "drag";
  144. ui_min = 0.0;
  145. ui_max = 1.0;
  146. ui_step = 1.0;
  147. ui_label = "Sega Brightness Fix";
  148. > = 0.0;
  149.  
  150. uniform float BP <
  151. ui_type = "drag";
  152. ui_min = -100.0;
  153. ui_max = 25.0;
  154. ui_step = 1.0;
  155. ui_label = "Raise Black Level";
  156. > = 0.0;
  157.  
  158. uniform float vigstr <
  159. ui_type = "drag";
  160. ui_min = 0.0;
  161. ui_max = 2.0;
  162. ui_step = 0.05;
  163. ui_label = "Vignette Strength";
  164. > = 0.0;
  165.  
  166. uniform float vigdef <
  167. ui_type = "drag";
  168. ui_min = 0.5;
  169. ui_max = 3.0;
  170. ui_step = 0.1;
  171. ui_label = "Vignette Size";
  172. > = 1.0;
  173.  
  174. uniform float lsmooth <
  175. ui_type = "drag";
  176. ui_min = 0.5;
  177. ui_max = 1.0;
  178. ui_step = 0.01;
  179. ui_label = "Raster Bloom Effect Smoothing";
  180. > = 0.7;
  181.  
  182. uniform float gamma_i <
  183. ui_type = "drag";
  184. ui_min = 1.0;
  185. ui_max = 5.0;
  186. ui_step = 0.05;
  187. ui_label = "Gamma Input";
  188. > = 2.4;
  189.  
  190. uniform float gamma_o <
  191. ui_type = "drag";
  192. ui_min = 1.0;
  193. ui_max = 5.0;
  194. ui_step = 0.05;
  195. ui_label = "Gamma Out";
  196. > = 2.4;
  197.  
  198. uniform float inter <
  199. ui_type = "drag";
  200. ui_min = 0.0;
  201. ui_max = 800.0;
  202. ui_step = 25.0;
  203. ui_label = "Interlace Trigger Resolution";
  204. > = 400.0;
  205.  
  206. uniform float interm <
  207. ui_type = "drag";
  208. ui_min = 0.0;
  209. ui_max = 5.0;
  210. ui_step = 1.0;
  211. ui_label = "Interlace Mode: OFF | Normal 1-3 | Interpolation 4-5";
  212. > = 1.0;
  213.  
  214. uniform float iscan <
  215. ui_type = "drag";
  216. ui_min = 0.0;
  217. ui_max = 1.0;
  218. ui_step = 0.05;
  219. ui_label = "Interlacing Scanline Effect (Interlaced Brightness)";
  220. > = 0.2;
  221.  
  222. uniform float iscans <
  223. ui_type = "drag";
  224. ui_min = 0.0;
  225. ui_max = 1.0;
  226. ui_step = 0.05;
  227. ui_label = "Interlacing Scanline Saturation";
  228. > = 0.25;
  229.  
  230. uniform float intres <
  231. ui_type = "drag";
  232. ui_min = 0.0;
  233. ui_max = 6.0;
  234. ui_step = 0.5;
  235. ui_label = "Internal Resolution Y: 0.5 | Y-Dowsample";
  236. > = 0.0;
  237.  
  238. uniform float downsample_levelx <
  239. ui_type = "drag";
  240. ui_min = 0.0;
  241. ui_max = 3.0;
  242. ui_step = 0.05;
  243. ui_label = "Downsampling-X (High-Res Content, Pre-Scalers)";
  244. > = 0.0;
  245.  
  246. uniform float downsample_levely <
  247. ui_type = "drag";
  248. ui_min = 0.0;
  249. ui_max = 3.0;
  250. ui_step = 0.05;
  251. ui_label = "Downsampling-Y (High-Res Content, Pre-Scalers)";
  252. > = 0.0;
  253.  
  254. uniform float m_glow <
  255. ui_type = "drag";
  256. ui_min = 0.0;
  257. ui_max = 1.0;
  258. ui_step = 1.0;
  259. ui_label = "Ordinary Glow | Magic Glow";
  260. > = 0.0;
  261.  
  262. uniform float m_glow_cutoff <
  263. ui_type = "drag";
  264. ui_min = 0.0;
  265. ui_max = 0.4;
  266. ui_step = 0.01;
  267. ui_label = "Magic Glow Cutoff";
  268. > = 0.12;
  269.  
  270. uniform float m_glow_low <
  271. ui_type = "drag";
  272. ui_min = 0.0;
  273. ui_max = 7.0;
  274. ui_step = 0.05;
  275. ui_label = "Magic Glow Low Strength";
  276. > = 0.35;
  277.  
  278. uniform float m_glow_high <
  279. ui_type = "drag";
  280. ui_min = 0.0;
  281. ui_max = 7.0;
  282. ui_step = 0.05;
  283. ui_label = "Magic Glow High Strength";
  284. > = 5.0;
  285.  
  286. uniform float m_glow_dist <
  287. ui_type = "drag";
  288. ui_min = 0.2;
  289. ui_max = 4.0;
  290. ui_step = 0.05;
  291. ui_label = "Magic Glow Distribution";
  292. > = 1.0;
  293.  
  294. uniform float m_glow_mask <
  295. ui_type = "drag";
  296. ui_min = 0.0;
  297. ui_max = 2.0;
  298. ui_step = 0.025;
  299. ui_label = "Magic Glow Mask Strength";
  300. > = 1.0;
  301.  
  302. uniform float SIZEH <
  303. ui_type = "drag";
  304. ui_min = 1.0;
  305. ui_max = 50.0;
  306. ui_step = 1.0;
  307. ui_label = "Horizontal Glow Radius";
  308. > = 6.0;
  309.  
  310. uniform float SIGMA_H <
  311. ui_type = "drag";
  312. ui_min = 0.2;
  313. ui_max = 15.0;
  314. ui_step = 0.1;
  315. ui_label = "Horizontal Glow Sigma";
  316. > = 1.2;
  317.  
  318. uniform float SIZEV <
  319. ui_type = "drag";
  320. ui_min = 1.0;
  321. ui_max = 50.0;
  322. ui_step = 1.0;
  323. ui_label = "Vertical Glow Radius";
  324. > = 6.0;
  325.  
  326. uniform float SIGMA_V <
  327. ui_type = "drag";
  328. ui_min = 0.2;
  329. ui_max = 15.0;
  330. ui_step = 0.1;
  331. ui_label = "Vertical Glow Sigma";
  332. > = 1.2;
  333.  
  334. uniform float SIZEX <
  335. ui_type = "drag";
  336. ui_min = 1.0;
  337. ui_max = 50.0;
  338. ui_step = 1.0;
  339. ui_label = "Horizontal Bloom/Halation/(Glow) Radius";
  340. > = 3.0;
  341.  
  342. uniform float SIGMA_X <
  343. ui_type = "drag";
  344. ui_min = 0.25;
  345. ui_max = 15.0;
  346. ui_step = 0.05;
  347. ui_label = "Horizontal Bloom/Halation/(Glow) Sigma";
  348. > = 0.75;
  349.  
  350. uniform float BLOOMCUT_X <
  351. ui_type = "drag";
  352. ui_min = 0.0;
  353. ui_max = 0.5;
  354. ui_step = 0.01;
  355. ui_label = "Horizontal Bloom/Halation/(Glow) Substract";
  356. > = 0.0;
  357.  
  358. uniform float SIZEY <
  359. ui_type = "drag";
  360. ui_min = 1.0;
  361. ui_max = 50.0;
  362. ui_step = 1.0;
  363. ui_label = "Vertical Bloom/Halation/(Glow) Radius";
  364. > = 3.0;
  365.  
  366. uniform float SIGMA_Y <
  367. ui_type = "drag";
  368. ui_min = 0.25;
  369. ui_max = 15.0;
  370. ui_step = 0.05;
  371. ui_label = "Vertical Bloom/Halation/(Glow) Sigma";
  372. > = 0.60;
  373.  
  374. uniform float BLOOMCUT_Y <
  375. ui_type = "drag";
  376. ui_min = 0.0;
  377. ui_max = 0.5;
  378. ui_step = 0.01;
  379. ui_label = "Vertical Bloom/Halation/(Glow) Substract";
  380. > = 0.0;
  381.  
  382. uniform float glow <
  383. ui_type = "drag";
  384. ui_min = -2.0;
  385. ui_max = 2.0;
  386. ui_step = 0.01;
  387. ui_label = "(Magic) Glow Strength";
  388. > = 0.08;
  389.  
  390. uniform float blm_1 <
  391. ui_type = "drag";
  392. ui_min = -2.0;
  393. ui_max = 2.0;
  394. ui_step = 0.05;
  395. ui_label = "Bloom Strength";
  396. > = 0.0;
  397.  
  398. uniform float mask_bloom <
  399. ui_type = "drag";
  400. ui_min = 0.0;
  401. ui_max = 2.0;
  402. ui_step = 0.05;
  403. ui_label = "Mask Bloom";
  404. > = 0.0;
  405.  
  406. uniform float bloom_dist <
  407. ui_type = "drag";
  408. ui_min = 0.0;
  409. ui_max = 3.0;
  410. ui_step = 0.05;
  411. ui_label = "Bloom Distribution";
  412. > = 0.0;
  413.  
  414. uniform float halation <
  415. ui_type = "drag";
  416. ui_min = -2.0;
  417. ui_max = 2.0;
  418. ui_step = 0.025;
  419. ui_label = "Halation Strength";
  420. > = 0.0;
  421.  
  422. uniform float gamma_c <
  423. ui_type = "drag";
  424. ui_min = 0.5;
  425. ui_max = 2.0;
  426. ui_step = 0.025;
  427. ui_label = "Gamma Correct";
  428. > = 1.0;
  429.  
  430. uniform float brightboost1 <
  431. ui_type = "drag";
  432. ui_min = 0.25;
  433. ui_max = 10.0;
  434. ui_step = 0.05;
  435. ui_label = "Bright Boost Dark Pixels";
  436. > = 1.4;
  437.  
  438. uniform float brightboost2 <
  439. ui_type = "drag";
  440. ui_min = 0.25;
  441. ui_max = 3.0;
  442. ui_step = 0.025;
  443. ui_label = "Bright Boost Bright Pixels";
  444. > = 1.1;
  445.  
  446. uniform float gsl <
  447. ui_type = "drag";
  448. ui_min = -1.0;
  449. ui_max = 2.0;
  450. ui_step = 1.0;
  451. ui_label = "Scanline Type";
  452. > = 0.0;
  453.  
  454. uniform float scanline1 <
  455. ui_type = "drag";
  456. ui_min = -20.0;
  457. ui_max = 40.0;
  458. ui_step = 0.5;
  459. ui_label = "Scanline Beam Shape Center";
  460. > = 6.0;
  461.  
  462. uniform float scanline2 <
  463. ui_type = "drag";
  464. ui_min = 0.0;
  465. ui_max = 70.0;
  466. ui_step = 1.0;
  467. ui_label = "Scanline Beam Shape Edges";
  468. > = 8.0;
  469.  
  470. uniform float beam_min <
  471. ui_type = "drag";
  472. ui_min = 0.25;
  473. ui_max = 10.0;
  474. ui_step = 0.05;
  475. ui_label = "Scanline Shape Dark Pixels";
  476. > = 1.3;
  477.  
  478. uniform float beam_max <
  479. ui_type = "drag";
  480. ui_min = 0.2;
  481. ui_max = 3.5;
  482. ui_step = 0.01;
  483. ui_label = "Scanline Shape Bright Pixels";
  484. > = 1.0;
  485.  
  486. uniform float beam_size <
  487. ui_type = "drag";
  488. ui_min = 0.0;
  489. ui_max = 1.0;
  490. ui_step = 0.05;
  491. ui_label = "Increased Bright Scanline Beam";
  492. > = 0.6;
  493.  
  494. uniform float scans <
  495. ui_type = "drag";
  496. ui_min = -5.0;
  497. ui_max = 5.0;
  498. ui_step = 0.1;
  499. ui_label = "Scanline Saturation / Mask Falloff";
  500. > = 0.5;
  501.  
  502. uniform float scan_falloff <
  503. ui_type = "drag";
  504. ui_min = 0.15;
  505. ui_max = 2.0;
  506. ui_step = 0.05;
  507. ui_label = "Scanline Falloff";
  508. > = 1.0;
  509.  
  510. uniform float spike <
  511. ui_type = "drag";
  512. ui_min = 0.0;
  513. ui_max = 2.0;
  514. ui_step = 0.1;
  515. ui_label = "Scanline Spike Removal";
  516. > = 1.0;
  517.  
  518. uniform float rolling_scan <
  519. ui_type = "drag";
  520. ui_min = -1.0;
  521. ui_max = 1.0;
  522. ui_step = 0.01;
  523. ui_label = "Rolling Scanline";
  524. > = 0.0;
  525.  
  526. uniform float scangamma <
  527. ui_type = "drag";
  528. ui_min = 0.5;
  529. ui_max = 5.0;
  530. ui_step = 0.05;
  531. ui_label = "Scanline Gamma";
  532. > = 2.4;
  533.  
  534. uniform float no_scanlines <
  535. ui_type = "drag";
  536. ui_min = 0.0;
  537. ui_max = 1.5;
  538. ui_step = 0.05;
  539. ui_label = "No-Scanline Mode";
  540. > = 0.0;
  541.  
  542. uniform float h_sharp <
  543. ui_type = "drag";
  544. ui_min = 0.2;
  545. ui_max = 15.0;
  546. ui_step = 0.1;
  547. ui_label = "Horizontal Sharpness";
  548. > = 5.2;
  549.  
  550. uniform float s_sharp <
  551. ui_type = "drag";
  552. ui_min = 0.0;
  553. ui_max = 2.0;
  554. ui_step = 0.1;
  555. ui_label = "Substractive Sharpness (1.0 Recommended)";
  556. > = 0.5;
  557.  
  558. uniform float ring <
  559. ui_type = "drag";
  560. ui_min = 0.0;
  561. ui_max = 3.0;
  562. ui_step = 0.05;
  563. ui_label = "Substractive Sharpness Ringing";
  564. > = 0.0;
  565.  
  566. uniform float smart_ei <
  567. ui_type = "drag";
  568. ui_min = 0.0;
  569. ui_max = 0.75;
  570. ui_step = 0.01;
  571. ui_label = "Smart Edges Effect Strength";
  572. > = 0.0;
  573.  
  574. uniform float ei_limit <
  575. ui_type = "drag";
  576. ui_min = 0.0;
  577. ui_max = 0.75;
  578. ui_step = 0.01;
  579. ui_label = "Smart Edges Effect Strength Limit";
  580. > = 0.25;
  581.  
  582. uniform float sth <
  583. ui_type = "drag";
  584. ui_min = 0.0;
  585. ui_max = 1.0;
  586. ui_step = 0.01;
  587. ui_label = "Smart Edges Smoothing Threshold";
  588. > = 0.23;
  589.  
  590. uniform float TATE <
  591. ui_type = "drag";
  592. ui_min = 0.0;
  593. ui_max = 1.0;
  594. ui_step = 1.0;
  595. ui_label = "TATE Mode";
  596. > = 0.0;
  597.  
  598. uniform float IOS <
  599. ui_type = "drag";
  600. ui_min = 0.0;
  601. ui_max = 4.0;
  602. ui_step = 1.0;
  603. ui_label = "Integer Scaling: Odd:Y | Even:X+Y";
  604. > = 0.0;
  605.  
  606. uniform float OS <
  607. ui_type = "drag";
  608. ui_min = 0.0;
  609. ui_max = 2.0;
  610. ui_step = 1.0;
  611. ui_label = "Raster Bloom Overscan Mode";
  612. > = 1.0;
  613.  
  614. uniform float blm_2 <
  615. ui_type = "drag";
  616. ui_min = 0.0;
  617. ui_max = 20.0;
  618. ui_step = 1.0;
  619. ui_label = "Raster Bloom %";
  620. > = 0.0;
  621.  
  622. uniform float csize <
  623. ui_type = "drag";
  624. ui_min = 0.0;
  625. ui_max = 0.25;
  626. ui_step = 0.01;
  627. ui_label = "Corner Size";
  628. > = 0.0;
  629.  
  630. uniform float bsize1 <
  631. ui_type = "drag";
  632. ui_min = 0.0;
  633. ui_max = 3.0;
  634. ui_step = 0.01;
  635. ui_label = "Border Size";
  636. > = 0.01;
  637.  
  638. uniform float sborder <
  639. ui_type = "drag";
  640. ui_min = 0.25;
  641. ui_max = 2.0;
  642. ui_step = 0.05;
  643. ui_label = "Border Intensity";
  644. > = 0.75;
  645.  
  646. uniform float barspeed <
  647. ui_type = "drag";
  648. ui_min = 5.0;
  649. ui_max = 200.0;
  650. ui_step = 1.0;
  651. ui_label = "Hum Bar Speed";
  652. > = 50.0;
  653.  
  654. uniform float barintensity <
  655. ui_type = "drag";
  656. ui_min = -1.0;
  657. ui_max = 1.0;
  658. ui_step = 0.01;
  659. ui_label = "Hum Bar Intensity";
  660. > = 0.0;
  661.  
  662. uniform float bardir <
  663. ui_type = "drag";
  664. ui_min = 0.0;
  665. ui_max = 1.0;
  666. ui_step = 1.0;
  667. ui_label = "Hum Bar Direction";
  668. > = 0.0;
  669.  
  670. uniform float warpX <
  671. ui_type = "drag";
  672. ui_min = 0.0;
  673. ui_max = 0.25;
  674. ui_step = 0.01;
  675. ui_label = "Curvature X (Default 0.03)";
  676. > = 0.0;
  677.  
  678. uniform float warpY <
  679. ui_type = "drag";
  680. ui_min = 0.0;
  681. ui_max = 0.25;
  682. ui_step = 0.01;
  683. ui_label = "Curvature Y (Default 0.04)";
  684. > = 0.0;
  685.  
  686. uniform float c_shape <
  687. ui_type = "drag";
  688. ui_min = 0.05;
  689. ui_max = 0.6;
  690. ui_step = 0.05;
  691. ui_label = "Curvature Shape";
  692. > = 0.25;
  693.  
  694. uniform float overscanX <
  695. ui_type = "drag";
  696. ui_min = -200.0;
  697. ui_max = 200.0;
  698. ui_step = 1.0;
  699. ui_label = "Overscan X Original Pixels";
  700. > = 0.0;
  701.  
  702. uniform float overscanY <
  703. ui_type = "drag";
  704. ui_min = -200.0;
  705. ui_max = 200.0;
  706. ui_step = 1.0;
  707. ui_label = "Overscan Y Original Pixels";
  708. > = 0.0;
  709.  
  710. uniform float shadowMask <
  711. ui_type = "drag";
  712. ui_min = -1.0;
  713. ui_max = 13.0;
  714. ui_step = 1.0;
  715. ui_label = "CRT Mask: 0:CGWG | 1-4:Lottes | 5-13:Trinitron";
  716. > = 0.0;
  717.  
  718. uniform float maskstr <
  719. ui_type = "drag";
  720. ui_min = -0.5;
  721. ui_max = 1.0;
  722. ui_step = 0.025;
  723. ui_label = "Mask Strength (0, 5-12)";
  724. > = 0.3;
  725.  
  726. uniform float mcut <
  727. ui_type = "drag";
  728. ui_min = 0.0;
  729. ui_max = 2.0;
  730. ui_step = 0.05;
  731. ui_label = "Mask 5-12 Low Strength";
  732. > = 1.1;
  733.  
  734. uniform float maskboost <
  735. ui_type = "drag";
  736. ui_min = 1.0;
  737. ui_max = 3.0;
  738. ui_step = 0.05;
  739. ui_label = "CRT Mask Boost";
  740. > = 1.0;
  741.  
  742. uniform float masksize <
  743. ui_type = "drag";
  744. ui_min = 1.0;
  745. ui_max = 4.0;
  746. ui_step = 1.0;
  747. ui_label = "CRT Mask Size";
  748. > = 1.0;
  749.  
  750. uniform float mask_zoom <
  751. ui_type = "drag";
  752. ui_min = -4.0;
  753. ui_max = 4.0;
  754. ui_step = 1.0;
  755. ui_label = "CRT Mask Zoom (+ Mask Width)";
  756. > = 0.0;
  757.  
  758. uniform float mask_drk <
  759. ui_type = "drag";
  760. ui_min = 0.0;
  761. ui_max = 2.0;
  762. ui_step = 0.05;
  763. ui_label = "Lottes Mask Dark";
  764. > = 0.5;
  765.  
  766. uniform float mask_lgt <
  767. ui_type = "drag";
  768. ui_min = 0.0;
  769. ui_max = 2.0;
  770. ui_step = 0.05;
  771. ui_label = "Lottes Mask Light";
  772. > = 1.5;
  773.  
  774. uniform float mshift <
  775. ui_type = "drag";
  776. ui_min = -8.0;
  777. ui_max = 8.0;
  778. ui_step = 0.5;
  779. ui_label = "Mask Shift/Stagger";
  780. > = 0.0;
  781.  
  782. uniform float mask_layout <
  783. ui_type = "drag";
  784. ui_min = 0.0;
  785. ui_max = 1.0;
  786. ui_step = 1.0;
  787. ui_label = "Mask Layout: RGB or BGR (Check LCD Panel)";
  788. > = 0.0;
  789.  
  790. uniform float mask_gamma <
  791. ui_type = "drag";
  792. ui_min = 1.0;
  793. ui_max = 5.0;
  794. ui_step = 0.05;
  795. ui_label = "Mask Gamma";
  796. > = 2.4;
  797.  
  798. uniform float slotmask <
  799. ui_type = "drag";
  800. ui_min = 0.0;
  801. ui_max = 1.0;
  802. ui_step = 0.05;
  803. ui_label = "Slot Mask Strength Bright Pixels";
  804. > = 0.0;
  805.  
  806. uniform float slotmask1 <
  807. ui_type = "drag";
  808. ui_min = 0.0;
  809. ui_max = 1.0;
  810. ui_step = 0.05;
  811. ui_label = "Slot Mask Strength Dark Pixels";
  812. > = 0.0;
  813.  
  814. uniform float slotwidth <
  815. ui_type = "drag";
  816. ui_min = 0.0;
  817. ui_max = 16.0;
  818. ui_step = 1.0;
  819. ui_label = "Slot Mask Width (0:Auto)";
  820. > = 0.0;
  821.  
  822. uniform float double_slot <
  823. ui_type = "drag";
  824. ui_min = 1.0;
  825. ui_max = 4.0;
  826. ui_step = 1.0;
  827. ui_label = "Slot Mask Height: 2x1 or 4x1";
  828. > = 2.0;
  829.  
  830. uniform float slotms <
  831. ui_type = "drag";
  832. ui_min = 1.0;
  833. ui_max = 4.0;
  834. ui_step = 1.0;
  835. ui_label = "Slot Mask Thickness";
  836. > = 1.0;
  837.  
  838. uniform float mclip <
  839. ui_type = "drag";
  840. ui_min = 0.0;
  841. ui_max = 1.0;
  842. ui_step = 0.05;
  843. ui_label = "Keep Mask Effect With Clipping";
  844. > = 0.0;
  845.  
  846. uniform float smoothmask <
  847. ui_type = "drag";
  848. ui_min = 0.0;
  849. ui_max = 1.0;
  850. ui_step = 1.0;
  851. ui_label = "Smooth Masks In Bright Scanlines";
  852. > = 0.0;
  853.  
  854. uniform float smask_mit <
  855. ui_type = "drag";
  856. ui_min = 0.0;
  857. ui_max = 1.0;
  858. ui_step = 0.05;
  859. ui_label = "Mitigate Slot Mask Interaction";
  860. > = 0.0;
  861.  
  862. uniform float dctypex <
  863. ui_type = "drag";
  864. ui_min = 0.0;
  865. ui_max = 0.75;
  866. ui_step = 0.05;
  867. ui_label = "Deconvergence Type X: 0.0:Static | Other:Dynamic";
  868. > = 0.0;
  869.  
  870. uniform float dctypey <
  871. ui_type = "drag";
  872. ui_min = 0.0;
  873. ui_max = 0.75;
  874. ui_step = 0.05;
  875. ui_label = "Deconvergence Type Y: 0.0:Static | Other:Dynamic";
  876. > = 0.0;
  877.  
  878. uniform float deconrx <
  879. ui_type = "drag";
  880. ui_min = -15.0;
  881. ui_max = 15.0;
  882. ui_step = 0.25;
  883. ui_label = "Horizontal Deconvergence Red Range";
  884. > = 0.0;
  885.  
  886. uniform float decongx <
  887. ui_type = "drag";
  888. ui_min = -15.0;
  889. ui_max = 15.0;
  890. ui_step = 0.25;
  891. ui_label = "Horizontal Deconvergence Green Range";
  892. > = 0.0;
  893.  
  894. uniform float deconbx <
  895. ui_type = "drag";
  896. ui_min = -15.0;
  897. ui_max = 15.0;
  898. ui_step = 0.25;
  899. ui_label = "Horizontal Deconvergence Blue Range";
  900. > = 0.0;
  901.  
  902. uniform float deconry <
  903. ui_type = "drag";
  904. ui_min = -15.0;
  905. ui_max = 15.0;
  906. ui_step = 0.25;
  907. ui_label = "Vertical Deconvergence Red Range";
  908. > = 0.0;
  909.  
  910. uniform float decongy <
  911. ui_type = "drag";
  912. ui_min = -15.0;
  913. ui_max = 15.0;
  914. ui_step = 0.25;
  915. ui_label = "Vertical Deconvergence Green Range";
  916. > = 0.0;
  917.  
  918. uniform float deconby <
  919. ui_type = "drag";
  920. ui_min = -15.0;
  921. ui_max = 15.0;
  922. ui_step = 0.25;
  923. ui_label = "Vertical Deconvergence Blue Range";
  924. > = 0.0;
  925.  
  926. uniform float decons <
  927. ui_type = "drag";
  928. ui_min = 0.0;
  929. ui_max = 3.0;
  930. ui_step = 0.1;
  931. ui_label = "Deconvergence Strength";
  932. > = 1.0;
  933.  
  934. uniform float addnoised <
  935. ui_type = "drag";
  936. ui_min = -1.0;
  937. ui_max = 1.0;
  938. ui_step = 0.02;
  939. ui_label = "Add Noise";
  940. > = 0.0;
  941.  
  942. uniform float noiseresd <
  943. ui_type = "drag";
  944. ui_min = 1.0;
  945. ui_max = 10.0;
  946. ui_step = 1.0;
  947. ui_label = "Noise Resolution";
  948. > = 2.0;
  949.  
  950. uniform float noisetype <
  951. ui_type = "drag";
  952. ui_min = 0.0;
  953. ui_max = 1.0;
  954. ui_step = 1.0;
  955. ui_label = "Noise Type: Colored | Luma";
  956. > = 0.0;
  957.  
  958. uniform float post_br <
  959. ui_type = "drag";
  960. ui_min = 0.25;
  961. ui_max = 5.0;
  962. ui_step = 0.01;
  963. ui_label = "Post Brightness";
  964. > = 1.0;
  965.  
  966. #include "ReShade.fxh"
  967.  
  968. #define TexSize float2(ResolutionX,ResolutionY)
  969. #define IptSize float2(800.0000000,600.0000000)
  970. #define OptSize float4(BUFFER_SCREEN_SIZE,1.0/BUFFER_SCREEN_SIZE)
  971. #define OrgSize float4(TexSize,1.0/TexSize)
  972. #define SrcSize float4(IptSize,1.0/IptSize)
  973. #define FragCoord (texcoord*OptSize.xy)
  974. #define eps 1e-10
  975. #define COMPAT_TEXTURE(c,d) tex2D(c,d)
  976. #define inv_sqr_h 1.0/(2.0*SIGMA_H*SIGMA_H)
  977. #define inv_sqr_v 1.0/(2.0*SIGMA_V*SIGMA_V)
  978. #define inv_sqr_x 1.0/(2.0*SIGMA_X*SIGMA_X)
  979. #define inv_sqr_y 1.0/(2.0*SIGMA_Y*SIGMA_Y)
  980.  
  981. #ifndef Resolution_X
  982. #define Resolution_X 320
  983. #endif
  984.  
  985. #ifndef Resolution_Y
  986. #define Resolution_Y 240
  987. #endif
  988.  
  989. texture GUEST_T1{Width=Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
  990. sampler GUEST_S1{Texture=GUEST_T1;MinFilter=Point ;MagFilter=Point ;};
  991.  
  992. texture GUEST_T2{Width=Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
  993. sampler GUEST_S2{Texture=GUEST_T2;MinFilter=Point ;MagFilter=Point ;};
  994.  
  995. texture GUEST_T3{Width=Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
  996. sampler GUEST_S3{Texture=GUEST_T3;MinFilter=Linear;MagFilter=Linear;};
  997.  
  998. texture GUEST_T4{Width=Resolution_X;Height=Resolution_Y ;Format=RGBA16F;};
  999. sampler GUEST_S4{Texture=GUEST_T4;MinFilter=Linear;MagFilter=Linear;};
  1000.  
  1001. texture GUEST_T5{Width=800.00000000;Height=600.00000000 ;Format=RGBA16F;};
  1002. sampler GUEST_S5{Texture=GUEST_T5;MinFilter=Linear;MagFilter=Linear;};
  1003.  
  1004. texture GUEST_T6{Width=800.00000000;Height=600.00000000 ;Format=RGBA16F;};
  1005. sampler GUEST_S6{Texture=GUEST_T6;MinFilter=Linear;MagFilter=Linear;};
  1006.  
  1007. texture GUEST_T7{Width=800.00000000;Height=600.00000000 ;Format=RGBA16F;};
  1008. sampler GUEST_S7{Texture=GUEST_T7;MinFilter=Linear;MagFilter=Linear;};
  1009.  
  1010. texture GUEST_T8{Width=800.00000000;Height=600.00000000 ;Format=RGBA16F;};
  1011. sampler GUEST_S8{Texture=GUEST_T8;MinFilter=Linear;MagFilter=Linear;};
  1012.  
  1013. texture GUEST_T9{Width=BUFFER_WIDTH;Height=BUFFER_HEIGHT;Format=RGBA16F;};
  1014. sampler GUEST_S9{Texture=GUEST_T9;MinFilter=Linear;MagFilter=Linear;};
  1015.  
  1016. texture GUEST_01<source="CRT-LUT-1.png";>{Width=1024;Height=32;};
  1017. sampler GUEST_L1{Texture=GUEST_01;};
  1018.  
  1019. texture GUEST_02<source="CRT-LUT-2.png";>{Width=1024;Height=32;};
  1020. sampler GUEST_L2{Texture=GUEST_02;};
  1021.  
  1022. texture GUEST_03<source="CRT-LUT-3.png";>{Width=1024;Height=32;};
  1023. sampler GUEST_L3{Texture=GUEST_03;};
  1024.  
  1025. texture GUEST_04<source="CRT-LUT-4.png";>{Width=1024;Height=32;};
  1026. sampler GUEST_L4{Texture=GUEST_04;};
  1027.  
  1028. sampler GUEST_S0{Texture=ReShade::BackBufferTex;};
  1029.  
  1030. uniform int framecount<source="framecount";>;
  1031.  
  1032. float3 fix_lut(float3 lut,float3 ref)
  1033. {
  1034. float r=length(ref);
  1035. float l=length(lut);
  1036. float m=max(max(ref.r,ref.g),ref.b);
  1037. ref=normalize(lut+0.0000001)*lerp(r,l,pow(m,1.25));
  1038. return lerp(lut,ref,LUTBR);
  1039. }
  1040.  
  1041. float vignette(float2 pos)
  1042. {
  1043. float2 b=vigdef*float2(1.0,OrgSize.x/OrgSize.y)*0.125;
  1044. pos=clamp(pos,0.0,1.0);
  1045. pos=abs(2.0*(pos-0.5));
  1046. float2 res=lerp(0.0.xx,1.0.xx,smoothstep(1.0.xx,1.0.xx-b,sqrt(pos)));
  1047. res=pow(res,0.70.xx);
  1048. return max(lerp(1.0,sqrt(res.x*res.y),vigstr),0.0);
  1049. }
  1050.  
  1051. float contrast(float x)
  1052. {
  1053. return max(lerp(x,smoothstep(0.0,1.0,x),contr),0.0);
  1054. }
  1055.  
  1056. float dist(float3 A,float3 B)
  1057. {
  1058. float r=0.5*(A.r+B.r);
  1059. float3 d=A-B;
  1060. float3 c=float3(2.+r,4.,3.-r);
  1061. return sqrt(dot(c*d,d))/3.;
  1062. }
  1063.  
  1064. float3 plant(float3 tar,float r)
  1065. {
  1066. float t=max(max(tar.r,tar.g),tar.b)+0.00001;
  1067. return tar*r/t;
  1068. }
  1069.  
  1070. float3 fetch_pixel(float2 coord)
  1071. {
  1072. float2 dx=float2(OrgSize.z,0.0)*downsample_levelx;
  1073. float2 dy=float2(0.0,OrgSize.w)*downsample_levely;
  1074. float2 d1=dx+dy;
  1075. float2 d2=dx-dy;
  1076. float sum=15.0;
  1077. float3 result=3.0*COMPAT_TEXTURE(GUEST_S2,coord).rgb+2.0*COMPAT_TEXTURE(GUEST_S2,coord+dx).rgb+2.0*COMPAT_TEXTURE(GUEST_S2,coord-dx).rgb+
  1078. 2.0*COMPAT_TEXTURE(GUEST_S2,coord+dy).rgb+2.0*COMPAT_TEXTURE(GUEST_S2,coord-dy).rgb+COMPAT_TEXTURE(GUEST_S2,coord+d1).rgb+
  1079. COMPAT_TEXTURE(GUEST_S2,coord-d1).rgb+COMPAT_TEXTURE(GUEST_S2,coord+d2).rgb+COMPAT_TEXTURE(GUEST_S2,coord-d2).rgb;
  1080. return result/sum;
  1081. }
  1082.  
  1083. float gauss_h(float x)
  1084. {
  1085. return exp(-x*x*inv_sqr_h);
  1086. }
  1087.  
  1088. float gauss_v(float x)
  1089. {
  1090. return exp(-x*x*inv_sqr_v);
  1091. }
  1092.  
  1093. float gauss_x(float x)
  1094. {
  1095. return exp(-x*x*inv_sqr_x);
  1096. }
  1097.  
  1098. float gauss_y(float x)
  1099. {
  1100. return exp(-x*x*inv_sqr_y);
  1101. }
  1102.  
  1103. float mod(float x,float y)
  1104. {
  1105. return x-y* floor(x/y);
  1106. }
  1107.  
  1108. float st0(float x)
  1109. {
  1110. return exp2(-10.0*x*x);
  1111. }
  1112.  
  1113. float st1(float x)
  1114. {
  1115. return exp2(- 7.0*x*x);
  1116. }
  1117.  
  1118. float sw0(float x,float color,float scanline)
  1119. {
  1120. float tmp=lerp(beam_min,beam_max,color);
  1121. float ex=x*tmp;
  1122. ex=(gsl>-0.5)?ex*ex:lerp(ex*ex,ex*ex*ex,0.4);
  1123. return exp2(-scanline*ex);
  1124. }
  1125.  
  1126. float sw1(float x,float color,float scanline)
  1127. {
  1128. x=lerp(x,beam_min*x,max(x-0.4*color,0.0));
  1129. float tmp=lerp(1.2*beam_min,beam_max,color);
  1130. float ex=x*tmp;
  1131. return exp2(-scanline*ex*ex);
  1132. }
  1133.  
  1134. float sw2(float x,float color,float scanline)
  1135. {
  1136. float tmp=lerp((2.5-0.5*color)*beam_min,beam_max,color);
  1137. tmp=lerp(beam_max,tmp,pow(x,color+0.3));
  1138. float ex=x*tmp;
  1139. return exp2(-scanline*ex*ex);
  1140. }
  1141.  
  1142. float2 overscan(float2 pos,float dx,float dy)
  1143. {
  1144. pos=pos*2.0-1.0;
  1145. pos*=float2(dx,dy);
  1146. return pos*0.5+0.5;
  1147. }
  1148.  
  1149. float2 warp(float2 pos)
  1150. {
  1151. pos=pos*2.0-1.0;
  1152. 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);
  1153. return pos*0.5+0.5;
  1154. }
  1155.  
  1156. float3 gc(float3 c)
  1157. {
  1158. float mc=max(max(c.r,c.g),c.b);
  1159. float mg=pow(mc,1.0/gamma_c);
  1160. return c*mg/(mc+eps);
  1161. }
  1162.  
  1163. float3 crt_mask(float2 pos,float mx,float mb)
  1164. {
  1165. float3 mask=mask_drk;
  1166. float3 one=1.0;
  1167. if(shadowMask==-1.0)
  1168. {
  1169. mask=one;
  1170. }else
  1171. if(shadowMask== 0.0)
  1172. {
  1173. float mc=1.0-max(maskstr,0.0);
  1174. pos.x=frac(pos.x*0.5);
  1175. if(pos.x<0.49)
  1176. {
  1177. mask.r=1.0;mask.g= mc;mask.b=1.0;
  1178. }else
  1179. {
  1180. mask.r= mc;mask.g=1.0;mask.b= mc;
  1181. }
  1182. }else
  1183. if(shadowMask== 1.0)
  1184. {
  1185. float line=mask_lgt;
  1186. float odd=0.0;
  1187. if(frac(pos.x/6.0)<0.49)odd=1.0;
  1188. if(frac((pos.y+odd)/2.0)<0.49)line=mask_drk;
  1189. pos.x=floor(mod(pos.x,3.0));
  1190. if(pos.x<0.5)mask.r=mask_lgt;else
  1191. if(pos.x<1.5)mask.g=mask_lgt;else
  1192. mask.b= mask_lgt;
  1193. mask*=line;
  1194. }else
  1195. if(shadowMask== 2.0)
  1196. {
  1197. pos.x=floor(mod(pos.x,3.0));
  1198. if(pos.x<0.5)mask.r=mask_lgt;else
  1199. if(pos.x<1.5)mask.g=mask_lgt;else
  1200. mask.b= mask_lgt;
  1201. }else
  1202. if(shadowMask== 3.0)
  1203. {
  1204. pos.x+=pos.y*3.0;
  1205. pos.x=frac(pos.x/6.0);
  1206. if(pos.x<0.3)mask.r=mask_lgt;else
  1207. if(pos.x<0.6)mask.g=mask_lgt;else
  1208. mask.b= mask_lgt;
  1209. }else
  1210. if(shadowMask== 4.0)
  1211. {
  1212. pos.xy=floor(pos.xy*float2(1.0,0.5));
  1213. pos.x+=pos.y*3.0;
  1214. pos.x=frac(pos.x/6.0);
  1215. if(pos.x<0.3)mask.r=mask_lgt;else
  1216. if(pos.x<0.6)mask.g=mask_lgt;else
  1217. mask.b= mask_lgt;
  1218. }else
  1219. if(shadowMask== 5.0)
  1220. {
  1221. mask=0.0;
  1222. pos.x=frac(pos.x/2.0);
  1223. if(pos.x<0.49)
  1224. {
  1225. mask.r=1.0;
  1226. mask.b=1.0;
  1227. }else
  1228. mask.g=1.0;
  1229. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1230. }else
  1231. if(shadowMask== 6.0)
  1232. {
  1233. mask=0.0;
  1234. pos.x=floor(mod(pos.x,3.0));
  1235. if(pos.x<0.5)mask.r=1.0;else
  1236. if(pos.x<1.5)mask.g=1.0;else
  1237. mask.b=1.0;
  1238. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1239. }else
  1240. if(shadowMask== 7.0)
  1241. {
  1242. mask=0.0;
  1243. pos.x=frac(pos.x/2.0);
  1244. if(pos.x<0.49)
  1245. {
  1246. mask=0.0.xxx;
  1247. }else
  1248. mask=1.0.xxx;
  1249. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1250. }else
  1251. if(shadowMask== 8.0)
  1252. {
  1253. mask=0.0;
  1254. pos.x=frac(pos.x/3.0);
  1255. if(pos.x<0.3)mask=0.0.xxx;else
  1256. if(pos.x<0.6)mask=1.0.xxx;else
  1257. mask=1.0.xxx;
  1258. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1259. }
  1260. else
  1261. if(shadowMask== 9.0)
  1262. {
  1263. mask=0.0;
  1264. pos.x=frac(pos.x/3.0);
  1265. if(pos.x<0.3)mask =0.0.xxx;else
  1266. if(pos.x<0.6)mask.rb=1.0.xx ;else
  1267. mask.g=1.0;
  1268. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1269. }else
  1270. if(shadowMask==10.0)
  1271. {
  1272. mask=0.0;
  1273. pos.x=frac(pos.x*0.25);
  1274. if(pos.x<0.2)mask =0.0.xxx;else
  1275. if(pos.x<0.4)mask.r=1.0 ;else
  1276. if(pos.x<0.7)mask.g=1.0 ;else
  1277. mask.b=1.0;
  1278. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1279. }else
  1280. if(shadowMask==11.0)
  1281. {
  1282. mask=0.0;
  1283. pos.x=frac(pos.x*0.25);
  1284. if(pos.x<0.2)mask.r =1.0 ;else
  1285. if(pos.x<0.4)mask.rg=1.0.xx;else
  1286. if(pos.x<0.7)mask.gb=1.0.xx;else
  1287. mask.b=1.0;mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1288. }else
  1289. if(shadowMask==12.0)
  1290. {
  1291. mask=0.0;
  1292. pos.x=floor(mod(pos.x,7.0));
  1293. if(pos.x<0.5)mask =0.0.xxx;else
  1294. if(pos.x<2.5)mask.r=1.0 ;else
  1295. if(pos.x<4.5)mask.g=1.0 ;else
  1296. mask.b=1.0;
  1297. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1298. }
  1299. else
  1300. {
  1301. mask=0.0;
  1302. pos.x=floor(mod(pos.x,6.0));
  1303. if(pos.x<0.5)mask =0.0.xxx;else
  1304. if(pos.x<1.5)mask.r =1.0 ;else
  1305. if(pos.x<2.5)mask.rg =1.0.xx ;else
  1306. if(pos.x<3.5)mask.rgb=1.0.xxx;else
  1307. if(pos.x<4.5)mask.gb =1.0.xx ;else
  1308. mask.b=1.0;
  1309. mask=clamp(lerp(lerp(one,mask,mcut),lerp(one,mask,maskstr),mx),0.0,1.0);
  1310. }
  1311. if(mask_layout>0.5)mask=mask.rbg;
  1312. float maskmin=min(min(mask.r,mask.g),mask.b);
  1313. return (mask-maskmin)*(1.0+(maskboost-1.0)*mb)+maskmin;
  1314. }
  1315.  
  1316. float slt_mask(float2 pos,float m,float swidth)
  1317. {
  1318. if ((slotmask+slotmask1)==0.0)return 1.0;else
  1319. {
  1320. pos.y=floor(pos.y/slotms);
  1321. float mlen=swidth*2.0;
  1322. float px=floor( mod(pos.x,0.99999*mlen));
  1323. float py=floor(frac(pos.y/(2.0*double_slot))*2.0*double_slot);
  1324. float slot_dark=lerp(1.0-slotmask1,1.0-slotmask,m);
  1325. float slot=1.0;
  1326. if(py==0.0&&px<swidth)slot=slot_dark;else
  1327. if(py==double_slot&&px>=swidth)slot=slot_dark;
  1328. return slot;
  1329. }
  1330. }
  1331.  
  1332. float humbars(float pos)
  1333. {
  1334. if (barintensity==0.0)return 1.0;else
  1335. {
  1336. pos=(barintensity>=0.0)?pos:(1.0-pos);
  1337. pos=frac(pos+ mod(float(framecount),barspeed)/(barspeed-1.0));
  1338. pos=(barintensity< 0.0)?pos:(1.0-pos);
  1339. return (1.0-barintensity)+barintensity*pos;
  1340. }
  1341. }
  1342.  
  1343. float corner(float2 pos)
  1344. {
  1345. float2 b=bsize1* float2(1.0,OptSize.x/OptSize.y)*0.05;
  1346. pos=clamp(pos,0.0,1.0);
  1347. pos=abs(2.0*(pos-0.5));
  1348. float csize1=lerp(400.0,7.0,pow(4.0*csize,0.10));
  1349. float crn=dot(pow(pos,csize1.xx),float2(1.0,OptSize.y/OptSize.x));
  1350. crn=(csize==0.0)?max(pos.x,pos.y):pow(crn,1.0/csize1);
  1351. pos=max(pos,crn);
  1352. float2 res=(bsize1==0.0)?1.0.xx:lerp(0.0.xx,1.0.xx,smoothstep(1.0.xx,1.0.xx-b,sqrt(pos)));
  1353. res=pow(res, sborder.xx);
  1354. return sqrt(res.x*res.y);
  1355. }
  1356.  
  1357. float3 declip(float3 c,float b)
  1358. {
  1359. float m=max(max(c.r,c.g),c.b);
  1360. if(m>b)c=c*b/m;
  1361. return c;
  1362. }
  1363.  
  1364. float igc(float mc)
  1365. {
  1366. return pow(mc,gamma_c);
  1367. }
  1368.  
  1369. float3 noise(float3 v)
  1370. {
  1371. if(addnoised<0.0) {v.z=-addnoised;}else{v.z= mod(v.z,6001.0)/1753.0;}
  1372. v =frac(v)+frac(v*1e4)+frac(v*1e-4);
  1373. v+=float3(0.12345,0.6789,0.314159);
  1374. v =frac(v*dot(v,v)*123.456);
  1375. v =frac(v*dot(v,v)*123.456);
  1376. v =frac(v*dot(v,v)*123.456);
  1377. v =frac(v*dot(v,v)*123.456);
  1378. return v;
  1379. }
  1380.  
  1381. void bring_pixel(inout float3 c,inout float3 b,float2 coord,float2 boord)
  1382. {
  1383. float stepx=OptSize.z;
  1384. float stepy=OptSize.w;
  1385. float2 dx=float2(stepx,0.0);
  1386. float2 dy=float2(0.0,stepy);
  1387. float posx= 2.0*coord.x-1.0;
  1388. float posy= 2.0*coord.y-1.0;
  1389. if(dctypex>0.025)
  1390. {
  1391. posx= sign(posx)*pow(abs(posx),1.05-dctypex);
  1392. dx=posx*dx;
  1393. }
  1394. if(dctypey>0.025)
  1395. {
  1396. posy= sign(posy)*pow(abs(posy),1.05-dctypey);
  1397. dy=posy*dy;
  1398. }
  1399. float2 rc=deconrx*dx+deconry*dy;
  1400. float2 gc=decongx*dx+decongy*dy;
  1401. float2 bc=deconbx*dx+deconby*dy;
  1402. float r1=COMPAT_TEXTURE(GUEST_S9,coord+rc).r;
  1403. float g1=COMPAT_TEXTURE(GUEST_S9,coord+gc).g;
  1404. float b1=COMPAT_TEXTURE(GUEST_S9,coord+bc).b;
  1405. float ds=decons;
  1406. float3 d;
  1407. d=float3(r1,g1,b1);
  1408. c=clamp(lerp(c,d,ds),0.0,1.0);
  1409. r1=COMPAT_TEXTURE(GUEST_S8,boord+rc).r;
  1410. g1=COMPAT_TEXTURE(GUEST_S8,boord+gc).g;
  1411. b1=COMPAT_TEXTURE(GUEST_S8,boord+bc).b;
  1412. d=float3(r1,g1,b1);
  1413. b=clamp(lerp(b,d,ds),0.0,1.0);
  1414. }
  1415.  
  1416. float4 AfterglowPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1417. {
  1418. float2 dx=float2(OrgSize.z,0.0);
  1419. float2 dy=float2(0.0,OrgSize.w);
  1420. float w=1.0;
  1421. float3 color0=COMPAT_TEXTURE(GUEST_S0,texcoord.xy ).rgb;
  1422. float3 color1=COMPAT_TEXTURE(GUEST_S0,texcoord.xy-dx).rgb;
  1423. float3 color2=COMPAT_TEXTURE(GUEST_S0,texcoord.xy+dx).rgb;
  1424. float3 color3=COMPAT_TEXTURE(GUEST_S0,texcoord.xy-dy).rgb;
  1425. float3 color4=COMPAT_TEXTURE(GUEST_S0,texcoord.xy+dy).rgb;
  1426. float3 clr=(2.5*color0+color1+color2+color3+color4)/6.5;
  1427. float3 a=COMPAT_TEXTURE(GUEST_S1,texcoord.xy).rgb;
  1428. if((color0.r+color0.g+color0.b<5.0/255.0)){w=0.0;}
  1429. float3 result=lerp(max(lerp(clr,a,0.49+float3(PR,PG,PB))-2.0/255.0,0.0),clr,w);
  1430. return float4(result,w);
  1431. }
  1432.  
  1433. float4 PreShaderPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1434. {
  1435. const float3x3 File0=float3x3(0.412391, 0.212639,0.019331, 0.357584,0.715169, 0.119195, 0.180481,0.072192,0.950532);
  1436. const float3x3 File1=float3x3(0.430554, 0.222004,0.020182, 0.341550,0.706655, 0.129553, 0.178352,0.071341,0.939322);
  1437. const float3x3 File2=float3x3(0.396686, 0.210299,0.006131, 0.372504,0.713766, 0.115356, 0.181266,0.075936,0.967571);
  1438. const float3x3 File3=float3x3(0.393521, 0.212376,0.018739, 0.365258,0.701060, 0.111934, 0.191677,0.086564,0.958385);
  1439. const float3x3 File4=float3x3(0.392258, 0.209410,0.016061, 0.351135,0.725680, 0.093636, 0.166603,0.064910,0.850324);
  1440. const float3x3 File5=float3x3(0.377923, 0.195679,0.010514, 0.317366,0.722319, 0.097826, 0.207738,0.082002,1.076960);
  1441. const float3x3 ToRGB=float3x3(3.240970,-0.969244,0.055630,-1.537383,1.875968,-0.203977,-0.498611,0.041555,1.056972);
  1442. const float3x3 ToMDN=float3x3(2.791723,-0.894766,0.041678,-1.173165,1.815586,-0.130886,-0.440973,0.032000,1.002034);
  1443. const float3x3 ToDCI=float3x3(2.493497,-0.829489,0.035846,-0.931384,1.762664,-0.076172,-0.402711,0.023625,0.956885);
  1444. const float3x3 ToADB=float3x3(2.041588,-0.969244,0.013444,-0.565007,1.875968,-0.118360,-0.344731,0.041555,1.015175);
  1445. const float3x3 ToREC=float3x3(1.716651,-0.666684,0.017640,-0.355671,1.616481,-0.042771,-0.253366,0.015769,0.942103);
  1446. const float3x3 D65_to_D55=float3x3(0.4850339153,0.2500956126,0.0227359648,0.3488957224,0.6977914447,0.1162985741,0.1302823568,0.0521129427,0.6861537456);
  1447. const float3x3 D65_to_D93=float3x3(0.3412754080,0.1759701322,0.0159972847,0.3646170520,0.7292341040,0.1215390173,0.2369894093,0.0947957637,1.2481442225);
  1448. float4 imgColor=COMPAT_TEXTURE(GUEST_S0,texcoord.xy);
  1449. float4 aftrglow=COMPAT_TEXTURE(GUEST_S1,texcoord.xy);
  1450. float w=1.0-aftrglow.w;
  1451. float l=length(aftrglow.rgb);
  1452. aftrglow.rgb=AS*w*normalize(pow(aftrglow.rgb+0.01,sat))*l;
  1453. float bp=w*BP/255.0;
  1454. if(sega_fix>0.5)imgColor.rgb=imgColor.rgb*(255.0/239.0);
  1455. imgColor.rgb=min(imgColor.rgb,1.0);
  1456. float3 color=imgColor.rgb;
  1457. if(int(TNTC)==0)
  1458. {
  1459. color.rgb=imgColor.rgb;
  1460. }else
  1461. {
  1462. float lutlow=LUTLOW/255.0;float invLS=1.0/32.0;
  1463. float3 lut_ref=imgColor.rgb+lutlow*(1.0-pow(imgColor.rgb,0.333.xxx));
  1464. float lutb=lut_ref.b*(1.0-0.5*invLS);
  1465. lut_ref.rg=lut_ref.rg*(1.0-invLS)+0.5*invLS;
  1466. float tile1=ceil(lutb*(32.0-1.0));
  1467. float tile0=max(tile1-1.0,0.0);
  1468. float f=frac(lutb*(32.0-1.0));if(f==0.0)f=1.0;
  1469. float2 coord0=float2(tile0+lut_ref.r,lut_ref.g)*float2(invLS,1.0);
  1470. float2 coord1=float2(tile1+lut_ref.r,lut_ref.g)*float2(invLS,1.0);
  1471. float4 color1,color2,res;
  1472. if(int(TNTC)==1)
  1473. {
  1474. color1=COMPAT_TEXTURE(GUEST_L1,coord0);
  1475. color2=COMPAT_TEXTURE(GUEST_L1,coord1);
  1476. res=lerp(color1,color2,f);
  1477. }else
  1478. if(int(TNTC)==2)
  1479. {
  1480. color1=COMPAT_TEXTURE(GUEST_L2,coord0);
  1481. color2=COMPAT_TEXTURE(GUEST_L2,coord1);
  1482. res=lerp(color1,color2,f);
  1483. }else
  1484. if(int(TNTC)==3)
  1485. {
  1486. color1=COMPAT_TEXTURE(GUEST_L3,coord0);
  1487. color2=COMPAT_TEXTURE(GUEST_L3,coord1);
  1488. res=lerp(color1,color2,f);
  1489. }else
  1490. if(int(TNTC)==4)
  1491. {
  1492. color1=COMPAT_TEXTURE(GUEST_L4,coord0);
  1493. color2=COMPAT_TEXTURE(GUEST_L4,coord1);
  1494. res=lerp(color1,color2,f);
  1495. }
  1496. res.rgb=fix_lut(res.rgb,imgColor.rgb);
  1497. color=lerp(imgColor.rgb,res.rgb,min(TNTC,1.0));
  1498. }
  1499. float3 c=clamp(color,0.0,1.0);
  1500. float3x3 m_o;
  1501. float p;
  1502. if(CS==0.0){p=2.2;m_o=ToRGB;}else
  1503. if(CS==1.0){p=2.2;m_o=ToMDN;}else
  1504. if(CS==2.0){p=2.6;m_o=ToDCI;}else
  1505. if(CS==3.0){p=2.2;m_o=ToADB;}else
  1506. if(CS==4.0){p=2.4;m_o=ToREC;}
  1507. color=pow(c,p);
  1508. float3x3 m_i;
  1509. if(CP==0.0){m_i=File0;}else
  1510. if(CP==1.0){m_i=File1;}else
  1511. if(CP==2.0){m_i=File2;}else
  1512. if(CP==3.0){m_i=File3;}else
  1513. if(CP==4.0){m_i=File4;}else
  1514. if(CP==5.0){m_i=File5;}
  1515. color=mul(color,m_i);
  1516. color=mul(color,m_o);
  1517. color=clamp(color,0.0,1.0);
  1518. color=pow(color,1.0/p);
  1519. if(CP==-1.0)color=c;
  1520. float3 scolor1=plant(pow(color,wp_saturation),max(max(color.r,color.g),color.b));
  1521. float luma=dot(color,float3(0.299,0.587,0.114));
  1522. float3 scolor2=lerp(luma,color,wp_saturation);
  1523. color=(wp_saturation>1.0)?scolor1:scolor2;
  1524. color=plant(color,contrast(max(max(color.r,color.g),color.b)));
  1525. p=2.2;
  1526. color=clamp(color,0.0,1.0);
  1527. color=pow(color,p);
  1528. float3 warmer=mul(color,D65_to_D55);
  1529. warmer=mul(warmer,ToRGB);
  1530. float3 cooler=mul(color,D65_to_D93);
  1531. cooler=mul(cooler,ToRGB);
  1532. float m=abs(WP)/100.0;
  1533. float3 comp=(WP<0.0)?cooler:warmer;
  1534. color=lerp(color,comp,m);
  1535. color=pow(max(color,0.0),1.0/p);
  1536. if(BP>-0.5)color=color+aftrglow.rgb+bp;else
  1537. {
  1538. color=max(color+BP/255.0,0.0)/(1.0+BP/255.0*step(-BP/255.0,max(max(color.r,color.g),color.b)))+aftrglow.rgb;
  1539. }
  1540. color=min(color*pre_bb,1.0);
  1541. return float4(color,vignette(texcoord.xy));
  1542. }
  1543.  
  1544. float4 LuminancePS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1545. {
  1546. float m=max(log2(OrgSize.x),log2(OrgSize.y));
  1547. m=floor(max(m,1.0))-1.0;
  1548. float2 dx=float2(1.0/OrgSize.x,0.0);
  1549. float2 dy=float2(0.0,1.0/OrgSize.y);
  1550. float2 x2=2.0*dx;
  1551. float2 y2=2.0*dy;
  1552. float ltotal=0.0;
  1553. ltotal+=length( tex2Dlod(GUEST_S2,float4(float2(0.3,0.3),m,0.0)).rgb);
  1554. ltotal+=length( tex2Dlod(GUEST_S2,float4(float2(0.3,0.7),m,0.0)).rgb);
  1555. ltotal+=length( tex2Dlod(GUEST_S2,float4(float2(0.7,0.3),m,0.0)).rgb);
  1556. ltotal+=length( tex2Dlod(GUEST_S2,float4(float2(0.7,0.7),m,0.0)).rgb);
  1557. ltotal*=0.25;
  1558. ltotal=pow(0.577350269*ltotal,0.7);
  1559. float lhistory=tex2D(GUEST_S3,0.5).a;
  1560. ltotal=lerp(ltotal,lhistory,lsmooth);
  1561. float3 l1=COMPAT_TEXTURE(GUEST_S2,texcoord.xy ).rgb;
  1562. float3 r1=COMPAT_TEXTURE(GUEST_S2,texcoord.xy+dx).rgb;
  1563. float3 l2=COMPAT_TEXTURE(GUEST_S2,texcoord.xy-dx).rgb;
  1564. float3 r2=COMPAT_TEXTURE(GUEST_S2,texcoord.xy+x2).rgb;
  1565. float c1=dist(l2,l1);
  1566. float c2=dist(l1,r1);
  1567. float c3=dist(r2,r1);
  1568. return float4(c1,c2,c3,ltotal);
  1569. }
  1570.  
  1571. float4 LinearizePS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1572. {
  1573. float3 c1=tex2Dlod(GUEST_S2,float4(texcoord,0.0,0.0)).rgb;
  1574. float3 c2=tex2Dlod(GUEST_S2,float4(texcoord+float2(0.0,OrgSize.w),0.0,0.0)).rgb;
  1575. if((downsample_levelx+downsample_levely)>0.025)
  1576. {
  1577. c1=fetch_pixel(texcoord);
  1578. c2=fetch_pixel(texcoord+float2(0.0,OrgSize.w));
  1579. }
  1580. float3 c=c1;
  1581. float intera=1.0;
  1582. float gamma_in=clamp(gamma_i,1.0,5.0);
  1583. float m1=max(max(c1.r,c1.g),c1.b);
  1584. float m2=max(max(c2.r,c2.g),c2.b);
  1585. float3 df=abs(c1-c2);
  1586. float d=max(max(df.r,df.g),df.b);
  1587. if(interm==2.0)d=lerp(0.1*d,10.0*d,step(m1/(m2+0.0001),m2/(m1+0.0001)));
  1588. float r=m1;
  1589. float yres_div=1.0;if(intres>1.25)yres_div=intres;
  1590. if(inter<=OrgSize.y/yres_div&&interm>0.5&&intres!=1.0&&intres!=0.5)
  1591. {
  1592. intera=0.25;
  1593. float liine_no=clamp(floor( mod(OrgSize.y*texcoord.y,2.0)),0.0,1.0);
  1594. float frame_no=clamp(floor( mod(float(framecount),2.0)),0.0,1.0);
  1595. float ii=abs(liine_no-frame_no);
  1596. if(interm< 3.5)
  1597. {
  1598. c2=plant(lerp(c2,c2*c2,iscans),max(max(c2.r,c2.g),c2.b));
  1599. r=clamp(max(m1*ii,(1.0-iscan)*min(m1,m2)),0.0,1.0);
  1600. 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);
  1601. if(interm==3.0)c=(1.0-0.5*iscan)*lerp(c2,c1,ii);
  1602. }
  1603. 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);}
  1604. 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);}
  1605. }
  1606. c=pow(c,gamma_in);
  1607. if(texcoord.x>0.5){gamma_in=intera;}else{gamma_in=1.0/gamma_in;}
  1608. return float4(c,gamma_in);
  1609. }
  1610.  
  1611. float4 HGaussianPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1612. {
  1613. float4 GaussSize=float4(OrgSize.x,OrgSize.y,OrgSize.z,OrgSize.w);
  1614. float f=frac(GaussSize.x*texcoord.x);
  1615. f=0.5-f;
  1616. float2 tex=floor(GaussSize.xy*texcoord)*GaussSize.zw+0.5*GaussSize.zw;
  1617. float3 color=0.0;
  1618. float2 dx=float2(GaussSize.z,0.0);
  1619. float3 pixel;
  1620. float w;
  1621. float wsum=0.0;
  1622. float n=-SIZEH;
  1623. do
  1624. {
  1625. pixel=tex2Dlod(GUEST_S4,float4(tex+n*dx,0.0,0.0)).rgb;
  1626. if(m_glow>0.5)
  1627. {
  1628. pixel=max(pixel-m_glow_cutoff,0.0);
  1629. pixel=plant(pixel,max(max(max(pixel.r,pixel.g),pixel.b)-m_glow_cutoff,0.0));
  1630. }
  1631. w=gauss_h(n+f);
  1632. color=color+w*pixel;
  1633. wsum=wsum+w;
  1634. n=n+1.0;
  1635. }while(n<=SIZEH);
  1636. color=color/wsum;
  1637. return float4(color,1.0);
  1638. }
  1639.  
  1640. float4 VGaussianPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1641. {
  1642. float4 GaussSize=float4(SrcSize.x,OrgSize.y,SrcSize.z,OrgSize.w);
  1643. float f=frac(GaussSize.y*texcoord.y);
  1644. f=0.5-f;
  1645. float2 tex=floor(GaussSize.xy*texcoord)*GaussSize.zw+0.5*GaussSize.zw;
  1646. float3 color=0.0;
  1647. float2 dy=float2(0.0,GaussSize.w);
  1648. float3 pixel;
  1649. float w;
  1650. float wsum=0.0;
  1651. float n=-SIZEV;
  1652. do
  1653. {
  1654. pixel=tex2Dlod(GUEST_S5,float4(tex+n*dy,0.0,0.0)).rgb;
  1655. w=gauss_v(n+f);
  1656. color=color+w*pixel;
  1657. wsum=wsum+w;
  1658. n=n+1.0;
  1659. }while(n<=SIZEV);
  1660. color=color/wsum;
  1661. return float4(color,1.0);
  1662. }
  1663.  
  1664. float4 BloomHorzPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1665. {
  1666. float4 BloomSize=float4(OrgSize.x,OrgSize.y,OrgSize.z,OrgSize.w);
  1667. float f=frac(BloomSize.x*texcoord.x);
  1668. f=0.5-f;
  1669. float2 tex=floor(BloomSize.xy*texcoord)*BloomSize.zw+0.5*BloomSize.zw;
  1670. float4 color=0.0;
  1671. float2 dx=float2(BloomSize.z,0.0);
  1672. float4 pixel;
  1673. float w;
  1674. float wsum=0.0;
  1675. float n=-SIZEX;
  1676. do
  1677. {
  1678. pixel=tex2Dlod(GUEST_S4,float4(tex+n*dx,0.0,0.0));
  1679. w=max(gauss_x(n+f)-BLOOMCUT_X,0.0);
  1680. pixel.a =max(max(pixel.r,pixel.g),pixel.b);
  1681. pixel.a*=pixel.a*pixel.a;
  1682. color=color+w*pixel;
  1683. wsum=wsum+w;
  1684. n=n+1.0;
  1685. }while(n<=SIZEX);
  1686. color=color/wsum;
  1687. return float4(color.rgb,pow(color.a,0.333333));
  1688. }
  1689.  
  1690. float4 BloomVertPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1691. {
  1692. float4 BloomSize=float4(SrcSize.x,OrgSize.y,SrcSize.z,OrgSize.w);
  1693. float f=frac(BloomSize.y*texcoord.y);
  1694. f=0.5-f;
  1695. float2 tex=floor(BloomSize.xy*texcoord)*BloomSize.zw+0.5*BloomSize.zw;
  1696. float4 color=0.0;
  1697. float2 dy=float2(0.0,BloomSize.w);
  1698. float4 pixel;
  1699. float w;
  1700. float wsum=0.0;
  1701. float n=-SIZEY;
  1702. do
  1703. {
  1704. pixel=tex2Dlod(GUEST_S7,float4(tex+n*dy,0.0,0.0));
  1705. w=max(gauss_y(n+f)-BLOOMCUT_Y,0.0);
  1706. pixel.a*=pixel.a*pixel.a;
  1707. color=color+w*pixel;
  1708. wsum=wsum+w;
  1709. n=n+1.0;
  1710. }while(n<=SIZEY);
  1711. color=color/wsum;
  1712. return float4(color.rgb,pow(color.a,0.175000));
  1713. }
  1714.  
  1715. float4 Advanced_PS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1716. {
  1717. float2 prescalex=(tex2Dsize(GUEST_S4,0))/OrgSize.xy;
  1718. 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);
  1719. float gamma_in=1.0/COMPAT_TEXTURE(GUEST_S4,0.25).a;
  1720. float lum=COMPAT_TEXTURE(GUEST_S3,0.5).a;
  1721. float intera=COMPAT_TEXTURE(GUEST_S4,float2(0.75,0.25)).a;
  1722. bool interb=((intera<0.5)||(no_scanlines>0.025));
  1723. bool notate=(TATE<0.5);
  1724. float SourceY=lerp(AdvSize.y,AdvSize.x,TATE);
  1725. float sy=1.0;
  1726. if( intres==1.0)sy=SourceY/224.0;
  1727. if( intres>0.25&&intres!=1.0)sy=intres;
  1728. if( notate){AdvSize*=float4(1.0,1.0/sy,1.0,sy);}else{AdvSize*=float4(1.0/sy,1.0,sy,1.0);}
  1729. if(IOS> 0.0&&!interb)
  1730. {
  1731. float2 ofactor=OptSize.xy/OrgSize.xy;
  1732. float2 intfactor=(IOS<2.5)?floor(ofactor):ceil(ofactor);
  1733. float2 diff=ofactor/intfactor;
  1734. float scan=lerp(diff.y,diff.x,TATE);
  1735. texcoord=overscan(texcoord,scan,scan);
  1736. if(IOS==1.0||IOS==3.0)texcoord=lerp(float2(texcoord.x,texcoord.y),float2(texcoord.x,texcoord.y),TATE);
  1737. }
  1738. float factor=1.0+(1.0-0.5*OS)*blm_2/100.0-lum*blm_2/100.0;
  1739. texcoord=overscan(texcoord,factor,factor);
  1740. texcoord=overscan(texcoord,(OrgSize.x-overscanX)/OrgSize.x,(OrgSize.y-overscanY)/OrgSize.y);
  1741. float2 pos=warp(texcoord);
  1742. bool smarte=(smart_ei>0.01&&notate);
  1743. float2 coffset=0.5;
  1744. float2 ps=AdvSize.zw;
  1745. float2 OGL2Pos=pos*AdvSize.xy-coffset;
  1746. float2 fp=frac(OGL2Pos);
  1747. float2 dx=float2(ps.x,0.0);
  1748. float2 dy=float2(0.0,ps.y);
  1749. float2 x2=2.0*dx;
  1750. float2 y2=2.0*dy;
  1751. float2 offx=dx;
  1752. float2 off2=x2;
  1753. float2 offy=dy;
  1754. float fpx=fp.x;
  1755. if(!notate){offx=dy;off2=y2;offy=dx;fpx=fp.y;}
  1756. float f=(notate)?fp.y:fp.x;
  1757. float2 pC4=floor(OGL2Pos)*ps+0.5*ps;
  1758. if( intres==0.5&& notate&&prescalex.y<1.5)pC4.y=floor(pC4.y*OrgSize.y)*OrgSize.w+0.5*OrgSize.w;
  1759. if( intres==0.5&&!notate&&prescalex.x<1.5)pC4.x=floor(pC4.x*OrgSize.x)*OrgSize.z+0.5*OrgSize.z;
  1760. if( interb&&no_scanlines<0.025)pC4.y=pos.y;else
  1761. 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);
  1762. float zero=exp2(-h_sharp);
  1763. float idiv=clamp(lerp(AdvSize.x,AdvSize.y,TATE)/400.0,1.0,2.0);
  1764. float fdivider=max(min(lerp(prescalex.x,prescalex.y,TATE),2.0),idiv*float(interb));
  1765. float wl3=(2.0+fpx)/fdivider;
  1766. float wl2=(1.0+fpx)/fdivider;
  1767. float wl1=( fpx)/fdivider;
  1768. float wr1=(1.0-fpx)/fdivider;
  1769. float wr2=(2.0-fpx)/fdivider;
  1770. float wr3=(3.0-fpx)/fdivider;
  1771. wl3*=wl3;wl3=exp2(-h_sharp*wl3);
  1772. wl2*=wl2;wl2=exp2(-h_sharp*wl2);
  1773. wl1*=wl1;wl1=exp2(-h_sharp*wl1);
  1774. wr1*=wr1;wr1=exp2(-h_sharp*wr1);
  1775. wr2*=wr2;wr2=exp2(-h_sharp*wr2);
  1776. wr3*=wr3;wr3=exp2(-h_sharp*wr3);
  1777. float sharp1=s_sharp*zero;
  1778. float fp1=1.-fpx;
  1779. float twl3=max(wl3-sharp1, 0.0 );
  1780. float twl2=max(wl2-sharp1,lerp(-0.12,0.0,1.0-fp1*fp1));
  1781. float twl1=max(wl1-sharp1,-0.12);
  1782. float twr1=max(wr1-sharp1,-0.12);
  1783. float twr2=max(wr2-sharp1,lerp(-0.12,0.0,1.0-fpx*fpx));
  1784. float twr3=max(wr3-sharp1, 0.0 );
  1785. bool sharp=(sharp1>0.0);
  1786. float3 c1,c2;
  1787. if( smarte)
  1788. {
  1789. twl3=0.0;twr3=0.0;
  1790. c1=tex2Dlod(GUEST_S3,float4(pC4 ,0.0,0.0)).xyz;
  1791. c2=tex2Dlod(GUEST_S3,float4(pC4+offy,0.0,0.0)).xyz;
  1792. c1=max(c1-sth,0.0);
  1793. c2=max(c2-sth,0.0);
  1794. }
  1795. float3 l3,l2,l1,r1,r2,r3,color1,color2,colmin,colmax;
  1796. l3=tex2Dlod(GUEST_S4,float4(pC4-off2 ,0.0,0.0)).rgb;
  1797. l2=tex2Dlod(GUEST_S4,float4(pC4-offx ,0.0,0.0)).rgb;
  1798. l1=tex2Dlod(GUEST_S4,float4(pC4 ,0.0,0.0)).rgb;
  1799. r1=tex2Dlod(GUEST_S4,float4(pC4+offx ,0.0,0.0)).rgb;
  1800. r2=tex2Dlod(GUEST_S4,float4(pC4+off2 ,0.0,0.0)).rgb;
  1801. r3=tex2Dlod(GUEST_S4,float4(pC4+offx+off2,0.0,0.0)).rgb;
  1802. colmin=min(min(l1,r1),min(l2,r2));
  1803. colmax=max(max(l1,r1),max(l2,r2));
  1804. if( smarte)
  1805. {
  1806. float pc=min(smart_ei*c1.y,ei_limit);
  1807. float pl=min(smart_ei*max(c1.y,c1.x),ei_limit);
  1808. float pr=min(smart_ei*max(c1.y,c1.z),ei_limit);
  1809. twl1=max(wl1-pc,0.01*wl1);twr1=max(wr1-pc,0.01*wr1);
  1810. twl2=max(wl2-pl,0.01*wl2);twr2=max(wr2-pr,0.01*wr2);
  1811. }
  1812. color1=(l3*twl3+l2*twl2+l1*twl1+r1*twr1+r2*twr2+r3*twr3)/(twl3+twl2+twl1+twr1+twr2+twr3);
  1813. if(sharp)color1=clamp(lerp(clamp(color1,colmin,colmax),color1,ring),0.0,1.0);
  1814. float ts=0.025;
  1815. float3 luma=float3(0.2126,0.7152,0.0722);
  1816. float lm2=max(max(l2.r,l2.g),l2.b);
  1817. float lm1=max(max(l1.r,l1.g),l1.b);
  1818. float rm1=max(max(r1.r,r1.g),r1.b);
  1819. float rm2=max(max(r2.r,r2.g),r2.b);
  1820. float swl2=max(twl2,0.0)*(dot(l2,luma)+ts);
  1821. float swl1=max(twl1,0.0)*(dot(l1,luma)+ts);
  1822. float swr1=max(twr1,0.0)*(dot(r1,luma)+ts);
  1823. float swr2=max(twr2,0.0)*(dot(r2,luma)+ts);
  1824. float fscolor1=(lm2*swl2+lm1*swl1+rm1*swr1+rm2*swr2)/(swl2+swl1+swr1+swr2);
  1825. float3 scolor1=clamp(lerp(max(max(color1.r,color1.g),color1.b),fscolor1,spike),0.0,1.0);
  1826. if(!interb)color1=pow(color1,scangamma/gamma_in);
  1827. float3 scolor2;
  1828. if(!interb)
  1829. {
  1830. pC4+=offy;
  1831. if( intres==0.5&& notate&&prescalex.y<1.5)pC4.y=floor((pos.y+0.33*offy.y)*OrgSize.y)*OrgSize.w+0.5*OrgSize.w;
  1832. if( intres==0.5&&!notate&&prescalex.x<1.5)pC4.x=floor((pos.x+0.33*offy.x)*OrgSize.x)*OrgSize.z+0.5*OrgSize.z;
  1833. l3=tex2Dlod(GUEST_S4,float4(pC4-off2 ,0.0,0.0)).rgb;
  1834. l2=tex2Dlod(GUEST_S4,float4(pC4-offx ,0.0,0.0)).rgb;
  1835. l1=tex2Dlod(GUEST_S4,float4(pC4 ,0.0,0.0)).rgb;
  1836. r1=tex2Dlod(GUEST_S4,float4(pC4+offx ,0.0,0.0)).rgb;
  1837. r2=tex2Dlod(GUEST_S4,float4(pC4+off2 ,0.0,0.0)).rgb;
  1838. r3=tex2Dlod(GUEST_S4,float4(pC4+offx+off2,0.0,0.0)).rgb;
  1839. colmin=min(min(l1,r1),min(l2,r2));
  1840. colmax=max(max(l1,r1),max(l2,r2));
  1841. if( smarte)
  1842. {
  1843. float pc=min(smart_ei*c2.y,ei_limit);
  1844. float pl=min(smart_ei*max(c2.y,c2.x),ei_limit);
  1845. float pr=min(smart_ei*max(c2.y,c2.z),ei_limit);
  1846. twl1=max(wl1-pc,0.01*wl1);twr1=max(wr1-pc,0.01*wr1);
  1847. twl2=max(wl2-pl,0.01*wl2);twr2=max(wr2-pr,0.01*wr2);
  1848. }
  1849. color2=(l3*twl3+l2*twl2+l1*twl1+r1*twr1+r2*twr2+r3*twr3)/(twl3+twl2+twl1+twr1+twr2+twr3);
  1850. if(sharp)color2=clamp(lerp(clamp(color2,colmin,colmax),color2,ring),0.0,1.0);
  1851. lm2=max(max(l2.r,l2.g),l2.b);
  1852. lm1=max(max(l1.r,l1.g),l1.b);
  1853. rm1=max(max(r1.r,r1.g),r1.b);
  1854. rm2=max(max(r2.r,r2.g),r2.b);
  1855. swl2=max(twl2,0.0)*(dot(l2,luma)+ts);
  1856. swl1=max(twl1,0.0)*(dot(l1,luma)+ts);
  1857. swr1=max(twr1,0.0)*(dot(r1,luma)+ts);
  1858. swr2=max(twr2,0.0)*(dot(r2,luma)+ts);
  1859. float fscolor2=(lm2*swl2+lm1*swl1+rm1*swr1+rm2*swr2)/(swl2+swl1+swr1+swr2);
  1860. scolor2=clamp(lerp(max(max(color2.r,color2.g),color2.b),fscolor2,spike),0.0,1.0);
  1861. color2=pow(color2,scangamma/gamma_in);
  1862. }
  1863. float3 ctmp=color1;float w3=1.0;float3 color=color1;
  1864. float3 one=1.0;
  1865. if(!interb)
  1866. {
  1867. float shape1=lerp(scanline1,scanline2, f);
  1868. float shape2=lerp(scanline1,scanline2,1.0-f);
  1869. float wt1=st0( f);
  1870. float wt2=st0(1.0-f);
  1871. float3 color00= color1*wt1+ color2*wt2;
  1872. float3 scolor0=scolor1*wt1+scolor2*wt2;
  1873. ctmp=color00/(wt1+wt2);
  1874. float3 sctmp=scolor0/(wt1+wt2);
  1875. float wf1,wf2;
  1876. float3 cref1=lerp(sctmp,scolor1,beam_size);float creff1=pow(max(max(cref1.r,cref1.g),cref1.b),scan_falloff);
  1877. float3 cref2=lerp(sctmp,scolor2,beam_size);float creff2=pow(max(max(cref2.r,cref2.g),cref2.b),scan_falloff);
  1878. float f1= f;
  1879. float f2=1.0-f;
  1880. float scanpix=lerp(AdvSize.x/OptSize.x,AdvSize.y/OptSize.y,float(notate));
  1881. f1=frac(f1+rolling_scan*float(framecount)*scanpix);
  1882. f2=1.0-f1;
  1883. if(gsl< 0.5)
  1884. {wf1=sw0(f1,creff1,shape1);wf2=sw0(f2,creff2,shape2);}else
  1885. if(gsl==1.0)
  1886. {wf1=sw1(f1,creff1,shape1);wf2=sw1(f2,creff2,shape2);}else
  1887. {wf1=sw2(f1,creff1,shape1);wf2=sw2(f2,creff2,shape2);}
  1888. if((wf1+wf2)>1.0){float wtmp=1.0/(wf1+wf2);wf1*=wtmp;wf2*=wtmp;}
  1889. float3 w1=wf1;float3 w2=wf2;
  1890. w3=wf1+wf2;
  1891. float mc1=max(max(color1.r,color1.g),color1.b)+eps;
  1892. float mc2=max(max(color2.r,color2.g),color2.b)+eps;
  1893. cref1=color1/mc1;
  1894. cref2=color2/mc2;
  1895. float scanpow1=(scans>0.0)?1.0:pow(f1,0.375);
  1896. float scanpow2=(scans>0.0)?1.0:pow(f2,0.375);
  1897. w1=pow(w1,lerp(2.0*abs(scans).xxx+1.0,1.0.xxx,lerp(1.0.xxx,cref1,scanpow1)));
  1898. w2=pow(w2,lerp(2.0*abs(scans).xxx+1.0,1.0.xxx,lerp(1.0.xxx,cref2,scanpow2)));
  1899. color=(gc(color1)*w1+gc(color2)*w2);
  1900. if(abs(rolling_scan)>0.005)
  1901. {
  1902. wt1=st1( f);
  1903. wt2=st1(1.0-f);
  1904. color00=(color1*wt1+color2*wt2)/(wt1+wt2);
  1905. color=gc(color00)*lerp(w1+w2,w3.xxx,max(wf1,wf2));
  1906. }
  1907. color=min(color,1.0);
  1908. }
  1909. if( interb)
  1910. {
  1911. color=gc(color1);
  1912. }
  1913. float colmx=max(max(ctmp.r,ctmp.g),ctmp.b);
  1914. if(!interb)color=pow(color,gamma_in/scangamma);
  1915. return float4(color,colmx);
  1916. }
  1917.  
  1918. float4 ChromaticPS(float4 position:SV_Position,float2 texcoord:TEXCOORD):SV_Target
  1919. {
  1920. float gamma_in=1.0/COMPAT_TEXTURE(GUEST_S4,0.25).a;
  1921. float lum=COMPAT_TEXTURE(GUEST_S3,0.5).a;
  1922. float intera=COMPAT_TEXTURE(GUEST_S4,float2(0.75,0.25)).a;
  1923. bool interb=(intera<0.5||no_scanlines>0.025);
  1924. bool notate=(TATE<0.5);
  1925. if(IOS> 0.0&&!interb)
  1926. {
  1927. float2 ofactor=OptSize.xy/OrgSize.xy;
  1928. float2 intfactor=(IOS<2.5)?floor(ofactor):ceil(ofactor);
  1929. float2 diff=ofactor/intfactor;
  1930. float scan=lerp(diff.y,diff.x,TATE);
  1931. texcoord=overscan(texcoord,scan,scan);
  1932. if(IOS==1.0||IOS==3.0)texcoord=lerp(float2(texcoord.x,texcoord.y),float2(texcoord.x,texcoord.y),TATE);
  1933. }
  1934. float factor=1.0+(1.0-0.5*OS)*blm_2/100.0-lum*blm_2/100.0;
  1935. texcoord=overscan(texcoord,factor,factor);
  1936. texcoord=overscan(texcoord,(OrgSize.x-overscanX)/OrgSize.x,(OrgSize.y-overscanY)/OrgSize.y);
  1937. float2 pos0=warp(texcoord.xy);
  1938. float2 pos1=texcoord.xy;
  1939. float2 pos=warp(texcoord);
  1940. float3 color=COMPAT_TEXTURE(GUEST_S9,pos1).rgb;
  1941. float3 Bloom=COMPAT_TEXTURE(GUEST_S8,pos).rgb;
  1942. if((abs(deconrx)+abs(deconry)+abs(decongx)+abs(decongy)+abs(deconbx)+abs(deconby))>0.2)
  1943. bring_pixel(color,Bloom,pos1,pos);
  1944. float cm=igc(max(max(color.r,color.g),color.b));
  1945. float mx1=COMPAT_TEXTURE(GUEST_S9,pos1 ).a;
  1946. float colmx=max(mx1,cm);
  1947. float w3=min((cm+0.0001)/(colmx+0.0005),1.0);
  1948. float2 dx=lerp(float2(0.001,0.0),float2(0.0,0.001),TATE);
  1949. float mx0=COMPAT_TEXTURE(GUEST_S9,pos1-dx).a;
  1950. float mx2=COMPAT_TEXTURE(GUEST_S9,pos1+dx).a;
  1951. float mxg=max(max(mx0,mx1),max(mx2,cm));
  1952. float mx=pow(mxg,1.40/gamma_in);
  1953. dx=lerp(float2(OrgSize.z,0.0),float2(0.0,OrgSize.w),TATE)*0.25;
  1954. mx0=COMPAT_TEXTURE(GUEST_S9,pos1-dx).a;
  1955. mx2=COMPAT_TEXTURE(GUEST_S9,pos1+dx).a;
  1956. float mb=1.0-min(abs(mx0-mx2)/(0.5+mx1),1.0);
  1957. float3 orig1=color;
  1958. float3 one=1.0;
  1959. float3 cmask=one;
  1960. float2 maskcoord=FragCoord.yx*1.00001;
  1961. if( notate)maskcoord=maskcoord.yx;
  1962. float2 scoord=maskcoord;
  1963. float mwidths[14]={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};
  1964. float mwidth=mwidths[int(shadowMask)];
  1965. float mask_compensate=frac(mwidth);
  1966. mwidth=floor(mwidth)*masksize;
  1967. float swidth=mwidth;
  1968. bool zoomed=(abs(mask_zoom)>0.75);
  1969. float mscale=1.0;
  1970. float2 maskcoord0=maskcoord;
  1971. maskcoord.y=floor(maskcoord.y/masksize);
  1972. if(abs(mshift)>0.75)
  1973. {
  1974. float stagg_lvl=1.0;if(frac(abs(mshift))>0.25&&abs(mshift)>1.25)stagg_lvl=2.0;
  1975. float next_line=float(frac((maskcoord.y/stagg_lvl)*0.5)>0.25);
  1976. maskcoord0.x=(mshift>-0.25)?(maskcoord0.x+next_line*floor(mshift)):(maskcoord0.x+floor(maskcoord.y/stagg_lvl)*floor(abs(mshift)));
  1977. }
  1978. maskcoord=maskcoord0/masksize;if(mask_zoom>=0.0)maskcoord=floor(maskcoord);
  1979. if(!zoomed)cmask*=crt_mask(maskcoord,mx,mb);else
  1980. {
  1981. float mwidth1=max(mwidth+mask_zoom,2.0);
  1982. mscale=mwidth1/mwidth;
  1983. float mlerp=frac(maskcoord.x/mscale);
  1984. float mcoord=floor(maskcoord.x/mscale); if(shadowMask==12.0&&mask_zoom==-2.0)mcoord=ceil(maskcoord.x/mscale);
  1985. cmask*=lerp(crt_mask(float2(mcoord,maskcoord.y),mx,mb),crt_mask(float2(mcoord+1.0,maskcoord.y),mx,mb),mlerp);
  1986. }
  1987. if(slotwidth>0.5)swidth=slotwidth;float smask=1.0;
  1988. float sm_offset=0.0;bool bsm_offset=(shadowMask==0.0||shadowMask==2.0||shadowMask==5.0||shadowMask==6.0||shadowMask==8.0||shadowMask==11.0);
  1989. if( zoomed)
  1990. {
  1991. if(mask_layout<0.5&&bsm_offset)sm_offset=1.0;else
  1992. if(bsm_offset)sm_offset=-1.0;
  1993. }
  1994. swidth=round(swidth*mscale);
  1995. smask=slt_mask(scoord+float2(sm_offset,0.0),mx,swidth);
  1996. 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);
  1997. cmask*=smask;
  1998. float3 cmask1=cmask;
  1999. if(mask_bloom>0.025)
  2000. {
  2001. float maxbl=max(max(max(Bloom.r,Bloom.g),Bloom.b),mxg);
  2002. maxbl=maxbl*lerp(1.0,2.0-colmx,bloom_dist);
  2003. cmask=max(min(cmask+maxbl*mask_bloom,1.0),cmask);
  2004. }
  2005. color=pow(color,mask_gamma/gamma_in);
  2006. color=color*cmask;
  2007. color=min(color,1.0);
  2008. color=pow(color,gamma_in/mask_gamma);
  2009. cmask=min(cmask,1.0);
  2010. cmask1=min(cmask1,1.0);
  2011. 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);
  2012. float bb=lerp(brightboost1,brightboost2,mx)*dark_compensate;
  2013. color*=bb;
  2014. float3 Glow=COMPAT_TEXTURE(GUEST_S6,pos).rgb;
  2015. float3 Ref=COMPAT_TEXTURE(GUEST_S4,pos).rgb;
  2016. float maxb=COMPAT_TEXTURE(GUEST_S8,pos).a;
  2017. float vig=COMPAT_TEXTURE(GUEST_S2,clamp(pos,0.0+0.5*OrgSize.zw,1.0-0.5*OrgSize.zw)).a;
  2018. float3 Bloom1=Bloom;
  2019. if(abs(blm_1)>0.025)
  2020. {
  2021. if(blm_1<-0.01)Bloom1=plant(Bloom,maxb);
  2022. Bloom1=min(Bloom1*(orig1+color),max(0.5*(colmx+orig1-color),0.001*Bloom1));
  2023. Bloom1=0.5*(Bloom1+lerp(Bloom1,lerp(colmx*orig1,Bloom1,0.5),1.0-color));
  2024. Bloom1=Bloom1*lerp(1.0,2.0-colmx,bloom_dist);
  2025. color=pow(pow(color,mask_gamma/gamma_in)+abs(blm_1)*pow(Bloom1,mask_gamma/gamma_in),gamma_in/mask_gamma);
  2026. }
  2027. color=min(color,lerp(one,cmask1,mclip));
  2028. if(!interb)color=declip(color,lerp(1.0,w3,0.6));else
  2029. {
  2030. w3=1.0;
  2031. }
  2032. if(halation> 0.01)
  2033. {
  2034. Bloom=lerp(0.5*(Bloom+Bloom*Bloom),0.75*Bloom*Bloom,colmx);
  2035. 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)*lerp(one,cmask,0.6)*Bloom*halation;
  2036. }else
  2037. if(halation<-0.01)
  2038. {
  2039. float mbl=max(max(Bloom.r,Bloom.g),Bloom.b);
  2040. Bloom=plant(Bloom+Ref+orig1+Bloom*Bloom*Bloom,min(mbl*mbl,0.75));
  2041. color=color+2.0*lerp(1.0,w3,0.5*colmx)*lerp(one,cmask,0.5)*Bloom*(-halation);
  2042. }
  2043. float w=0.25+0.60*lerp(w3,1.0,sqrt(colmx));
  2044. if(smoothmask>0.5)
  2045. {
  2046. w3=lerp(1.0,w3,smoothstep(0.3,0.6,mx1));color=max(min(color/w3,1.0)*w3,min(color,color*(1.0-w3)));
  2047. }
  2048. if(m_glow<0.5)Glow=lerp(Glow,0.25*color,0.7*colmx);else
  2049. {
  2050. maxb=max(max(Glow.r,Glow.g),Glow.b);
  2051. orig1=plant(orig1+0.001*Ref,1.0);
  2052. Bloom=plant(Glow,1.0);
  2053. Ref=abs(orig1-Bloom);
  2054. mx0=max(max(orig1.g,orig1.g),orig1.b)-min(min(orig1.g,orig1.g),orig1.b);
  2055. mx2=max(max(Bloom.g,Bloom.g),Bloom.b)-min(min(Bloom.g,Bloom.g),Bloom.b);
  2056. Bloom=lerp(maxb*min(Bloom,orig1),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));
  2057. Glow=lerp(m_glow_low*Glow,m_glow_high*Bloom,pow(colmx,m_glow_dist/gamma_in));
  2058. }
  2059. if(glow>=0.0&&m_glow<0.5)color=color+0.5*Glow*glow;else
  2060. {
  2061. if(m_glow>0.5)cmask1=max(lerp(one,cmask1,m_glow_mask),0.0);color=color+abs(glow)*cmask1*Glow;
  2062. }
  2063. color=min(color,1.0);
  2064. color=pow(color,1.0/gamma_o);
  2065. float rc=0.6*sqrt(max(max(color.r,color.g),color.b))+0.4;
  2066. if(abs(addnoised)>0.01)
  2067. {
  2068. float3 noise0=noise(float3(floor(OptSize.xy*texcoord/noiseresd),float(framecount)));
  2069. if(noisetype<0.5)color=lerp(color,noise0,0.25*abs(addnoised)*rc);
  2070. else color=min(color*lerp(1.0,1.5*noise0.x,0.5*abs(addnoised)),1.0);
  2071. }
  2072. return float4(color*vig*humbars(lerp(pos.y,pos.x,bardir))*post_br*corner(pos0),1.0);
  2073. }
  2074.  
  2075. technique CRT_Guest_Advanced
  2076. {
  2077. pass Afterglow
  2078. {
  2079. VertexShader=PostProcessVS;
  2080. PixelShader=AfterglowPS;
  2081. RenderTarget=GUEST_T1;
  2082. }
  2083. pass PreShader
  2084. {
  2085. VertexShader=PostProcessVS;
  2086. PixelShader=PreShaderPS;
  2087. RenderTarget=GUEST_T2;
  2088. }
  2089. pass Luminance
  2090. {
  2091. VertexShader=PostProcessVS;
  2092. PixelShader=LuminancePS;
  2093. RenderTarget=GUEST_T3;
  2094. }
  2095. pass Linearize
  2096. {
  2097. VertexShader=PostProcessVS;
  2098. PixelShader=LinearizePS;
  2099. RenderTarget=GUEST_T4;
  2100. }
  2101. pass GaussianX
  2102. {
  2103. VertexShader=PostProcessVS;
  2104. PixelShader=HGaussianPS;
  2105. RenderTarget=GUEST_T5;
  2106. }
  2107. pass GaussianY
  2108. {
  2109. VertexShader=PostProcessVS;
  2110. PixelShader=VGaussianPS;
  2111. RenderTarget=GUEST_T6;
  2112. }
  2113. pass BloomHorz
  2114. {
  2115. VertexShader=PostProcessVS;
  2116. PixelShader=BloomHorzPS;
  2117. RenderTarget=GUEST_T7;
  2118. }
  2119. pass BloomVert
  2120. {
  2121. VertexShader=PostProcessVS;
  2122. PixelShader=BloomVertPS;
  2123. RenderTarget=GUEST_T8;
  2124. }
  2125. pass Guest_CRT
  2126. {
  2127. VertexShader=PostProcessVS;
  2128. PixelShader=Advanced_PS;
  2129. RenderTarget=GUEST_T9;
  2130. }
  2131. pass Chromatic
  2132. {
  2133. VertexShader=PostProcessVS;
  2134. PixelShader=ChromaticPS;
  2135. }
  2136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement