You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.5 KiB

  1. Shader "Hidden/Post FX/FXAA"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "white" {}
  6. }
  7. CGINCLUDE
  8. #include "UnityCG.cginc"
  9. #include "Common.cginc"
  10. #include "UberSecondPass.cginc"
  11. #pragma multi_compile __ GRAIN
  12. #pragma multi_compile __ DITHERING
  13. #if defined(SHADER_API_PS3)
  14. #define FXAA_PS3 1
  15. // Shaves off 2 cycles from the shader
  16. #define FXAA_EARLY_EXIT 0
  17. #elif defined(SHADER_API_XBOX360)
  18. #define FXAA_360 1
  19. // Shaves off 10ms from the shader's execution time
  20. #define FXAA_EARLY_EXIT 1
  21. #else
  22. #define FXAA_PC 1
  23. #endif
  24. #define FXAA_HLSL_3 1
  25. #define FXAA_QUALITY__PRESET 39
  26. #define FXAA_GREEN_AS_LUMA 1
  27. #pragma target 3.0
  28. #include "FXAA3.cginc"
  29. float3 _QualitySettings;
  30. float4 _ConsoleSettings;
  31. half4 Frag(VaryingsDefault i) : SV_Target
  32. {
  33. const float4 consoleUV = i.uv.xyxy + 0.5 * float4(-_MainTex_TexelSize.xy, _MainTex_TexelSize.xy);
  34. const float4 consoleSubpixelFrame = _ConsoleSettings.x * float4(-1.0, -1.0, 1.0, 1.0) *
  35. _MainTex_TexelSize.xyxy;
  36. const float4 consoleSubpixelFramePS3 = float4(-2.0, -2.0, 2.0, 2.0) * _MainTex_TexelSize.xyxy;
  37. const float4 consoleSubpixelFrameXBOX = float4(8.0, 8.0, -4.0, -4.0) * _MainTex_TexelSize.xyxy;
  38. #if defined(SHADER_API_XBOX360)
  39. const float4 consoleConstants = float4(1.0, -1.0, 0.25, -0.25);
  40. #else
  41. const float4 consoleConstants = float4(0.0, 0.0, 0.0, 0.0);
  42. #endif
  43. half4 color = FxaaPixelShader(
  44. UnityStereoScreenSpaceUVAdjust(i.uv, _MainTex_ST),
  45. UnityStereoScreenSpaceUVAdjust(consoleUV, _MainTex_ST),
  46. _MainTex, _MainTex, _MainTex, _MainTex_TexelSize.xy,
  47. consoleSubpixelFrame, consoleSubpixelFramePS3, consoleSubpixelFrameXBOX,
  48. _QualitySettings.x, _QualitySettings.y, _QualitySettings.z,
  49. _ConsoleSettings.y, _ConsoleSettings.z, _ConsoleSettings.w, consoleConstants);
  50. color.rgb = UberSecondPass(color.rgb, i.uv);
  51. return half4(color.rgb, 1.0);
  52. }
  53. ENDCG
  54. SubShader
  55. {
  56. Cull Off ZWrite Off ZTest Always
  57. Pass
  58. {
  59. CGPROGRAM
  60. #pragma vertex VertDefault
  61. #pragma fragment Frag
  62. ENDCG
  63. }
  64. }
  65. }