Advertisement
Guest User

Untitled

a guest
Jan 6th, 2019
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. texture2D frameTex2D;
  2.  
  3. #define FXAA_PC 1
  4. #define FXAA_HLSL_3 1
  5.  
  6. #ifndef FXAA_QUALITY__PRESET
  7. #define FXAA_QUALITY__PRESET 26
  8. #endif
  9.  
  10. #include "FXAA.h"
  11.  
  12. sampler frameSampler = sampler_state
  13. {
  14. texture = <frameTex2D>;
  15. AddressU = CLAMP;
  16. AddressV = CLAMP;
  17. MINFILTER = LINEAR;
  18. MAGFILTER = LINEAR;
  19. };
  20.  
  21. struct VSOUT
  22. {
  23. float4 vertPos : POSITION;
  24. float2 UVCoord : TEXCOORD0;
  25. };
  26.  
  27. struct VSIN
  28. {
  29. float4 vertPos : POSITION0;
  30. float2 UVCoord : TEXCOORD0;
  31. };
  32.  
  33. VSOUT FrameVS(VSIN IN)
  34. {
  35. VSOUT OUT;
  36. OUT.vertPos = IN.vertPos;
  37. OUT.UVCoord = IN.UVCoord;
  38. return OUT;
  39. }
  40.  
  41. float4 calcLuma(VSOUT IN) : COLOR0
  42. {
  43. // Mirror Mode!
  44. IN.UVCoord.x = 1 - IN.UVCoord.x;
  45.  
  46. float4 color = tex2D(frameSampler, IN.UVCoord);
  47. color.a = dot(color.rgb, float3(0.299, 0.587, 0.114));
  48. //return float4(color.a,color.a,color.a,color.a);
  49.  
  50. return color;
  51. }
  52.  
  53. float4 applyFXAA(VSOUT IN) : COLOR0
  54. {
  55. return FxaaPixelShader(IN.UVCoord, float4(0,0,0,0), frameSampler, frameSampler,
  56. frameSampler, PIXEL_SIZE, float4(0,0,0,0), float4(0,0,0,0), float4(0,0,0,0),
  57. //
  58. // Only used on FXAA Quality.
  59. // This used to be the FXAA_QUALITY__SUBPIX define.
  60. // It is here now to allow easier tuning.
  61. // Choose the amount of sub-pixel aliasing removal.
  62. // This can effect sharpness.
  63. // 1.00 - upper limit (softer)
  64. // 0.75 - default amount of filtering
  65. // 0.50 - lower limit (sharper, less sub-pixel aliasing removal)
  66. // 0.25 - almost off
  67. // 0.00 - completely off
  68. 0.75,
  69. //
  70. // Only used on FXAA Quality.
  71. // This used to be the FXAA_QUALITY__EDGE_THRESHOLD define.
  72. // It is here now to allow easier tuning.
  73. // The minimum amount of local contrast required to apply algorithm.
  74. // 0.333 - too little (faster)
  75. // 0.250 - low quality
  76. // 0.166 - default
  77. // 0.125 - high quality
  78. // 0.063 - overkill (slower)
  79. 0.125,
  80. //
  81. // Only used on FXAA Quality.
  82. // This used to be the FXAA_QUALITY__EDGE_THRESHOLD_MIN define.
  83. // It is here now to allow easier tuning.
  84. // Trims the algorithm from processing darks.
  85. // 0.0833 - upper limit (default, the start of visible unfiltered edges)
  86. // 0.0625 - high quality (faster)
  87. // 0.0312 - visible limit (slower)
  88. // Special notes when using FXAA_GREEN_AS_LUMA,
  89. // Likely want to set this to zero.
  90. // As colors that are mostly not-green
  91. // will appear very dark in the green channel!
  92. // Tune by looking at mostly non-green content,
  93. // then start at zero and increase until aliasing is a problem.
  94. 0.0312,
  95. 8.0, 0.125, 0.05, float4(0,0,0,0) );
  96. }
  97.  
  98. technique t0
  99. {
  100. pass P0
  101. {
  102. VertexShader = compile vs_3_0 FrameVS();
  103. PixelShader = compile ps_3_0 calcLuma();
  104. ZEnable = false;
  105. SRGBWriteEnable = false;
  106. AlphaBlendEnable = false;
  107. AlphaTestEnable = false;
  108. ColorWriteEnable = RED|GREEN|BLUE|ALPHA;
  109. }
  110.  
  111. pass P1
  112. {
  113. VertexShader = compile vs_3_0 FrameVS();
  114. PixelShader = compile ps_3_0 applyFXAA();
  115. ZEnable = false;
  116. SRGBWriteEnable = false;
  117. AlphaBlendEnable = false;
  118. AlphaTestEnable = false;
  119. }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement