fxaa.pixel 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #include "global.inc"
  21. #define FXAA_GREEN_AS_LUMA 1
  22. #define FXAA_EARLY_EXIT 0
  23. #include "Fxaa3_11.h"
  24. uniform sampler2D samp0 : register(s0);
  25. uniform sampler2D samp1 : register(s1); // exponent bias -1
  26. uniform sampler2D samp2 : register(s2); // exponent bias -2
  27. uniform float4 rpUser0 : register( c128 );
  28. uniform float4 rpUser1 : register( c129 );
  29. uniform float4 rpUser2 : register( c130 );
  30. uniform float4 rpUser3 : register( c131 );
  31. uniform float4 rpUser4 : register( c132 );
  32. uniform float4 rpUser5 : register( c133 );
  33. uniform float4 rpUser6 : register( c134 );
  34. struct PS_IN {
  35. float4 position : VPOS;
  36. float2 texcoord0 : TEXCOORD0_centroid;
  37. };
  38. struct PS_OUT {
  39. float4 color : COLOR;
  40. };
  41. void main( PS_IN fragment, out PS_OUT result ) {
  42. const float4 FXAAQualityRCPFrame = rpUser0;
  43. const float4 FXAAConsoleRcpFrameOpt = rpUser1;
  44. const float4 FXAAConsoleRcpFrameOpt2 = rpUser2;
  45. const float4 FXAAConsole360RcpFrameOpt2 = rpUser3;
  46. const float4 FXAAQualityParms = rpUser4;
  47. const float4 FXAAConsoleEdgeParms = rpUser5;
  48. const float4 FXAAConsole360ConstDir = rpUser6;
  49. // Inputs - see more info in fxaa3_11.hfile
  50. FxaaFloat2 fxaaPos = fragment.texcoord0;
  51. FxaaFloat4 fxaaConsolePos;
  52. float2 halfPixelOffset = float2( 0.5, 0.5 ) * FXAAQualityRCPFrame.xy;
  53. fxaaConsolePos.xy = fxaaPos.xy - ( halfPixelOffset );
  54. fxaaConsolePos.zw = fxaaPos.xy + ( halfPixelOffset );
  55. FxaaFloat2 fxaaQualityRcpFrame = FXAAQualityRCPFrame.xy;
  56. FxaaFloat4 fxaaConsoleRcpFrameOpt = FXAAConsoleRcpFrameOpt;
  57. FxaaFloat4 fxaaConsoleRcpFrameOpt2 = FXAAConsoleRcpFrameOpt2;
  58. FxaaFloat4 fxaaConsole360RcpFrameOpt2 = FXAAConsole360RcpFrameOpt2;
  59. // Quality parms
  60. FxaaFloat fxaaQualitySubpix = FXAAQualityParms.x;
  61. FxaaFloat fxaaQualityEdgeThreshold = FXAAQualityParms.y;
  62. FxaaFloat fxaaQualityEdgeThresholdMin = FXAAQualityParms.z;
  63. // Console specific Parms
  64. FxaaFloat fxaaConsoleEdgeSharpness = FXAAConsoleEdgeParms.x;
  65. FxaaFloat fxaaConsoleEdgeThreshold = FXAAConsoleEdgeParms.y;
  66. FxaaFloat fxaaConsoleEdgeThresholdMin = FXAAConsoleEdgeParms.z;
  67. // 360 specific parms these have to come from a constant register so that the compiler
  68. // does not unoptimize the shader
  69. FxaaFloat4 fxaaConsole360ConstDir = FXAAConsole360ConstDir;
  70. float4 colorSample = FxaaPixelShader( fxaaPos,
  71. fxaaConsolePos,
  72. samp0,
  73. samp1,
  74. samp2,
  75. fxaaQualityRcpFrame,
  76. fxaaConsoleRcpFrameOpt,
  77. fxaaConsoleRcpFrameOpt2,
  78. fxaaConsole360RcpFrameOpt2,
  79. fxaaQualitySubpix,
  80. fxaaQualityEdgeThreshold,
  81. fxaaQualityEdgeThresholdMin,
  82. fxaaConsoleEdgeSharpness,
  83. fxaaConsoleEdgeThreshold,
  84. fxaaConsoleEdgeThresholdMin,
  85. fxaaConsole360ConstDir );
  86. result.color = colorSample;
  87. }