FXAAGreenLumaLow.fx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #define FXAA_PC_CONSOLE 1
  2. #ifdef SM4 // shader model 4.0 (DX11)
  3. #define FXAA_HLSL_4_MG 1
  4. #else
  5. #define FXAA_HLSL_3 1
  6. #endif
  7. #define FXAA_GREEN_AS_LUMA 1
  8. #include "Fxaa3_11.MG.fxh"
  9. #include "Macros.fxh"
  10. DECLARE_TEXTURE(Texture, 0);
  11. //BEGIN_CONSTANTS
  12. float2 InverseViewportSize;
  13. float4 ConsoleSharpness;
  14. float4 ConsoleOpt1;
  15. float4 ConsoleOpt2;
  16. float SubPixelAliasingRemoval;
  17. float EdgeThreshold;
  18. float EdgeThresholdMin;
  19. float ConsoleEdgeSharpness;
  20. float ConsoleEdgeThreshold;
  21. float ConsoleEdgeThresholdMin;
  22. // Must keep this as constant register instead of an immediate
  23. float4 Console360ConstDir = float4(1.0, -1.0, 0.25, -0.25);
  24. //MATRIX_CONSTANTS
  25. float4x4 World;
  26. float4x4 View;
  27. float4x4 Projection;
  28. //END_CONSTANTS
  29. struct VSOutput
  30. {
  31. float4 position : SV_Position;
  32. float2 texCoord : TEXCOORD0;
  33. };
  34. VSOutput VertexShaderFunction(float4 position : POSITION0,
  35. float2 texCoord : TEXCOORD0)
  36. {
  37. VSOutput output;
  38. float4 worldPosition = mul(position, World);
  39. float4 viewPosition = mul(worldPosition, View);
  40. output.position = mul(viewPosition, Projection);
  41. output.texCoord = texCoord;
  42. return output;
  43. }
  44. float4 PixelShaderFunction_FXAA(VSOutput input) : SV_Target0
  45. {
  46. FxaaTex tex;
  47. #ifdef SM4 // shader model 4.0 (DX11)
  48. tex.tex = Texture;
  49. tex.smpl = TextureSampler;
  50. #else
  51. tex = TextureSampler;
  52. #endif
  53. float4 value = FxaaPixelShader(
  54. input.texCoord,
  55. 0, // Not used in PC or Xbox 360
  56. tex,
  57. tex, // *** TODO: For Xbox, can I use additional sampler with exponent bias of -1
  58. tex, // *** TODO: For Xbox, can I use additional sampler with exponent bias of -2
  59. InverseViewportSize, // FXAA Quality only
  60. ConsoleSharpness, // Console only
  61. ConsoleOpt1,
  62. ConsoleOpt2,
  63. SubPixelAliasingRemoval, // FXAA Quality only
  64. EdgeThreshold,// FXAA Quality only
  65. EdgeThresholdMin,
  66. ConsoleEdgeSharpness,
  67. ConsoleEdgeThreshold, // TODO
  68. ConsoleEdgeThresholdMin, // TODO
  69. Console360ConstDir
  70. );
  71. return value;
  72. }
  73. float4 PixelShaderFunction_Standard(VSOutput input) : SV_Target0
  74. {
  75. return SAMPLE_TEXTURE(Texture, input.texCoord);
  76. }
  77. TECHNIQUE( Standard, VertexShaderFunction, PixelShaderFunction_Standard );
  78. technique FXAA
  79. {
  80. pass
  81. {
  82. #ifdef SM4 // shader model 4.0 (DX11)
  83. VertexShader = compile vs_4_0_level_9_1 VertexShaderFunction();
  84. PixelShader = compile ps_4_0_level_9_3 PixelShaderFunction_FXAA();
  85. #else
  86. VertexShader = compile vs_3_0 VertexShaderFunction();
  87. PixelShader = compile ps_3_0 PixelShaderFunction_FXAA();
  88. #endif
  89. }
  90. }