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