195 #define FXAA_360_OPT 0 206 #ifndef FXAA_PC_CONSOLE 212 #define FXAA_PC_CONSOLE 0 215 #ifndef FXAA_GLSL_120 216 #define FXAA_GLSL_120 0 219 #ifndef FXAA_GLSL_130 220 #define FXAA_GLSL_130 0 224 #define FXAA_HLSL_3 0 228 #define FXAA_HLSL_4 0 232 #define FXAA_HLSL_5 0 235 #ifndef FXAA_GREEN_AS_LUMA 254 #define FXAA_GREEN_AS_LUMA 0 257 #ifndef FXAA_EARLY_EXIT 268 #define FXAA_EARLY_EXIT 1 280 #define FXAA_DISCARD 0 283 #ifndef FXAA_FAST_PIXEL_OFFSET 290 #ifdef GL_EXT_gpu_shader4 291 #define FXAA_FAST_PIXEL_OFFSET 1 293 #ifdef GL_NV_gpu_shader5 294 #define FXAA_FAST_PIXEL_OFFSET 1 296 #ifdef GL_ARB_gpu_shader5 297 #define FXAA_FAST_PIXEL_OFFSET 1 299 #ifndef FXAA_FAST_PIXEL_OFFSET 300 #define FXAA_FAST_PIXEL_OFFSET 0 304 #ifndef FXAA_GATHER4_ALPHA 309 #if (FXAA_HLSL_5 == 1) 310 #define FXAA_GATHER4_ALPHA 1 312 #ifdef GL_ARB_gpu_shader5 313 #define FXAA_GATHER4_ALPHA 1 315 #ifdef GL_NV_gpu_shader5 316 #define FXAA_GATHER4_ALPHA 1 318 #ifndef FXAA_GATHER4_ALPHA 319 #define FXAA_GATHER4_ALPHA 0 326 #ifndef FXAA_CONSOLE__PS3_EDGE_SHARPNESS 340 #define FXAA_CONSOLE__PS3_EDGE_SHARPNESS 8.0 343 #define FXAA_CONSOLE__PS3_EDGE_SHARPNESS 4.0 346 #define FXAA_CONSOLE__PS3_EDGE_SHARPNESS 2.0 350 #ifndef FXAA_CONSOLE__PS3_EDGE_THRESHOLD 368 #define FXAA_CONSOLE__PS3_EDGE_THRESHOLD 0.125 370 #define FXAA_CONSOLE__PS3_EDGE_THRESHOLD 0.25 379 #ifndef FXAA_QUALITY__PRESET 400 #define FXAA_QUALITY__PRESET 12 413 #if (FXAA_QUALITY__PRESET == 10) 414 #define FXAA_QUALITY__PS 3 415 #define FXAA_QUALITY__P0 1.5 416 #define FXAA_QUALITY__P1 3.0 417 #define FXAA_QUALITY__P2 12.0 420 #if (FXAA_QUALITY__PRESET == 11) 421 #define FXAA_QUALITY__PS 4 422 #define FXAA_QUALITY__P0 1.0 423 #define FXAA_QUALITY__P1 1.5 424 #define FXAA_QUALITY__P2 3.0 425 #define FXAA_QUALITY__P3 12.0 428 #if (FXAA_QUALITY__PRESET == 12) 429 #define FXAA_QUALITY__PS 5 430 #define FXAA_QUALITY__P0 1.0 431 #define FXAA_QUALITY__P1 1.5 432 #define FXAA_QUALITY__P2 2.0 433 #define FXAA_QUALITY__P3 4.0 434 #define FXAA_QUALITY__P4 12.0 437 #if (FXAA_QUALITY__PRESET == 13) 438 #define FXAA_QUALITY__PS 6 439 #define FXAA_QUALITY__P0 1.0 440 #define FXAA_QUALITY__P1 1.5 441 #define FXAA_QUALITY__P2 2.0 442 #define FXAA_QUALITY__P3 2.0 443 #define FXAA_QUALITY__P4 4.0 444 #define FXAA_QUALITY__P5 12.0 447 #if (FXAA_QUALITY__PRESET == 14) 448 #define FXAA_QUALITY__PS 7 449 #define FXAA_QUALITY__P0 1.0 450 #define FXAA_QUALITY__P1 1.5 451 #define FXAA_QUALITY__P2 2.0 452 #define FXAA_QUALITY__P3 2.0 453 #define FXAA_QUALITY__P4 2.0 454 #define FXAA_QUALITY__P5 4.0 455 #define FXAA_QUALITY__P6 12.0 458 #if (FXAA_QUALITY__PRESET == 15) 459 #define FXAA_QUALITY__PS 8 460 #define FXAA_QUALITY__P0 1.0 461 #define FXAA_QUALITY__P1 1.5 462 #define FXAA_QUALITY__P2 2.0 463 #define FXAA_QUALITY__P3 2.0 464 #define FXAA_QUALITY__P4 2.0 465 #define FXAA_QUALITY__P5 2.0 466 #define FXAA_QUALITY__P6 4.0 467 #define FXAA_QUALITY__P7 12.0 473 #if (FXAA_QUALITY__PRESET == 20) 474 #define FXAA_QUALITY__PS 3 475 #define FXAA_QUALITY__P0 1.5 476 #define FXAA_QUALITY__P1 2.0 477 #define FXAA_QUALITY__P2 8.0 480 #if (FXAA_QUALITY__PRESET == 21) 481 #define FXAA_QUALITY__PS 4 482 #define FXAA_QUALITY__P0 1.0 483 #define FXAA_QUALITY__P1 1.5 484 #define FXAA_QUALITY__P2 2.0 485 #define FXAA_QUALITY__P3 8.0 488 #if (FXAA_QUALITY__PRESET == 22) 489 #define FXAA_QUALITY__PS 5 490 #define FXAA_QUALITY__P0 1.0 491 #define FXAA_QUALITY__P1 1.5 492 #define FXAA_QUALITY__P2 2.0 493 #define FXAA_QUALITY__P3 2.0 494 #define FXAA_QUALITY__P4 8.0 497 #if (FXAA_QUALITY__PRESET == 23) 498 #define FXAA_QUALITY__PS 6 499 #define FXAA_QUALITY__P0 1.0 500 #define FXAA_QUALITY__P1 1.5 501 #define FXAA_QUALITY__P2 2.0 502 #define FXAA_QUALITY__P3 2.0 503 #define FXAA_QUALITY__P4 2.0 504 #define FXAA_QUALITY__P5 8.0 507 #if (FXAA_QUALITY__PRESET == 24) 508 #define FXAA_QUALITY__PS 7 509 #define FXAA_QUALITY__P0 1.0 510 #define FXAA_QUALITY__P1 1.5 511 #define FXAA_QUALITY__P2 2.0 512 #define FXAA_QUALITY__P3 2.0 513 #define FXAA_QUALITY__P4 2.0 514 #define FXAA_QUALITY__P5 3.0 515 #define FXAA_QUALITY__P6 8.0 518 #if (FXAA_QUALITY__PRESET == 25) 519 #define FXAA_QUALITY__PS 8 520 #define FXAA_QUALITY__P0 1.0 521 #define FXAA_QUALITY__P1 1.5 522 #define FXAA_QUALITY__P2 2.0 523 #define FXAA_QUALITY__P3 2.0 524 #define FXAA_QUALITY__P4 2.0 525 #define FXAA_QUALITY__P5 2.0 526 #define FXAA_QUALITY__P6 4.0 527 #define FXAA_QUALITY__P7 8.0 530 #if (FXAA_QUALITY__PRESET == 26) 531 #define FXAA_QUALITY__PS 9 532 #define FXAA_QUALITY__P0 1.0 533 #define FXAA_QUALITY__P1 1.5 534 #define FXAA_QUALITY__P2 2.0 535 #define FXAA_QUALITY__P3 2.0 536 #define FXAA_QUALITY__P4 2.0 537 #define FXAA_QUALITY__P5 2.0 538 #define FXAA_QUALITY__P6 2.0 539 #define FXAA_QUALITY__P7 4.0 540 #define FXAA_QUALITY__P8 8.0 543 #if (FXAA_QUALITY__PRESET == 27) 544 #define FXAA_QUALITY__PS 10 545 #define FXAA_QUALITY__P0 1.0 546 #define FXAA_QUALITY__P1 1.5 547 #define FXAA_QUALITY__P2 2.0 548 #define FXAA_QUALITY__P3 2.0 549 #define FXAA_QUALITY__P4 2.0 550 #define FXAA_QUALITY__P5 2.0 551 #define FXAA_QUALITY__P6 2.0 552 #define FXAA_QUALITY__P7 2.0 553 #define FXAA_QUALITY__P8 4.0 554 #define FXAA_QUALITY__P9 8.0 557 #if (FXAA_QUALITY__PRESET == 28) 558 #define FXAA_QUALITY__PS 11 559 #define FXAA_QUALITY__P0 1.0 560 #define FXAA_QUALITY__P1 1.5 561 #define FXAA_QUALITY__P2 2.0 562 #define FXAA_QUALITY__P3 2.0 563 #define FXAA_QUALITY__P4 2.0 564 #define FXAA_QUALITY__P5 2.0 565 #define FXAA_QUALITY__P6 2.0 566 #define FXAA_QUALITY__P7 2.0 567 #define FXAA_QUALITY__P8 2.0 568 #define FXAA_QUALITY__P9 4.0 569 #define FXAA_QUALITY__P10 8.0 572 #if (FXAA_QUALITY__PRESET == 29) 573 #define FXAA_QUALITY__PS 12 574 #define FXAA_QUALITY__P0 1.0 575 #define FXAA_QUALITY__P1 1.5 576 #define FXAA_QUALITY__P2 2.0 577 #define FXAA_QUALITY__P3 2.0 578 #define FXAA_QUALITY__P4 2.0 579 #define FXAA_QUALITY__P5 2.0 580 #define FXAA_QUALITY__P6 2.0 581 #define FXAA_QUALITY__P7 2.0 582 #define FXAA_QUALITY__P8 2.0 583 #define FXAA_QUALITY__P9 2.0 584 #define FXAA_QUALITY__P10 4.0 585 #define FXAA_QUALITY__P11 8.0 591 #if (FXAA_QUALITY__PRESET == 39) 592 #define FXAA_QUALITY__PS 12 593 #define FXAA_QUALITY__P0 1.0 594 #define FXAA_QUALITY__P1 1.0 595 #define FXAA_QUALITY__P2 1.0 596 #define FXAA_QUALITY__P3 1.0 597 #define FXAA_QUALITY__P4 1.0 598 #define FXAA_QUALITY__P5 1.5 599 #define FXAA_QUALITY__P6 2.0 600 #define FXAA_QUALITY__P7 2.0 601 #define FXAA_QUALITY__P8 2.0 602 #define FXAA_QUALITY__P9 2.0 603 #define FXAA_QUALITY__P10 4.0 604 #define FXAA_QUALITY__P11 8.0 614 #if (FXAA_GLSL_120 == 1) || (FXAA_GLSL_130 == 1) 615 #define FxaaBool bool 616 #define FxaaDiscard discard 617 #define FxaaFloat float 618 #define FxaaFloat2 vec2 619 #define FxaaFloat3 vec3 620 #define FxaaFloat4 vec4 621 #define FxaaHalf float 622 #define FxaaHalf2 vec2 623 #define FxaaHalf3 vec3 624 #define FxaaHalf4 vec4 625 #define FxaaInt2 ivec2 626 #define FxaaSat(x) clamp(x, 0.0, 1.0) 627 #define FxaaTex sampler2D 629 #define FxaaBool bool 630 #define FxaaDiscard clip(-1) 631 #define FxaaFloat float 632 #define FxaaFloat2 float2 633 #define FxaaFloat3 float3 634 #define FxaaFloat4 float4 635 #define FxaaHalf half 636 #define FxaaHalf2 half2 637 #define FxaaHalf3 half3 638 #define FxaaHalf4 half4 639 #define FxaaSat(x) saturate(x) 642 #if (FXAA_GLSL_120 == 1) 648 #define FxaaTexTop(t, p) texture2DLod(t, p, 0.0) 649 #if (FXAA_FAST_PIXEL_OFFSET == 1) 650 #define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o) 652 #define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0) 654 #if (FXAA_GATHER4_ALPHA == 1) 656 #define FxaaTexAlpha4(t, p) textureGather(t, p, 3) 657 #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3) 658 #define FxaaTexGreen4(t, p) textureGather(t, p, 1) 659 #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1) 663 #if (FXAA_GLSL_130 == 1) 665 #define FxaaTexTop(t, p) textureLod(t, p, 0.0) 666 #define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o) 667 #if (FXAA_GATHER4_ALPHA == 1) 669 #define FxaaTexAlpha4(t, p) textureGather(t, p, 3) 670 #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3) 671 #define FxaaTexGreen4(t, p) textureGather(t, p, 1) 672 #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1) 676 #if (FXAA_HLSL_3 == 1) || (FXAA_360 == 1) || (FXAA_PS3 == 1) 677 #define FxaaInt2 float2 678 #define FxaaTex sampler2D 679 #define FxaaTexTop(t, p) tex2Dlod(t, float4(p, 0.0, 0.0)) 680 #define FxaaTexOff(t, p, o, r) tex2Dlod(t, float4(p + (o * r), 0, 0)) 683 #if (FXAA_HLSL_4 == 1) 684 #define FxaaInt2 int2 685 struct FxaaTex { SamplerState smpl; Texture2D tex; };
686 #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0) 687 #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o) 690 #if (FXAA_HLSL_5 == 1) 691 #define FxaaInt2 int2 692 struct FxaaTex { SamplerState smpl; Texture2D tex; };
693 #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0) 694 #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o) 695 #define FxaaTexAlpha4(t, p) t.tex.GatherAlpha(t.smpl, p) 696 #define FxaaTexOffAlpha4(t, p, o) t.tex.GatherAlpha(t.smpl, p, o) 697 #define FxaaTexGreen4(t, p) t.tex.GatherGreen(t.smpl, p) 698 #define FxaaTexOffGreen4(t, p, o) t.tex.GatherGreen(t.smpl, p, o) 705 #if (FXAA_GREEN_AS_LUMA == 0) 706 FxaaFloat FxaaLuma(FxaaFloat4 rgba) {
return rgba.w; }
708 FxaaFloat FxaaLuma(FxaaFloat4 rgba) {
return rgba.y; }
721 FxaaFloat4 FxaaPixelShader(
731 FxaaFloat4 fxaaConsolePosPos,
743 FxaaTex fxaaConsole360TexExpBiasNegOne,
749 FxaaTex fxaaConsole360TexExpBiasNegTwo,
755 FxaaFloat2 fxaaQualityRcpFrame,
767 FxaaFloat4 fxaaConsoleRcpFrameOpt,
776 FxaaFloat4 fxaaConsoleRcpFrameOpt2,
785 FxaaFloat4 fxaaConsole360RcpFrameOpt2,
797 FxaaFloat fxaaQualitySubpix,
808 FxaaFloat fxaaQualityEdgeThreshold,
823 FxaaFloat fxaaQualityEdgeThresholdMin,
837 FxaaFloat fxaaConsoleEdgeSharpness,
851 FxaaFloat fxaaConsoleEdgeThreshold,
870 FxaaFloat fxaaConsoleEdgeThresholdMin,
877 FxaaFloat4 fxaaConsole360ConstDir
883 #if (FXAA_GATHER4_ALPHA == 1) 884 #if (FXAA_DISCARD == 0) 885 FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);
886 #if (FXAA_GREEN_AS_LUMA == 0) 887 #define lumaM rgbyM.w 889 #define lumaM rgbyM.y 892 #if (FXAA_GREEN_AS_LUMA == 0) 893 FxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM);
894 FxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1));
896 FxaaFloat4 luma4A = FxaaTexGreen4(tex, posM);
897 FxaaFloat4 luma4B = FxaaTexOffGreen4(tex, posM, FxaaInt2(-1, -1));
899 #if (FXAA_DISCARD == 1) 900 #define lumaM luma4A.w 902 #define lumaE luma4A.z 903 #define lumaS luma4A.x 904 #define lumaSE luma4A.y 905 #define lumaNW luma4B.w 906 #define lumaN luma4B.z 907 #define lumaW luma4B.x 909 FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);
910 #if (FXAA_GREEN_AS_LUMA == 0) 911 #define lumaM rgbyM.w 913 #define lumaM rgbyM.y 915 FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));
916 FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));
917 FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));
918 FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));
921 FxaaFloat maxSM = max(lumaS, lumaM);
922 FxaaFloat minSM = min(lumaS, lumaM);
923 FxaaFloat maxESM = max(lumaE, maxSM);
924 FxaaFloat minESM = min(lumaE, minSM);
925 FxaaFloat maxWN = max(lumaN, lumaW);
926 FxaaFloat minWN = min(lumaN, lumaW);
927 FxaaFloat rangeMax = max(maxWN, maxESM);
928 FxaaFloat rangeMin = min(minWN, minESM);
929 FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;
930 FxaaFloat range = rangeMax - rangeMin;
931 FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);
932 FxaaBool earlyExit = range < rangeMaxClamped;
935 #if (FXAA_DISCARD == 1) 941 #if (FXAA_GATHER4_ALPHA == 0) 942 FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));
943 FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));
944 FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));
945 FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));
947 FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, -1), fxaaQualityRcpFrame.xy));
948 FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));
951 FxaaFloat lumaNS = lumaN + lumaS;
952 FxaaFloat lumaWE = lumaW + lumaE;
953 FxaaFloat subpixRcpRange = 1.0/range;
954 FxaaFloat subpixNSWE = lumaNS + lumaWE;
955 FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;
956 FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;
958 FxaaFloat lumaNESE = lumaNE + lumaSE;
959 FxaaFloat lumaNWNE = lumaNW + lumaNE;
960 FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;
961 FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;
963 FxaaFloat lumaNWSW = lumaNW + lumaSW;
964 FxaaFloat lumaSWSE = lumaSW + lumaSE;
965 FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);
966 FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);
967 FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;
968 FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;
969 FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;
970 FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;
972 FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;
973 FxaaFloat lengthSign = fxaaQualityRcpFrame.x;
974 FxaaBool horzSpan = edgeHorz >= edgeVert;
975 FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;
977 if(!horzSpan) lumaN = lumaW;
978 if(!horzSpan) lumaS = lumaE;
979 if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;
980 FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;
982 FxaaFloat gradientN = lumaN - lumaM;
983 FxaaFloat gradientS = lumaS - lumaM;
984 FxaaFloat lumaNN = lumaN + lumaM;
985 FxaaFloat lumaSS = lumaS + lumaM;
986 FxaaBool pairN = abs(gradientN) >= abs(gradientS);
987 FxaaFloat gradient = max(abs(gradientN), abs(gradientS));
988 if(pairN) lengthSign = -lengthSign;
989 FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);
995 offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;
996 offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;
997 if(!horzSpan) posB.x += lengthSign * 0.5;
998 if( horzSpan) posB.y += lengthSign * 0.5;
1001 posN.x = posB.x - offNP.x * FXAA_QUALITY__P0;
1002 posN.y = posB.y - offNP.y * FXAA_QUALITY__P0;
1004 posP.x = posB.x + offNP.x * FXAA_QUALITY__P0;
1005 posP.y = posB.y + offNP.y * FXAA_QUALITY__P0;
1006 FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;
1007 FxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));
1008 FxaaFloat subpixE = subpixC * subpixC;
1009 FxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));
1011 if(!pairN) lumaNN = lumaSS;
1012 FxaaFloat gradientScaled = gradient * 1.0/4.0;
1013 FxaaFloat lumaMM = lumaM - lumaNN * 0.5;
1014 FxaaFloat subpixF = subpixD * subpixE;
1015 FxaaBool lumaMLTZero = lumaMM < 0.0;
1017 lumaEndN -= lumaNN * 0.5;
1018 lumaEndP -= lumaNN * 0.5;
1019 FxaaBool doneN = abs(lumaEndN) >= gradientScaled;
1020 FxaaBool doneP = abs(lumaEndP) >= gradientScaled;
1021 if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P1;
1022 if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P1;
1023 FxaaBool doneNP = (!doneN) || (!doneP);
1024 if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P1;
1025 if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P1;
1028 if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
1029 if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
1030 if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
1031 if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
1032 doneN = abs(lumaEndN) >= gradientScaled;
1033 doneP = abs(lumaEndP) >= gradientScaled;
1034 if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P2;
1035 if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P2;
1036 doneNP = (!doneN) || (!doneP);
1037 if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P2;
1038 if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P2;
1040 #if (FXAA_QUALITY__PS > 3) 1042 if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
1043 if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
1044 if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
1045 if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
1046 doneN = abs(lumaEndN) >= gradientScaled;
1047 doneP = abs(lumaEndP) >= gradientScaled;
1048 if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P3;
1049 if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P3;
1050 doneNP = (!doneN) || (!doneP);
1051 if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P3;
1052 if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P3;
1054 #if (FXAA_QUALITY__PS > 4) 1056 if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
1057 if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
1058 if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
1059 if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
1060 doneN = abs(lumaEndN) >= gradientScaled;
1061 doneP = abs(lumaEndP) >= gradientScaled;
1062 if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P4;
1063 if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P4;
1064 doneNP = (!doneN) || (!doneP);
1065 if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P4;
1066 if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P4;
1068 #if (FXAA_QUALITY__PS > 5) 1070 if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
1071 if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
1072 if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
1073 if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
1074 doneN = abs(lumaEndN) >= gradientScaled;
1075 doneP = abs(lumaEndP) >= gradientScaled;
1076 if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P5;
1077 if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P5;
1078 doneNP = (!doneN) || (!doneP);
1079 if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P5;
1080 if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P5;
1082 #if (FXAA_QUALITY__PS > 6) 1084 if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
1085 if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
1086 if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
1087 if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
1088 doneN = abs(lumaEndN) >= gradientScaled;
1089 doneP = abs(lumaEndP) >= gradientScaled;
1090 if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P6;
1091 if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P6;
1092 doneNP = (!doneN) || (!doneP);
1093 if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P6;
1094 if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P6;
1096 #if (FXAA_QUALITY__PS > 7) 1098 if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
1099 if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
1100 if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
1101 if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
1102 doneN = abs(lumaEndN) >= gradientScaled;
1103 doneP = abs(lumaEndP) >= gradientScaled;
1104 if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P7;
1105 if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P7;
1106 doneNP = (!doneN) || (!doneP);
1107 if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P7;
1108 if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P7;
1110 #if (FXAA_QUALITY__PS > 8) 1112 if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
1113 if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
1114 if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
1115 if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
1116 doneN = abs(lumaEndN) >= gradientScaled;
1117 doneP = abs(lumaEndP) >= gradientScaled;
1118 if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P8;
1119 if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P8;
1120 doneNP = (!doneN) || (!doneP);
1121 if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P8;
1122 if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P8;
1124 #if (FXAA_QUALITY__PS > 9) 1126 if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
1127 if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
1128 if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
1129 if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
1130 doneN = abs(lumaEndN) >= gradientScaled;
1131 doneP = abs(lumaEndP) >= gradientScaled;
1132 if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P9;
1133 if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P9;
1134 doneNP = (!doneN) || (!doneP);
1135 if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P9;
1136 if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P9;
1138 #if (FXAA_QUALITY__PS > 10) 1140 if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
1141 if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
1142 if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
1143 if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
1144 doneN = abs(lumaEndN) >= gradientScaled;
1145 doneP = abs(lumaEndP) >= gradientScaled;
1146 if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P10;
1147 if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P10;
1148 doneNP = (!doneN) || (!doneP);
1149 if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P10;
1150 if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P10;
1152 #if (FXAA_QUALITY__PS > 11) 1154 if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
1155 if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
1156 if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
1157 if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
1158 doneN = abs(lumaEndN) >= gradientScaled;
1159 doneP = abs(lumaEndP) >= gradientScaled;
1160 if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P11;
1161 if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P11;
1162 doneNP = (!doneN) || (!doneP);
1163 if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P11;
1164 if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P11;
1166 #if (FXAA_QUALITY__PS > 12) 1168 if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
1169 if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
1170 if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
1171 if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
1172 doneN = abs(lumaEndN) >= gradientScaled;
1173 doneP = abs(lumaEndP) >= gradientScaled;
1174 if(!doneN) posN.x -= offNP.x * FXAA_QUALITY__P12;
1175 if(!doneN) posN.y -= offNP.y * FXAA_QUALITY__P12;
1176 doneNP = (!doneN) || (!doneP);
1177 if(!doneP) posP.x += offNP.x * FXAA_QUALITY__P12;
1178 if(!doneP) posP.y += offNP.y * FXAA_QUALITY__P12;
1212 FxaaFloat dstN = posM.x - posN.x;
1213 FxaaFloat dstP = posP.x - posM.x;
1214 if(!horzSpan) dstN = posM.y - posN.y;
1215 if(!horzSpan) dstP = posP.y - posM.y;
1217 FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;
1218 FxaaFloat spanLength = (dstP + dstN);
1219 FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;
1220 FxaaFloat spanLengthRcp = 1.0/spanLength;
1222 FxaaBool directionN = dstN < dstP;
1223 FxaaFloat dst = min(dstN, dstP);
1224 FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;
1225 FxaaFloat subpixG = subpixF * subpixF;
1226 FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;
1227 FxaaFloat subpixH = subpixG * fxaaQualitySubpix;
1229 FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;
1230 FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);
1231 if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;
1232 if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;
1233 #if (FXAA_DISCARD == 1) 1234 return FxaaTexTop(tex, posM);
1236 return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);
1256 #if (FXAA_PC_CONSOLE == 1) 1258 FxaaFloat4 FxaaPixelShader(
1261 FxaaFloat4 fxaaConsolePosPos,
1263 FxaaTex fxaaConsole360TexExpBiasNegOne,
1264 FxaaTex fxaaConsole360TexExpBiasNegTwo,
1265 FxaaFloat2 fxaaQualityRcpFrame,
1266 FxaaFloat4 fxaaConsoleRcpFrameOpt,
1267 FxaaFloat4 fxaaConsoleRcpFrameOpt2,
1268 FxaaFloat4 fxaaConsole360RcpFrameOpt2,
1269 FxaaFloat fxaaQualitySubpix,
1270 FxaaFloat fxaaQualityEdgeThreshold,
1271 FxaaFloat fxaaQualityEdgeThresholdMin,
1272 FxaaFloat fxaaConsoleEdgeSharpness,
1273 FxaaFloat fxaaConsoleEdgeThreshold,
1274 FxaaFloat fxaaConsoleEdgeThresholdMin,
1275 FxaaFloat4 fxaaConsole360ConstDir
1278 FxaaFloat lumaNw = FxaaLuma(FxaaTexTop(tex, fxaaConsolePosPos.xy));
1279 FxaaFloat lumaSw = FxaaLuma(FxaaTexTop(tex, fxaaConsolePosPos.xw));
1280 FxaaFloat lumaNe = FxaaLuma(FxaaTexTop(tex, fxaaConsolePosPos.zy));
1281 FxaaFloat lumaSe = FxaaLuma(FxaaTexTop(tex, fxaaConsolePosPos.zw));
1283 FxaaFloat4 rgbyM = FxaaTexTop(tex, pos.xy);
1284 #if (FXAA_GREEN_AS_LUMA == 0) 1285 FxaaFloat lumaM = rgbyM.w;
1287 FxaaFloat lumaM = rgbyM.y;
1290 FxaaFloat lumaMaxNwSw = max(lumaNw, lumaSw);
1291 lumaNe += 1.0/384.0;
1292 FxaaFloat lumaMinNwSw = min(lumaNw, lumaSw);
1294 FxaaFloat lumaMaxNeSe = max(lumaNe, lumaSe);
1295 FxaaFloat lumaMinNeSe = min(lumaNe, lumaSe);
1297 FxaaFloat lumaMax = max(lumaMaxNeSe, lumaMaxNwSw);
1298 FxaaFloat lumaMin = min(lumaMinNeSe, lumaMinNwSw);
1300 FxaaFloat lumaMaxScaled = lumaMax * fxaaConsoleEdgeThreshold;
1302 FxaaFloat lumaMinM = min(lumaMin, lumaM);
1303 FxaaFloat lumaMaxScaledClamped = max(fxaaConsoleEdgeThresholdMin, lumaMaxScaled);
1304 FxaaFloat lumaMaxM = max(lumaMax, lumaM);
1305 FxaaFloat dirSwMinusNe = lumaSw - lumaNe;
1306 FxaaFloat lumaMaxSubMinM = lumaMaxM - lumaMinM;
1307 FxaaFloat dirSeMinusNw = lumaSe - lumaNw;
1308 if(lumaMaxSubMinM < lumaMaxScaledClamped)
return rgbyM;
1311 dir.x = dirSwMinusNe + dirSeMinusNw;
1312 dir.y = dirSwMinusNe - dirSeMinusNw;
1314 FxaaFloat2 dir1 = normalize(dir.xy);
1315 FxaaFloat4 rgbyN1 = FxaaTexTop(tex, pos.xy - dir1 * fxaaConsoleRcpFrameOpt.zw);
1316 FxaaFloat4 rgbyP1 = FxaaTexTop(tex, pos.xy + dir1 * fxaaConsoleRcpFrameOpt.zw);
1318 FxaaFloat dirAbsMinTimesC = min(abs(dir1.x), abs(dir1.y)) * fxaaConsoleEdgeSharpness;
1319 FxaaFloat2 dir2 = clamp(dir1.xy / dirAbsMinTimesC, -2.0, 2.0);
1321 FxaaFloat4 rgbyN2 = FxaaTexTop(tex, pos.xy - dir2 * fxaaConsoleRcpFrameOpt2.zw);
1322 FxaaFloat4 rgbyP2 = FxaaTexTop(tex, pos.xy + dir2 * fxaaConsoleRcpFrameOpt2.zw);
1324 FxaaFloat4 rgbyA = rgbyN1 + rgbyP1;
1325 FxaaFloat4 rgbyB = ((rgbyN2 + rgbyP2) * 0.25) + (rgbyA * 0.25);
1327 #if (FXAA_GREEN_AS_LUMA == 0) 1328 FxaaBool twoTap = (rgbyB.w < lumaMin) || (rgbyB.w > lumaMax);
1330 FxaaBool twoTap = (rgbyB.y < lumaMin) || (rgbyB.y > lumaMax);
1332 if(twoTap) rgbyB.xyz = rgbyA.xyz * 0.5;
1353 [reduceTempRegUsage(4)]
1354 float4 FxaaPixelShader(
1357 FxaaFloat4 fxaaConsolePosPos,
1359 FxaaTex fxaaConsole360TexExpBiasNegOne,
1360 FxaaTex fxaaConsole360TexExpBiasNegTwo,
1361 FxaaFloat2 fxaaQualityRcpFrame,
1362 FxaaFloat4 fxaaConsoleRcpFrameOpt,
1363 FxaaFloat4 fxaaConsoleRcpFrameOpt2,
1364 FxaaFloat4 fxaaConsole360RcpFrameOpt2,
1365 FxaaFloat fxaaQualitySubpix,
1366 FxaaFloat fxaaQualityEdgeThreshold,
1367 FxaaFloat fxaaQualityEdgeThresholdMin,
1368 FxaaFloat fxaaConsoleEdgeSharpness,
1369 FxaaFloat fxaaConsoleEdgeThreshold,
1370 FxaaFloat fxaaConsoleEdgeThresholdMin,
1371 FxaaFloat4 fxaaConsole360ConstDir
1374 float4 lumaNwNeSwSe;
1375 #if (FXAA_GREEN_AS_LUMA == 0) 1377 tfetch2D lumaNwNeSwSe.w___, tex, pos.xy, OffsetX = -0.5, OffsetY = -0.5, UseComputedLOD=
false 1378 tfetch2D lumaNwNeSwSe._w__, tex, pos.xy, OffsetX = 0.5, OffsetY = -0.5, UseComputedLOD=
false 1379 tfetch2D lumaNwNeSwSe.__w_, tex, pos.xy, OffsetX = -0.5, OffsetY = 0.5, UseComputedLOD=
false 1380 tfetch2D lumaNwNeSwSe.___w, tex, pos.xy, OffsetX = 0.5, OffsetY = 0.5, UseComputedLOD=
false 1384 tfetch2D lumaNwNeSwSe.y___, tex, pos.xy, OffsetX = -0.5, OffsetY = -0.5, UseComputedLOD=
false 1385 tfetch2D lumaNwNeSwSe._y__, tex, pos.xy, OffsetX = 0.5, OffsetY = -0.5, UseComputedLOD=
false 1386 tfetch2D lumaNwNeSwSe.__y_, tex, pos.xy, OffsetX = -0.5, OffsetY = 0.5, UseComputedLOD=
false 1387 tfetch2D lumaNwNeSwSe.___y, tex, pos.xy, OffsetX = 0.5, OffsetY = 0.5, UseComputedLOD=
false 1391 lumaNwNeSwSe.y += 1.0/384.0;
1392 float2 lumaMinTemp = min(lumaNwNeSwSe.xy, lumaNwNeSwSe.zw);
1393 float2 lumaMaxTemp = max(lumaNwNeSwSe.xy, lumaNwNeSwSe.zw);
1394 float lumaMin = min(lumaMinTemp.x, lumaMinTemp.y);
1395 float lumaMax = max(lumaMaxTemp.x, lumaMaxTemp.y);
1397 float4 rgbyM = tex2Dlod(tex, float4(pos.xy, 0.0, 0.0));
1398 #if (FXAA_GREEN_AS_LUMA == 0) 1399 float lumaMinM = min(lumaMin, rgbyM.w);
1400 float lumaMaxM = max(lumaMax, rgbyM.w);
1402 float lumaMinM = min(lumaMin, rgbyM.y);
1403 float lumaMaxM = max(lumaMax, rgbyM.y);
1405 if((lumaMaxM - lumaMinM) < max(fxaaConsoleEdgeThresholdMin, lumaMax * fxaaConsoleEdgeThreshold))
return rgbyM;
1408 dir.x = dot(lumaNwNeSwSe, fxaaConsole360ConstDir.yyxx);
1409 dir.y = dot(lumaNwNeSwSe, fxaaConsole360ConstDir.xyxy);
1410 dir = normalize(dir);
1412 float4 dir1 = dir.xyxy * fxaaConsoleRcpFrameOpt.xyzw;
1415 float dirAbsMinTimesC = min(abs(dir.x), abs(dir.y)) * fxaaConsoleEdgeSharpness;
1416 dir2 = saturate(fxaaConsole360ConstDir.zzww * dir.xyxy / dirAbsMinTimesC + 0.5);
1417 dir2 = dir2 * fxaaConsole360RcpFrameOpt2.xyxy + fxaaConsole360RcpFrameOpt2.zwzw;
1419 float4 rgbyN1 = tex2Dlod(fxaaConsole360TexExpBiasNegOne, float4(pos.xy + dir1.xy, 0.0, 0.0));
1420 float4 rgbyP1 = tex2Dlod(fxaaConsole360TexExpBiasNegOne, float4(pos.xy + dir1.zw, 0.0, 0.0));
1421 float4 rgbyN2 = tex2Dlod(fxaaConsole360TexExpBiasNegTwo, float4(pos.xy + dir2.xy, 0.0, 0.0));
1422 float4 rgbyP2 = tex2Dlod(fxaaConsole360TexExpBiasNegTwo, float4(pos.xy + dir2.zw, 0.0, 0.0));
1424 float4 rgbyA = rgbyN1 + rgbyP1;
1425 float4 rgbyB = rgbyN2 + rgbyP2 + rgbyA * 0.5;
1427 float4 rgbyR = ((FxaaLuma(rgbyB) - lumaMax) > 0.0) ? rgbyA : rgbyB;
1428 rgbyR = ((FxaaLuma(rgbyB) - lumaMin) > 0.0) ? rgbyR : rgbyA;
1590 #if (FXAA_PS3 == 1) && (FXAA_EARLY_EXIT == 0) 1593 #pragma disablepc all 1595 #pragma option OutColorPrec=fp16 1596 #pragma texformat default RGBA8 1598 half4 FxaaPixelShader(
1601 FxaaFloat4 fxaaConsolePosPos,
1603 FxaaTex fxaaConsole360TexExpBiasNegOne,
1604 FxaaTex fxaaConsole360TexExpBiasNegTwo,
1605 FxaaFloat2 fxaaQualityRcpFrame,
1606 FxaaFloat4 fxaaConsoleRcpFrameOpt,
1607 FxaaFloat4 fxaaConsoleRcpFrameOpt2,
1608 FxaaFloat4 fxaaConsole360RcpFrameOpt2,
1609 FxaaFloat fxaaQualitySubpix,
1610 FxaaFloat fxaaQualityEdgeThreshold,
1611 FxaaFloat fxaaQualityEdgeThresholdMin,
1612 FxaaFloat fxaaConsoleEdgeSharpness,
1613 FxaaFloat fxaaConsoleEdgeThreshold,
1614 FxaaFloat fxaaConsoleEdgeThresholdMin,
1615 FxaaFloat4 fxaaConsole360ConstDir
1620 half4 lumaNe = h4tex2Dlod(tex, half4(fxaaConsolePosPos.zy, 0, 0));
1621 #if (FXAA_GREEN_AS_LUMA == 0) 1622 lumaNe.w += half(1.0/512.0);
1626 lumaNe.y += half(1.0/512.0);
1632 half4 lumaSw = h4tex2Dlod(tex, half4(fxaaConsolePosPos.xw, 0, 0));
1633 #if (FXAA_GREEN_AS_LUMA == 0) 1642 half4 lumaNw = h4tex2Dlod(tex, half4(fxaaConsolePosPos.xy, 0, 0));
1643 #if (FXAA_GREEN_AS_LUMA == 0) 1652 half4 lumaSe = h4tex2Dlod(tex, half4(fxaaConsolePosPos.zw, 0, 0));
1653 #if (FXAA_GREEN_AS_LUMA == 0) 1663 dir1_pos.xy = normalize(dir.xyz).xz;
1664 half dirAbsMinTimesC = min(abs(dir1_pos.x), abs(dir1_pos.y)) * half(FXAA_CONSOLE__PS3_EDGE_SHARPNESS);
1668 dir2_pos.xy = clamp(dir1_pos.xy / dirAbsMinTimesC, half(-2.0), half(2.0));
1669 dir1_pos.zw = pos.xy;
1670 dir2_pos.zw = pos.xy;
1672 temp1N.xy = dir1_pos.zw - dir1_pos.xy * fxaaConsoleRcpFrameOpt.zw;
1675 temp1N = h4tex2Dlod(tex, half4(temp1N.xy, 0.0, 0.0));
1677 rgby1.xy = dir1_pos.zw + dir1_pos.xy * fxaaConsoleRcpFrameOpt.zw;
1680 rgby1 = h4tex2Dlod(tex, half4(rgby1.xy, 0.0, 0.0));
1681 rgby1 = (temp1N + rgby1) * 0.5;
1685 temp2N.xy = dir2_pos.zw - dir2_pos.xy * fxaaConsoleRcpFrameOpt2.zw;
1686 temp2N = h4tex2Dlod(tex, half4(temp2N.xy, 0.0, 0.0));
1690 rgby2.xy = dir2_pos.zw + dir2_pos.xy * fxaaConsoleRcpFrameOpt2.zw;
1691 rgby2 = h4tex2Dlod(tex, half4(rgby2.xy, 0.0, 0.0));
1692 rgby2 = (temp2N + rgby2) * 0.5;
1696 #if (FXAA_GREEN_AS_LUMA == 0) 1697 half lumaMin = min(min(lumaNw.w, lumaSw.w), min(lumaNe.w, lumaSe.w));
1698 half lumaMax = max(max(lumaNw.w, lumaSw.w), max(lumaNe.w, lumaSe.w));
1700 half lumaMin = min(min(lumaNw.y, lumaSw.y), min(lumaNe.y, lumaSe.y));
1701 half lumaMax = max(max(lumaNw.y, lumaSw.y), max(lumaNe.y, lumaSe.y));
1703 rgby2 = (rgby2 + rgby1) * 0.5;
1706 #if (FXAA_GREEN_AS_LUMA == 0) 1707 bool twoTapLt = rgby2.w < lumaMin;
1708 bool twoTapGt = rgby2.w > lumaMax;
1710 bool twoTapLt = rgby2.y < lumaMin;
1711 bool twoTapGt = rgby2.y > lumaMax;
1715 if(twoTapLt || twoTapGt) rgby2 = rgby1;
1899 #if (FXAA_PS3 == 1) && (FXAA_EARLY_EXIT == 1) 1902 #pragma disablepc all 1904 #pragma option OutColorPrec=fp16 1905 #pragma texformat default RGBA8 1907 half4 FxaaPixelShader(
1910 FxaaFloat4 fxaaConsolePosPos,
1912 FxaaTex fxaaConsole360TexExpBiasNegOne,
1913 FxaaTex fxaaConsole360TexExpBiasNegTwo,
1914 FxaaFloat2 fxaaQualityRcpFrame,
1915 FxaaFloat4 fxaaConsoleRcpFrameOpt,
1916 FxaaFloat4 fxaaConsoleRcpFrameOpt2,
1917 FxaaFloat4 fxaaConsole360RcpFrameOpt2,
1918 FxaaFloat fxaaQualitySubpix,
1919 FxaaFloat fxaaQualityEdgeThreshold,
1920 FxaaFloat fxaaQualityEdgeThresholdMin,
1921 FxaaFloat fxaaConsoleEdgeSharpness,
1922 FxaaFloat fxaaConsoleEdgeThreshold,
1923 FxaaFloat fxaaConsoleEdgeThresholdMin,
1924 FxaaFloat4 fxaaConsole360ConstDir
1928 half4 rgbyNe = h4tex2Dlod(tex, half4(fxaaConsolePosPos.zy, 0, 0));
1929 #if (FXAA_GREEN_AS_LUMA == 0) 1930 half lumaNe = rgbyNe.w + half(1.0/512.0);
1932 half lumaNe = rgbyNe.y + half(1.0/512.0);
1936 half4 lumaSw = h4tex2Dlod(tex, half4(fxaaConsolePosPos.xw, 0, 0));
1937 #if (FXAA_GREEN_AS_LUMA == 0) 1938 half lumaSwNegNe = lumaSw.w - lumaNe;
1940 half lumaSwNegNe = lumaSw.y - lumaNe;
1944 half4 lumaNw = h4tex2Dlod(tex, half4(fxaaConsolePosPos.xy, 0, 0));
1945 #if (FXAA_GREEN_AS_LUMA == 0) 1946 half lumaMaxNwSw = max(lumaNw.w, lumaSw.w);
1947 half lumaMinNwSw = min(lumaNw.w, lumaSw.w);
1949 half lumaMaxNwSw = max(lumaNw.y, lumaSw.y);
1950 half lumaMinNwSw = min(lumaNw.y, lumaSw.y);
1954 half4 lumaSe = h4tex2Dlod(tex, half4(fxaaConsolePosPos.zw, 0, 0));
1955 #if (FXAA_GREEN_AS_LUMA == 0) 1956 half dirZ = lumaNw.w + lumaSwNegNe;
1957 half dirX = -lumaNw.w + lumaSwNegNe;
1959 half dirZ = lumaNw.y + lumaSwNegNe;
1960 half dirX = -lumaNw.y + lumaSwNegNe;
1966 #if (FXAA_GREEN_AS_LUMA == 0) 1967 dir.x = lumaSe.w + dirX;
1968 dir.z = -lumaSe.w + dirZ;
1969 half lumaMinNeSe = min(lumaNe, lumaSe.w);
1971 dir.x = lumaSe.y + dirX;
1972 dir.z = -lumaSe.y + dirZ;
1973 half lumaMinNeSe = min(lumaNe, lumaSe.y);
1978 dir1_pos.xy = normalize(dir).xz;
1979 half dirAbsMinTimes8 = min(abs(dir1_pos.x), abs(dir1_pos.y)) * half(FXAA_CONSOLE__PS3_EDGE_SHARPNESS);
1983 dir2_pos.xy = clamp(dir1_pos.xy / dirAbsMinTimes8, half(-2.0), half(2.0));
1984 dir1_pos.zw = pos.xy;
1985 dir2_pos.zw = pos.xy;
1986 #if (FXAA_GREEN_AS_LUMA == 0) 1987 half lumaMaxNeSe = max(lumaNe, lumaSe.w);
1989 half lumaMaxNeSe = max(lumaNe, lumaSe.y);
1994 temp1N.xy = dir1_pos.zw - dir1_pos.xy * fxaaConsoleRcpFrameOpt.zw;
1995 temp1N = h4tex2Dlod(tex, half4(temp1N.xy, 0.0, 0.0));
1996 half lumaMax = max(lumaMaxNwSw, lumaMaxNeSe);
1997 half lumaMin = min(lumaMinNwSw, lumaMinNeSe);
2001 rgby1.xy = dir1_pos.zw + dir1_pos.xy * fxaaConsoleRcpFrameOpt.zw;
2002 rgby1 = h4tex2Dlod(tex, half4(rgby1.xy, 0.0, 0.0));
2003 rgby1 = (temp1N + rgby1) * 0.5;
2006 half4 rgbyM = h4tex2Dlod(tex, half4(pos.xy, 0.0, 0.0));
2007 #if (FXAA_GREEN_AS_LUMA == 0) 2008 half lumaMaxM = max(lumaMax, rgbyM.w);
2009 half lumaMinM = min(lumaMin, rgbyM.w);
2011 half lumaMaxM = max(lumaMax, rgbyM.y);
2012 half lumaMinM = min(lumaMin, rgbyM.y);
2017 temp2N.xy = dir2_pos.zw - dir2_pos.xy * fxaaConsoleRcpFrameOpt2.zw;
2018 temp2N = h4tex2Dlod(tex, half4(temp2N.xy, 0.0, 0.0));
2020 rgby2.xy = dir2_pos.zw + dir2_pos.xy * fxaaConsoleRcpFrameOpt2.zw;
2021 half lumaRangeM = (lumaMaxM - lumaMinM) / FXAA_CONSOLE__PS3_EDGE_THRESHOLD;
2024 rgby2 = h4tex2Dlod(tex, half4(rgby2.xy, 0.0, 0.0));
2025 rgby2 = (temp2N + rgby2) * 0.5;
2028 rgby2 = (rgby2 + rgby1) * 0.5;
2031 #if (FXAA_GREEN_AS_LUMA == 0) 2032 bool twoTapLt = rgby2.w < lumaMin;
2033 bool twoTapGt = rgby2.w > lumaMax;
2035 bool twoTapLt = rgby2.y < lumaMin;
2036 bool twoTapGt = rgby2.y > lumaMax;
2038 bool earlyExit = lumaRangeM < lumaMax;
2039 bool twoTap = twoTapLt || twoTapGt;
2042 if(twoTap) rgby2 = rgby1;
2043 if(earlyExit) rgby2 = rgbyM;