pcsx2/plugins/GSdx/res/fxaa.h

1271 lines
52 KiB
C

/*
* Copyright (C) 2011-2013 Gregory hainaut
* Copyright (C) 2007-2009 Gabest
*
* This file was generated by glsl2h.pl script
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#pragma once
#include "stdafx.h"
static const char* fxaa_fx =
"#if defined(SHADER_MODEL) || defined(FXAA_GLSL_130) // make safe to include in resource file to enforce dependency\n"
"\n"
"#ifndef FXAA_GLSL_130\n"
" #define FXAA_GLSL_130 0\n"
"#endif\n"
"\n"
"#define FXAA_PC 1\n"
"#define FXAA_QUALITY_SUBPIX 0.0\n"
"\n"
"#ifdef SHADER_MODEL\n"
"#if SHADER_MODEL >= 0x400\n"
"\n"
"#if SHADER_MODEL >= 0x500\n"
" #define FXAA_HLSL_5 1\n"
"#else \n"
" #define FXAA_HLSL_4 1\n"
"#endif\n"
"\n"
"Texture2D Texture;\n"
"SamplerState TextureSampler;\n"
"\n"
"cbuffer cb0\n"
"{\n"
" float4 _rcpFrame;\n"
" float4 _rcpFrameOpt;\n"
"};\n"
"\n"
"struct PS_INPUT\n"
"{\n"
" float4 p : SV_Position;\n"
" float2 t : TEXCOORD0;\n"
"};\n"
"\n"
"struct PS_OUTPUT\n"
"{\n"
" float4 c : SV_Target0;\n"
"};\n"
"\n"
"#elif SHADER_MODEL <= 0x300\n"
"\n"
"#define FXAA_HLSL_3 1\n"
"\n"
"sampler Texture : register(s0);\n"
"\n"
"float4 _rcpFrame : register(c0);\n"
"float4 _rcpFrameOpt : register(c1);\n"
"\n"
"struct PS_INPUT\n"
"{\n"
"#if SHADER_MODEL < 0x300\n"
" float4 p : TEXCOORD1;\n"
"#else\n"
" float4 p : VPOS;\n"
"#endif\n"
" float2 t : TEXCOORD0;\n"
"};\n"
"\n"
"struct PS_OUTPUT\n"
"{\n"
" float4 c : COLOR;\n"
"};\n"
"\n"
"#endif\n"
"#endif\n"
"\n"
"\n"
"#if (FXAA_GLSL_130 == 1)\n"
"struct vertex_basic\n"
"{\n"
" vec4 p;\n"
" vec2 t;\n"
"};\n"
"\n"
"#ifdef DISABLE_GL42\n"
"layout(std140) uniform cb13\n"
"#else\n"
"layout(std140, binding = 13) uniform cb13\n"
"#endif\n"
"{\n"
" vec4 _rcpFrame;\n"
" vec4 _rcpFrameOpt;\n"
"};\n"
"\n"
"#ifdef DISABLE_GL42\n"
"uniform sampler2D TextureSampler;\n"
"#else\n"
"layout(binding = 0) uniform sampler2D TextureSampler;\n"
"#endif\n"
"\n"
"#if __VERSION__ > 140 && !(defined(NO_STRUCT))\n"
"layout(location = 0) in vertex_basic PSin;\n"
"#define PSin_p (PSin.p)\n"
"#define PSin_t (PSin.t)\n"
"#else\n"
"#ifdef DISABLE_SSO\n"
"in vec4 SHADERp;\n"
"in vec2 SHADERt;\n"
"#else\n"
"layout(location = 0) in vec4 SHADERp;\n"
"layout(location = 1) in vec2 SHADERt;\n"
"#endif\n"
"#define PSin_p SHADERp\n"
"#define PSin_t SHADERt\n"
"#endif\n"
"\n"
"layout(location = 0) out vec4 SV_Target0;\n"
"\n"
"#endif\n"
"\n"
"/*============================================================================\n"
"\n"
"\n"
" NVIDIA FXAA 3.10 by TIMOTHY LOTTES\n"
"\n"
"\n"
"------------------------------------------------------------------------------\n"
"COPYRIGHT (C) 2010, 2011 NVIDIA CORPORATION. ALL RIGHTS RESERVED.\n"
"------------------------------------------------------------------------------\n"
"TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED\n"
"*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS\n"
"OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF\n"
"MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA\n"
"OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR\n"
"CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR\n"
"LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION,\n"
"OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE\n"
"THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\n"
"DAMAGES.\n"
"\n"
"------------------------------------------------------------------------------\n"
" INTEGRATION CHECKLIST\n"
"------------------------------------------------------------------------------\n"
"(1.)\n"
"In the shader source,\n"
"setup defines for the desired configuration.\n"
"Example,\n"
"\n"
" #define FXAA_PC 1\n"
" #define FXAA_HLSL_3 1\n"
" #define FXAA_QUALITY_PRESET 12\n"
" #define FXAA_QUALITY_EDGE_THRESHOLD (1.0/6.0)\n"
" #define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/12.0)\n"
"\n"
"(2.)\n"
"Then include this file,\n"
"\n"
" #include \"Fxaa3.h\"\n"
"\n"
"(3.)\n"
"Then call the FXAA pixel shader from within your desired shader,\n"
"\n"
" return FxaaPixelShader(pos, posPos, tex, rcpFrame, rcpFrameOpt);\n"
"\n"
"(4.)\n"
"Insure pass prior to FXAA outputs RGBL.\n"
"See next section.\n"
"\n"
"(5.)\n"
"Setup engine to provide \"rcpFrame\" and \"rcpFrameOpt\" constants.\n"
"Not using constants will result in a performance loss.\n"
"\n"
" // {x_} = 1.0/screenWidthInPixels\n"
" // {_y} = 1.0/screenHeightInPixels\n"
" float2 rcpFrame\n"
"\n"
" // This must be from a constant/uniform.\n"
" // {x___} = 2.0/screenWidthInPixels\n"
" // {_y__} = 2.0/screenHeightInPixels\n"
" // {__z_} = 0.5/screenWidthInPixels\n"
" // {___w} = 0.5/screenHeightInPixels\n"
" float4 rcpFrameOpt\n"
"\n"
"(5.a.) \n"
"Optionally change to this for sharper FXAA Console,\n"
"\n"
" // This must be from a constant/uniform.\n"
" // {x___} = 2.0/screenWidthInPixels\n"
" // {_y__} = 2.0/screenHeightInPixels\n"
" // {__z_} = 0.333/screenWidthInPixels\n"
" // {___w} = 0.333/screenHeightInPixels\n"
" float4 rcpFrameOpt\n"
"\n"
"(6.)\n"
"Have FXAA vertex shader run as a full screen triangle,\n"
"and output \"pos\" and \"posPos\" such that inputs in the pixel shader provide,\n"
"\n"
" // {xy} = center of pixel\n"
" float2 pos,\n"
"\n"
" // {xy__} = upper left of pixel\n"
" // {__zw} = lower right of pixel\n"
" float4 posPos,\n"
"\n"
"(7.)\n"
"Insure the texture sampler used by FXAA is set to bilinear filtering.\n"
"\n"
"\n"
"------------------------------------------------------------------------------\n"
" INTEGRATION - RGBL AND COLORSPACE\n"
"------------------------------------------------------------------------------\n"
"FXAA3 requires RGBL as input.\n"
"\n"
"RGB should be LDR (low dynamic range).\n"
"Specifically do FXAA after tonemapping.\n"
"\n"
"RGB data as returned by a texture fetch can be linear or non-linear.\n"
"Note an \"sRGB format\" texture counts as linear,\n"
"because the result of a texture fetch is linear data.\n"
"Regular \"RGBA8\" textures in the sRGB colorspace are non-linear.\n"
"\n"
"Luma must be stored in the alpha channel prior to running FXAA.\n"
"This luma should be in a perceptual space (could be gamma 2.0).\n"
"Example pass before FXAA where output is gamma 2.0 encoded,\n"
"\n"
" color.rgb = ToneMap(color.rgb); // linear color output\n"
" color.rgb = sqrt(color.rgb); // gamma 2.0 color output\n"
" return color;\n"
"\n"
"To use FXAA,\n"
"\n"
" color.rgb = ToneMap(color.rgb); // linear color output\n"
" color.rgb = sqrt(color.rgb); // gamma 2.0 color output\n"
" color.a = dot(color.rgb, float3(0.299, 0.587, 0.114)); // compute luma\n"
" return color;\n"
"\n"
"Another example where output is linear encoded,\n"
"say for instance writing to an sRGB formated render target,\n"
"where the render target does the conversion back to sRGB after blending,\n"
"\n"
" color.rgb = ToneMap(color.rgb); // linear color output\n"
" return color;\n"
"\n"
"To use FXAA,\n"
"\n"
" color.rgb = ToneMap(color.rgb); // linear color output\n"
" color.a = sqrt(dot(color.rgb, float3(0.299, 0.587, 0.114))); // compute luma\n"
" return color;\n"
"\n"
"Getting luma correct is required for the algorithm to work correctly.\n"
"\n"
"\n"
"------------------------------------------------------------------------------\n"
" BEING LINEARLY CORRECT?\n"
"------------------------------------------------------------------------------\n"
"Applying FXAA to a framebuffer with linear RGB color will look worse.\n"
"This is very counter intuitive, but happends to be true in this case.\n"
"The reason is because dithering artifacts will be more visiable \n"
"in a linear colorspace.\n"
"\n"
"\n"
"------------------------------------------------------------------------------\n"
" COMPLEX INTEGRATION\n"
"------------------------------------------------------------------------------\n"
"Q. What if the engine is blending into RGB before wanting to run FXAA?\n"
"\n"
"A. In the last opaque pass prior to FXAA,\n"
" have the pass write out luma into alpha.\n"
" Then blend into RGB only.\n"
" FXAA should be able to run ok\n"
" assuming the blending pass did not any add aliasing.\n"
" This should be the common case for particles and common blending passes.\n"
"\n"
"============================================================================*/\n"
"\n"
"/*============================================================================\n"
"\n"
" INTEGRATION KNOBS\n"
"\n"
"============================================================================*/\n"
"//\n"
"// FXAA_PS3 and FXAA_360 choose the console algorithm (FXAA3 CONSOLE).\n"
"// FXAA_360_OPT is a prototype for the new optimized 360 version.\n"
"//\n"
"// 1 = Use API.\n"
"// 0 = Don't use API.\n"
"//\n"
"/*--------------------------------------------------------------------------*/\n"
"#ifndef FXAA_PS3\n"
" #define FXAA_PS3 0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#ifndef FXAA_360\n"
" #define FXAA_360 0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#ifndef FXAA_360_OPT\n"
" #define FXAA_360_OPT 0\n"
"#endif\n"
"/*==========================================================================*/\n"
"#ifndef FXAA_PC\n"
" //\n"
" // FXAA Quality\n"
" // The high quality PC algorithm.\n"
" //\n"
" #define FXAA_PC 0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#ifndef FXAA_PC_CONSOLE\n"
" //\n"
" // The console algorithm for PC is included\n"
" // for developers targeting really low spec machines.\n"
" //\n"
" #define FXAA_PC_CONSOLE 0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#ifndef FXAA_GLSL_120\n"
" #define FXAA_GLSL_120 0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#ifndef FXAA_GLSL_130\n"
" #define FXAA_GLSL_130 0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#ifndef FXAA_HLSL_3\n"
" #define FXAA_HLSL_3 0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#ifndef FXAA_HLSL_4\n"
" #define FXAA_HLSL_4 0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#ifndef FXAA_HLSL_5\n"
" #define FXAA_HLSL_5 0\n"
"#endif\n"
"/*==========================================================================*/\n"
"#ifndef FXAA_EARLY_EXIT\n"
" //\n"
" // Controls algorithm's early exit path.\n"
" // On PS3 turning this on adds 2 cycles to the shader.\n"
" // On 360 turning this off adds 10ths of a millisecond to the shader.\n"
" // Turning this off on console will result in a more blurry image.\n"
" // So this defaults to on.\n"
" //\n"
" // 1 = On.\n"
" // 0 = Off.\n"
" //\n"
" #define FXAA_EARLY_EXIT 1\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#ifndef FXAA_DISCARD\n"
" //\n"
" // Only valid for PC OpenGL currently.\n"
" //\n"
" // 1 = Use discard on pixels which don't need AA.\n"
" // For APIs which enable concurrent TEX+ROP from same surface.\n"
" // 0 = Return unchanged color on pixels which don't need AA.\n"
" //\n"
" #define FXAA_DISCARD 0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#ifndef FXAA_FAST_PIXEL_OFFSET\n"
" //\n"
" // Used for GLSL 120 only.\n"
" //\n"
" // 1 = GL API supports fast pixel offsets\n"
" // 0 = do not use fast pixel offsets\n"
" //\n"
" #ifdef GL_EXT_gpu_shader4\n"
" #define FXAA_FAST_PIXEL_OFFSET 1\n"
" #endif\n"
" #ifdef GL_NV_gpu_shader5\n"
" #define FXAA_FAST_PIXEL_OFFSET 1\n"
" #endif\n"
" #ifdef GL_ARB_gpu_shader5\n"
" #define FXAA_FAST_PIXEL_OFFSET 1\n"
" #endif\n"
" #ifndef FXAA_FAST_PIXEL_OFFSET\n"
" #define FXAA_FAST_PIXEL_OFFSET 0\n"
" #endif\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#ifndef FXAA_GATHER4_ALPHA\n"
" //\n"
" // 1 = API supports gather4 on alpha channel.\n"
" // 0 = API does not support gather4 on alpha channel.\n"
" //\n"
" #if (FXAA_HLSL_5 == 1)\n"
" #define FXAA_GATHER4_ALPHA 1\n"
" #endif\n"
" #ifdef GL_ARB_gpu_shader5\n"
" #define FXAA_GATHER4_ALPHA 1\n"
" #endif\n"
" #ifdef GL_NV_gpu_shader5\n"
" #define FXAA_GATHER4_ALPHA 1\n"
" #endif\n"
" #ifndef FXAA_GATHER4_ALPHA\n"
" #define FXAA_GATHER4_ALPHA 0\n"
" #endif\n"
"#endif\n"
"\n"
"/*============================================================================\n"
" FXAA CONSOLE - TUNING KNOBS\n"
"============================================================================*/\n"
"#ifndef FXAA_CONSOLE_EDGE_SHARPNESS\n"
" //\n"
" // Consoles the sharpness of edges.\n"
" //\n"
" // Due to the PS3 being ALU bound,\n"
" // there are only two safe values here: 4 and 8.\n"
" // These options use the shaders ability to a free *|/ by 4|8.\n"
" //\n"
" // 8.0 is sharper\n"
" // 4.0 is softer\n"
" // 2.0 is really soft (good for vector graphics inputs)\n"
" //\n"
" #if 1\n"
" #define FXAA_CONSOLE_EDGE_SHARPNESS 8.0\n"
" #endif\n"
" #if 0\n"
" #define FXAA_CONSOLE_EDGE_SHARPNESS 4.0\n"
" #endif\n"
" #if 0\n"
" #define FXAA_CONSOLE_EDGE_SHARPNESS 2.0\n"
" #endif\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#ifndef FXAA_CONSOLE_EDGE_THRESHOLD\n"
" //\n"
" // The minimum amount of local contrast required to apply algorithm.\n"
" // The console setting has a different mapping than the quality setting.\n"
" //\n"
" // This only applies when FXAA_EARLY_EXIT is 1.\n"
" //\n"
" // Due to the PS3 being ALU bound,\n"
" // there are only two safe values here: 0.25 and 0.125.\n"
" // These options use the shaders ability to a free *|/ by 4|8.\n"
" //\n"
" // 0.125 leaves less aliasing, but is softer\n"
" // 0.25 leaves more aliasing, and is sharper\n"
" //\n"
" #if 1\n"
" #define FXAA_CONSOLE_EDGE_THRESHOLD 0.125\n"
" #else\n"
" #define FXAA_CONSOLE_EDGE_THRESHOLD 0.25\n"
" #endif\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#ifndef FXAA_CONSOLE_EDGE_THRESHOLD_MIN\n"
" //\n"
" // Trims the algorithm from processing darks.\n"
" // The console setting has a different mapping than the quality setting.\n"
" //\n"
" // This only applies when FXAA_EARLY_EXIT is 1.\n"
" //\n"
" // This does not apply to PS3.\n"
" // PS3 was simplified to avoid more shader instructions.\n"
" //\n"
" #define FXAA_CONSOLE_EDGE_THRESHOLD_MIN 0.05\n"
"#endif\n"
"\n"
"/*============================================================================\n"
" FXAA QUALITY - TUNING KNOBS\n"
"============================================================================*/\n"
"#ifndef FXAA_QUALITY_EDGE_THRESHOLD\n"
" //\n"
" // The minimum amount of local contrast required to apply algorithm.\n"
" //\n"
" // 1/3 - too little\n"
" // 1/4 - low quality\n"
" // 1/6 - default\n"
" // 1/8 - high quality (default)\n"
" // 1/16 - overkill\n"
" //\n"
" #define FXAA_QUALITY_EDGE_THRESHOLD (1.0/6.0)\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#ifndef FXAA_QUALITY_EDGE_THRESHOLD_MIN\n"
" //\n"
" // Trims the algorithm from processing darks.\n"
" //\n"
" // 1/32 - visible limit\n"
" // 1/16 - high quality\n"
" // 1/12 - upper limit (default, the start of visible unfiltered edges)\n"
" //\n"
" #define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/12.0)\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#ifndef FXAA_QUALITY_SUBPIX\n"
" //\n"
" // Choose the amount of sub-pixel aliasing removal.\n"
" //\n"
" // 1 - upper limit (softer)\n"
" // 3/4 - default amount of filtering\n"
" // 1/2 - lower limit (sharper, less sub-pixel aliasing removal)\n"
" //\n"
" #define FXAA_QUALITY_SUBPIX (3.0/4.0)\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#ifndef FXAA_QUALITY_PRESET\n"
" //\n"
" // Choose the quality preset.\n"
" // \n"
" // OPTIONS\n"
" // -----------------------------------------------------------------------\n"
" // 10 to 15 - default medium dither (10=fastest, 15=highest quality)\n"
" // 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)\n"
" // 39 - no dither, very expensive \n"
" //\n"
" // NOTES\n"
" // -----------------------------------------------------------------------\n"
" // 12 = slightly faster then FXAA 3.9 and higher edge quality (default)\n"
" // 13 = about same speed as FXAA 3.9 and better than 12\n"
" // 23 = closest to FXAA 3.9 visually and performance wise\n"
" // _ = the lowest digit is directly related to performance\n"
" // _ = the highest digit is directly related to style\n"
" // \n"
" #define FXAA_QUALITY_PRESET 12\n"
"#endif\n"
"\n"
"\n"
"/*============================================================================\n"
"\n"
" FXAA QUALITY - PRESETS\n"
"\n"
"============================================================================*/\n"
"\n"
"/*============================================================================\n"
" FXAA QUALITY - MEDIUM DITHER PRESETS\n"
"============================================================================*/\n"
"#if (FXAA_QUALITY_PRESET == 10)\n"
" #define FXAA_QUALITY_PS 3\n"
" #define FXAA_QUALITY_P0 1.5\n"
" #define FXAA_QUALITY_P1 3.0\n"
" #define FXAA_QUALITY_P2 12.0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#if (FXAA_QUALITY_PRESET == 11)\n"
" #define FXAA_QUALITY_PS 4\n"
" #define FXAA_QUALITY_P0 1.0\n"
" #define FXAA_QUALITY_P1 1.5\n"
" #define FXAA_QUALITY_P2 3.0\n"
" #define FXAA_QUALITY_P3 12.0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#if (FXAA_QUALITY_PRESET == 12)\n"
" #define FXAA_QUALITY_PS 5\n"
" #define FXAA_QUALITY_P0 1.0\n"
" #define FXAA_QUALITY_P1 1.5\n"
" #define FXAA_QUALITY_P2 2.0\n"
" #define FXAA_QUALITY_P3 4.0\n"
" #define FXAA_QUALITY_P4 12.0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#if (FXAA_QUALITY_PRESET == 13)\n"
" #define FXAA_QUALITY_PS 6\n"
" #define FXAA_QUALITY_P0 1.0\n"
" #define FXAA_QUALITY_P1 1.5\n"
" #define FXAA_QUALITY_P2 2.0\n"
" #define FXAA_QUALITY_P3 2.0\n"
" #define FXAA_QUALITY_P4 4.0\n"
" #define FXAA_QUALITY_P5 12.0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#if (FXAA_QUALITY_PRESET == 14)\n"
" #define FXAA_QUALITY_PS 7\n"
" #define FXAA_QUALITY_P0 1.0\n"
" #define FXAA_QUALITY_P1 1.5\n"
" #define FXAA_QUALITY_P2 2.0\n"
" #define FXAA_QUALITY_P3 2.0\n"
" #define FXAA_QUALITY_P4 2.0\n"
" #define FXAA_QUALITY_P5 4.0\n"
" #define FXAA_QUALITY_P6 12.0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#if (FXAA_QUALITY_PRESET == 15)\n"
" #define FXAA_QUALITY_PS 8\n"
" #define FXAA_QUALITY_P0 1.0\n"
" #define FXAA_QUALITY_P1 1.5\n"
" #define FXAA_QUALITY_P2 2.0\n"
" #define FXAA_QUALITY_P3 2.0\n"
" #define FXAA_QUALITY_P4 2.0\n"
" #define FXAA_QUALITY_P5 2.0\n"
" #define FXAA_QUALITY_P6 4.0\n"
" #define FXAA_QUALITY_P7 12.0\n"
"#endif\n"
"\n"
"/*============================================================================\n"
" FXAA QUALITY - LOW DITHER PRESETS\n"
"============================================================================*/\n"
"#if (FXAA_QUALITY_PRESET == 20)\n"
" #define FXAA_QUALITY_PS 3\n"
" #define FXAA_QUALITY_P0 1.5\n"
" #define FXAA_QUALITY_P1 2.0\n"
" #define FXAA_QUALITY_P2 8.0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#if (FXAA_QUALITY_PRESET == 21)\n"
" #define FXAA_QUALITY_PS 4\n"
" #define FXAA_QUALITY_P0 1.0\n"
" #define FXAA_QUALITY_P1 1.5\n"
" #define FXAA_QUALITY_P2 2.0\n"
" #define FXAA_QUALITY_P3 8.0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#if (FXAA_QUALITY_PRESET == 22)\n"
" #define FXAA_QUALITY_PS 5\n"
" #define FXAA_QUALITY_P0 1.0\n"
" #define FXAA_QUALITY_P1 1.5\n"
" #define FXAA_QUALITY_P2 2.0\n"
" #define FXAA_QUALITY_P3 2.0\n"
" #define FXAA_QUALITY_P4 8.0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#if (FXAA_QUALITY_PRESET == 23)\n"
" #define FXAA_QUALITY_PS 6\n"
" #define FXAA_QUALITY_P0 1.0\n"
" #define FXAA_QUALITY_P1 1.5\n"
" #define FXAA_QUALITY_P2 2.0\n"
" #define FXAA_QUALITY_P3 2.0\n"
" #define FXAA_QUALITY_P4 2.0\n"
" #define FXAA_QUALITY_P5 8.0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#if (FXAA_QUALITY_PRESET == 24)\n"
" #define FXAA_QUALITY_PS 7\n"
" #define FXAA_QUALITY_P0 1.0\n"
" #define FXAA_QUALITY_P1 1.5\n"
" #define FXAA_QUALITY_P2 2.0\n"
" #define FXAA_QUALITY_P3 2.0\n"
" #define FXAA_QUALITY_P4 2.0\n"
" #define FXAA_QUALITY_P5 3.0\n"
" #define FXAA_QUALITY_P6 8.0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#if (FXAA_QUALITY_PRESET == 25)\n"
" #define FXAA_QUALITY_PS 8\n"
" #define FXAA_QUALITY_P0 1.0\n"
" #define FXAA_QUALITY_P1 1.5\n"
" #define FXAA_QUALITY_P2 2.0\n"
" #define FXAA_QUALITY_P3 2.0\n"
" #define FXAA_QUALITY_P4 2.0\n"
" #define FXAA_QUALITY_P5 2.0\n"
" #define FXAA_QUALITY_P6 4.0\n"
" #define FXAA_QUALITY_P7 8.0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#if (FXAA_QUALITY_PRESET == 26)\n"
" #define FXAA_QUALITY_PS 9\n"
" #define FXAA_QUALITY_P0 1.0\n"
" #define FXAA_QUALITY_P1 1.5\n"
" #define FXAA_QUALITY_P2 2.0\n"
" #define FXAA_QUALITY_P3 2.0\n"
" #define FXAA_QUALITY_P4 2.0\n"
" #define FXAA_QUALITY_P5 2.0\n"
" #define FXAA_QUALITY_P6 2.0\n"
" #define FXAA_QUALITY_P7 4.0\n"
" #define FXAA_QUALITY_P8 8.0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#if (FXAA_QUALITY_PRESET == 27)\n"
" #define FXAA_QUALITY_PS 10\n"
" #define FXAA_QUALITY_P0 1.0\n"
" #define FXAA_QUALITY_P1 1.5\n"
" #define FXAA_QUALITY_P2 2.0\n"
" #define FXAA_QUALITY_P3 2.0\n"
" #define FXAA_QUALITY_P4 2.0\n"
" #define FXAA_QUALITY_P5 2.0\n"
" #define FXAA_QUALITY_P6 2.0\n"
" #define FXAA_QUALITY_P7 2.0\n"
" #define FXAA_QUALITY_P8 4.0\n"
" #define FXAA_QUALITY_P9 8.0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#if (FXAA_QUALITY_PRESET == 28)\n"
" #define FXAA_QUALITY_PS 11\n"
" #define FXAA_QUALITY_P0 1.0\n"
" #define FXAA_QUALITY_P1 1.5\n"
" #define FXAA_QUALITY_P2 2.0\n"
" #define FXAA_QUALITY_P3 2.0\n"
" #define FXAA_QUALITY_P4 2.0\n"
" #define FXAA_QUALITY_P5 2.0\n"
" #define FXAA_QUALITY_P6 2.0\n"
" #define FXAA_QUALITY_P7 2.0\n"
" #define FXAA_QUALITY_P8 2.0\n"
" #define FXAA_QUALITY_P9 4.0\n"
" #define FXAA_QUALITY_P10 8.0\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#if (FXAA_QUALITY_PRESET == 29)\n"
" #define FXAA_QUALITY_PS 12\n"
" #define FXAA_QUALITY_P0 1.0\n"
" #define FXAA_QUALITY_P1 1.5\n"
" #define FXAA_QUALITY_P2 2.0\n"
" #define FXAA_QUALITY_P3 2.0\n"
" #define FXAA_QUALITY_P4 2.0\n"
" #define FXAA_QUALITY_P5 2.0\n"
" #define FXAA_QUALITY_P6 2.0\n"
" #define FXAA_QUALITY_P7 2.0\n"
" #define FXAA_QUALITY_P8 2.0\n"
" #define FXAA_QUALITY_P9 2.0\n"
" #define FXAA_QUALITY_P10 4.0\n"
" #define FXAA_QUALITY_P11 8.0\n"
"#endif\n"
"\n"
"/*============================================================================\n"
" FXAA QUALITY - EXTREME QUALITY\n"
"============================================================================*/\n"
"#if (FXAA_QUALITY_PRESET == 39)\n"
" #define FXAA_QUALITY_PS 12\n"
" #define FXAA_QUALITY_P0 1.0\n"
" #define FXAA_QUALITY_P1 1.0\n"
" #define FXAA_QUALITY_P2 1.0\n"
" #define FXAA_QUALITY_P3 1.0\n"
" #define FXAA_QUALITY_P4 1.0\n"
" #define FXAA_QUALITY_P5 1.5\n"
" #define FXAA_QUALITY_P6 2.0\n"
" #define FXAA_QUALITY_P7 2.0\n"
" #define FXAA_QUALITY_P8 2.0\n"
" #define FXAA_QUALITY_P9 2.0\n"
" #define FXAA_QUALITY_P10 4.0\n"
" #define FXAA_QUALITY_P11 8.0\n"
"#endif\n"
"\n"
"\n"
"\n"
"/*============================================================================\n"
"\n"
" API PORTING\n"
"\n"
"============================================================================*/\n"
"#if (FXAA_GLSL_120 == 1)\n"
" // Requires,\n"
" // #version 120\n"
" // And at least,\n"
" // #extension GL_EXT_gpu_shader4 : enable\n"
" // (or set FXAA_FAST_PIXEL_OFFSET 1 to work like DX9)\n"
" #define half float\n"
" #define half2 vec2\n"
" #define half3 vec3\n"
" #define half4 vec4\n"
" #define int2 ivec2\n"
" #define float2 vec2\n"
" #define float3 vec3\n"
" #define float4 vec4\n"
" #define FxaaInt2 ivec2\n"
" #define FxaaFloat2 vec2\n"
" #define FxaaFloat3 vec3\n"
" #define FxaaFloat4 vec4\n"
" #define FxaaDiscard discard\n"
" #define FxaaDot3(a, b) dot(a, b)\n"
" #define FxaaSat(x) clamp(x, 0.0, 1.0)\n"
" #define FxaaLerp(x,y,s) mix(x,y,s)\n"
" #define FxaaTex sampler2D\n"
" #define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)\n"
" #if (FXAA_FAST_PIXEL_OFFSET == 1)\n"
" #define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o)\n"
" #else\n"
" #define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)\n"
" #endif\n"
" #if (FXAA_GATHER4_ALPHA == 1)\n"
" // use #extension GL_ARB_gpu_shader5 : enable\n"
" #define FxaaTexAlpha4(t, p, r) textureGather(t, p, 3)\n"
" #define FxaaTexOffAlpha4(t, p, o, r) textureGatherOffset(t, p, o, 3)\n"
" #endif\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#if (FXAA_GLSL_130 == 1)\n"
" // Requires \"#version 130\" or better\n"
" #define half float\n"
" #define half2 vec2\n"
" #define half3 vec3\n"
" #define half4 vec4\n"
" #define int2 ivec2\n"
" #define float2 vec2\n"
" #define float3 vec3\n"
" #define float4 vec4\n"
" #define FxaaInt2 ivec2\n"
" #define FxaaFloat2 vec2\n"
" #define FxaaFloat3 vec3\n"
" #define FxaaFloat4 vec4\n"
" #define FxaaDiscard discard\n"
" #define FxaaDot3(a, b) dot(a, b)\n"
" #define FxaaSat(x) clamp(x, 0.0, 1.0)\n"
" #define FxaaLerp(x,y,s) mix(x,y,s)\n"
" #define FxaaTex sampler2D\n"
" #define FxaaTexTop(t, p) textureLod(t, p, 0.0)\n"
" #define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)\n"
" #if (FXAA_GATHER4_ALPHA == 1)\n"
" // use #extension GL_ARB_gpu_shader5 : enable\n"
" #define FxaaTexAlpha4(t, p, r) textureGather(t, p, 3)\n"
" #define FxaaTexOffAlpha4(t, p, o, r) textureGatherOffset(t, p, o, 3)\n"
" #endif\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#if (FXAA_HLSL_3 == 1) || (FXAA_360 == 1)\n"
" #define int2 float2\n"
" #define FxaaInt2 float2\n"
" #define FxaaFloat2 float2\n"
" #define FxaaFloat3 float3\n"
" #define FxaaFloat4 float4\n"
" #define FxaaDiscard clip(-1)\n"
" #define FxaaDot3(a, b) dot(a, b)\n"
" #define FxaaSat(x) saturate(x)\n"
" #define FxaaLerp(x,y,s) lerp(x,y,s)\n"
" #define FxaaTex sampler2D\n"
" #define FxaaTexTop(t, p) tex2Dlod(t, float4(p, 0.0, 0.0))\n"
" #define FxaaTexOff(t, p, o, r) tex2Dlod(t, float4(p + (o * r), 0, 0))\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#if (FXAA_HLSL_4 == 1)\n"
" #define FxaaInt2 int2\n"
" #define FxaaFloat2 float2\n"
" #define FxaaFloat3 float3\n"
" #define FxaaFloat4 float4\n"
" #define FxaaDiscard clip(-1)\n"
" #define FxaaDot3(a, b) dot(a, b)\n"
" #define FxaaSat(x) saturate(x)\n"
" #define FxaaLerp(x,y,s) lerp(x,y,s)\n"
" struct FxaaTex { SamplerState smpl; Texture2D tex; };\n"
" #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)\n"
" #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)\n"
"#endif\n"
"/*--------------------------------------------------------------------------*/\n"
"#if (FXAA_HLSL_5 == 1)\n"
" #define FxaaInt2 int2\n"
" #define FxaaFloat2 float2\n"
" #define FxaaFloat3 float3\n"
" #define FxaaFloat4 float4\n"
" #define FxaaDiscard clip(-1)\n"
" #define FxaaDot3(a, b) dot(a, b)\n"
" #define FxaaSat(x) saturate(x)\n"
" #define FxaaLerp(x,y,s) lerp(x,y,s)\n"
" struct FxaaTex { SamplerState smpl; Texture2D tex; };\n"
" #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)\n"
" #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)\n"
" #define FxaaTexAlpha4(t, p, r) t.tex.GatherAlpha(t.smpl, p)\n"
" #define FxaaTexOffAlpha4(t, p, o, r) t.tex.GatherAlpha(t.smpl, p, o)\n"
"#endif\n"
"\n"
"\n"
"\n"
"/*============================================================================\n"
"\n"
" FXAA3 QUALITY - PC\n"
"\n"
"============================================================================*/\n"
"#if (FXAA_PC == 1)\n"
"/*--------------------------------------------------------------------------*/\n"
"float4 FxaaPixelShader(\n"
" // {xy} = center of pixel\n"
" float2 pos,\n"
" // {xyzw} = not used on FXAA3 Quality\n"
" float4 posPos,\n"
" // {rgb_} = color in linear or perceptual color space\n"
" // {___a} = luma in perceptual color space (not linear)\n"
" FxaaTex tex,\n"
" // This must be from a constant/uniform.\n"
" // {x_} = 1.0/screenWidthInPixels\n"
" // {_y} = 1.0/screenHeightInPixels\n"
" float2 rcpFrame,\n"
" // {xyzw} = not used on FXAA3 Quality\n"
" float4 rcpFrameOpt\n"
") {\n"
"/*--------------------------------------------------------------------------*/\n"
" float2 posM;\n"
" posM.x = pos.x;\n"
" posM.y = pos.y;\n"
" #if (FXAA_GATHER4_ALPHA == 1)\n"
" #if (FXAA_DISCARD == 0)\n"
" float4 rgbyM = FxaaTexTop(tex, posM);\n"
" #define lumaM rgbyM.w\n"
" #endif\n"
" float4 luma4A = FxaaTexAlpha4(tex, posM, rcpFrame.xy);\n"
" float4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1), rcpFrame.xy);\n"
" #if (FXAA_DISCARD == 1)\n"
" #define lumaM luma4A.w\n"
" #endif\n"
" #define lumaE luma4A.z\n"
" #define lumaS luma4A.x\n"
" #define lumaSE luma4A.y\n"
" #define lumaNW luma4B.w\n"
" #define lumaN luma4B.z\n"
" #define lumaW luma4B.x\n"
" #else\n"
" float4 rgbyM = FxaaTexTop(tex, posM);\n"
" #define lumaM rgbyM.w\n"
" float lumaS = FxaaTexOff(tex, posM, FxaaInt2( 0, 1), rcpFrame.xy).w;\n"
" float lumaE = FxaaTexOff(tex, posM, FxaaInt2( 1, 0), rcpFrame.xy).w;\n"
" float lumaN = FxaaTexOff(tex, posM, FxaaInt2( 0,-1), rcpFrame.xy).w;\n"
" float lumaW = FxaaTexOff(tex, posM, FxaaInt2(-1, 0), rcpFrame.xy).w;\n"
" #endif\n"
"/*--------------------------------------------------------------------------*/\n"
" float maxSM = max(lumaS, lumaM);\n"
" float minSM = min(lumaS, lumaM);\n"
" float maxESM = max(lumaE, maxSM);\n"
" float minESM = min(lumaE, minSM);\n"
" float maxWN = max(lumaN, lumaW);\n"
" float minWN = min(lumaN, lumaW);\n"
" float rangeMax = max(maxWN, maxESM);\n"
" float rangeMin = min(minWN, minESM);\n"
" float rangeMaxScaled = rangeMax * FXAA_QUALITY_EDGE_THRESHOLD;\n"
" float range = rangeMax - rangeMin;\n"
" float rangeMaxClamped = max(FXAA_QUALITY_EDGE_THRESHOLD_MIN, rangeMaxScaled);\n"
" bool earlyExit = range < rangeMaxClamped;\n"
"/*--------------------------------------------------------------------------*/\n"
" if(earlyExit)\n"
" #if (FXAA_DISCARD == 1)\n"
" FxaaDiscard;\n"
" #else\n"
" return rgbyM;\n"
" #endif\n"
"/*--------------------------------------------------------------------------*/\n"
" #if (FXAA_GATHER4_ALPHA == 0)\n"
" float lumaNW = FxaaTexOff(tex, posM, FxaaInt2(-1,-1), rcpFrame.xy).w;\n"
" float lumaSE = FxaaTexOff(tex, posM, FxaaInt2( 1, 1), rcpFrame.xy).w;\n"
" float lumaNE = FxaaTexOff(tex, posM, FxaaInt2( 1,-1), rcpFrame.xy).w;\n"
" float lumaSW = FxaaTexOff(tex, posM, FxaaInt2(-1, 1), rcpFrame.xy).w;\n"
" #else\n"
" float lumaNE = FxaaTexOff(tex, posM, FxaaInt2(1, -1), rcpFrame.xy).w;\n"
" float lumaSW = FxaaTexOff(tex, posM, FxaaInt2(-1, 1), rcpFrame.xy).w;\n"
" #endif\n"
"/*--------------------------------------------------------------------------*/\n"
" float lumaNS = lumaN + lumaS;\n"
" float lumaWE = lumaW + lumaE;\n"
" float subpixRcpRange = 1.0/range;\n"
" float subpixNSWE = lumaNS + lumaWE;\n"
" float edgeHorz1 = (-2.0 * lumaM) + lumaNS;\n"
" float edgeVert1 = (-2.0 * lumaM) + lumaWE;\n"
"/*--------------------------------------------------------------------------*/\n"
" float lumaNESE = lumaNE + lumaSE;\n"
" float lumaNWNE = lumaNW + lumaNE;\n"
" float edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\n"
" float edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\n"
"/*--------------------------------------------------------------------------*/\n"
" float lumaNWSW = lumaNW + lumaSW;\n"
" float lumaSWSE = lumaSW + lumaSE;\n"
" float edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\n"
" float edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\n"
" float edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\n"
" float edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\n"
" float edgeHorz = abs(edgeHorz3) + edgeHorz4;\n"
" float edgeVert = abs(edgeVert3) + edgeVert4;\n"
"/*--------------------------------------------------------------------------*/\n"
" float subpixNWSWNESE = lumaNWSW + lumaNESE;\n"
" float lengthSign = rcpFrame.x;\n"
" bool horzSpan = edgeHorz >= edgeVert;\n"
" float subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\n"
"/*--------------------------------------------------------------------------*/\n"
" if(!horzSpan) lumaN = lumaW;\n"
" if(!horzSpan) lumaS = lumaE;\n"
" if(horzSpan) lengthSign = rcpFrame.y;\n"
" float subpixB = (subpixA * (1.0/12.0)) - lumaM;\n"
"/*--------------------------------------------------------------------------*/\n"
" float gradientN = lumaN - lumaM;\n"
" float gradientS = lumaS - lumaM;\n"
" float lumaNN = lumaN + lumaM;\n"
" float lumaSS = lumaS + lumaM;\n"
" bool pairN = abs(gradientN) >= abs(gradientS);\n"
" float gradient = max(abs(gradientN), abs(gradientS));\n"
" if(pairN) lengthSign = -lengthSign;\n"
" float subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);\n"
"/*--------------------------------------------------------------------------*/\n"
" float2 posB;\n"
" posB.x = posM.x;\n"
" posB.y = posM.y;\n"
" float2 offNP;\n"
" offNP.x = (!horzSpan) ? 0.0 : rcpFrame.x;\n"
" offNP.y = ( horzSpan) ? 0.0 : rcpFrame.y;\n"
" if(!horzSpan) posB.x += lengthSign * 0.5;\n"
" if( horzSpan) posB.y += lengthSign * 0.5;\n"
"/*--------------------------------------------------------------------------*/\n"
" float2 posN;\n"
" posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;\n"
" posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;\n"
" float2 posP;\n"
" posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;\n"
" posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;\n"
" float subpixD = ((-2.0)*subpixC) + 3.0;\n"
" float lumaEndN = FxaaTexTop(tex, posN).w;\n"
" float subpixE = subpixC * subpixC;\n"
" float lumaEndP = FxaaTexTop(tex, posP).w;\n"
"/*--------------------------------------------------------------------------*/\n"
" if(!pairN) lumaNN = lumaSS;\n"
" float gradientScaled = gradient * 1.0/4.0;\n"
" float lumaMM = lumaM - lumaNN * 0.5;\n"
" float subpixF = subpixD * subpixE;\n"
" bool lumaMLTZero = lumaMM < 0.0;\n"
"/*--------------------------------------------------------------------------*/\n"
" lumaEndN -= lumaNN * 0.5;\n"
" lumaEndP -= lumaNN * 0.5;\n"
" bool doneN = abs(lumaEndN) >= gradientScaled;\n"
" bool doneP = abs(lumaEndP) >= gradientScaled;\n"
" if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;\n"
" if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;\n"
" bool doneNP = (!doneN) || (!doneP);\n"
" if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;\n"
" if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;\n"
"/*--------------------------------------------------------------------------*/\n"
" if(doneNP) {\n"
" if(!doneN) lumaEndN = FxaaTexTop(tex, posN.xy).w;\n"
" if(!doneP) lumaEndP = FxaaTexTop(tex, posP.xy).w;\n"
" if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n"
" if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n"
" doneN = abs(lumaEndN) >= gradientScaled;\n"
" doneP = abs(lumaEndP) >= gradientScaled;\n"
" if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;\n"
" if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;\n"
" doneNP = (!doneN) || (!doneP);\n"
" if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;\n"
" if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;\n"
"/*--------------------------------------------------------------------------*/\n"
" #if (FXAA_QUALITY_PS > 3)\n"
" if(doneNP) {\n"
" if(!doneN) lumaEndN = FxaaTexTop(tex, posN.xy).w;\n"
" if(!doneP) lumaEndP = FxaaTexTop(tex, posP.xy).w;\n"
" if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n"
" if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n"
" doneN = abs(lumaEndN) >= gradientScaled;\n"
" doneP = abs(lumaEndP) >= gradientScaled;\n"
" if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;\n"
" if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;\n"
" doneNP = (!doneN) || (!doneP);\n"
" if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;\n"
" if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;\n"
"/*--------------------------------------------------------------------------*/\n"
" #if (FXAA_QUALITY_PS > 4)\n"
" if(doneNP) {\n"
" if(!doneN) lumaEndN = FxaaTexTop(tex, posN.xy).w;\n"
" if(!doneP) lumaEndP = FxaaTexTop(tex, posP.xy).w;\n"
" if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n"
" if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n"
" doneN = abs(lumaEndN) >= gradientScaled;\n"
" doneP = abs(lumaEndP) >= gradientScaled;\n"
" if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;\n"
" if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;\n"
" doneNP = (!doneN) || (!doneP);\n"
" if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;\n"
" if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;\n"
"/*--------------------------------------------------------------------------*/\n"
" #if (FXAA_QUALITY_PS > 5)\n"
" if(doneNP) {\n"
" if(!doneN) lumaEndN = FxaaTexTop(tex, posN.xy).w;\n"
" if(!doneP) lumaEndP = FxaaTexTop(tex, posP.xy).w;\n"
" if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n"
" if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n"
" doneN = abs(lumaEndN) >= gradientScaled;\n"
" doneP = abs(lumaEndP) >= gradientScaled;\n"
" if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;\n"
" if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;\n"
" doneNP = (!doneN) || (!doneP);\n"
" if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;\n"
" if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;\n"
"/*--------------------------------------------------------------------------*/\n"
" #if (FXAA_QUALITY_PS > 6)\n"
" if(doneNP) {\n"
" if(!doneN) lumaEndN = FxaaTexTop(tex, posN.xy).w;\n"
" if(!doneP) lumaEndP = FxaaTexTop(tex, posP.xy).w;\n"
" if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n"
" if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n"
" doneN = abs(lumaEndN) >= gradientScaled;\n"
" doneP = abs(lumaEndP) >= gradientScaled;\n"
" if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;\n"
" if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;\n"
" doneNP = (!doneN) || (!doneP);\n"
" if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;\n"
" if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;\n"
"/*--------------------------------------------------------------------------*/\n"
" #if (FXAA_QUALITY_PS > 7)\n"
" if(doneNP) {\n"
" if(!doneN) lumaEndN = FxaaTexTop(tex, posN.xy).w;\n"
" if(!doneP) lumaEndP = FxaaTexTop(tex, posP.xy).w;\n"
" if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n"
" if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n"
" doneN = abs(lumaEndN) >= gradientScaled;\n"
" doneP = abs(lumaEndP) >= gradientScaled;\n"
" if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;\n"
" if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;\n"
" doneNP = (!doneN) || (!doneP);\n"
" if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;\n"
" if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;\n"
"/*--------------------------------------------------------------------------*/\n"
" #if (FXAA_QUALITY_PS > 8)\n"
" if(doneNP) {\n"
" if(!doneN) lumaEndN = FxaaTexTop(tex, posN.xy).w;\n"
" if(!doneP) lumaEndP = FxaaTexTop(tex, posP.xy).w;\n"
" if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n"
" if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n"
" doneN = abs(lumaEndN) >= gradientScaled;\n"
" doneP = abs(lumaEndP) >= gradientScaled;\n"
" if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;\n"
" if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;\n"
" doneNP = (!doneN) || (!doneP);\n"
" if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;\n"
" if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;\n"
"/*--------------------------------------------------------------------------*/\n"
" #if (FXAA_QUALITY_PS > 9)\n"
" if(doneNP) {\n"
" if(!doneN) lumaEndN = FxaaTexTop(tex, posN.xy).w;\n"
" if(!doneP) lumaEndP = FxaaTexTop(tex, posP.xy).w;\n"
" if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n"
" if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n"
" doneN = abs(lumaEndN) >= gradientScaled;\n"
" doneP = abs(lumaEndP) >= gradientScaled;\n"
" if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;\n"
" if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;\n"
" doneNP = (!doneN) || (!doneP);\n"
" if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;\n"
" if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;\n"
"/*--------------------------------------------------------------------------*/\n"
" #if (FXAA_QUALITY_PS > 10)\n"
" if(doneNP) {\n"
" if(!doneN) lumaEndN = FxaaTexTop(tex, posN.xy).w;\n"
" if(!doneP) lumaEndP = FxaaTexTop(tex, posP.xy).w;\n"
" if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n"
" if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n"
" doneN = abs(lumaEndN) >= gradientScaled;\n"
" doneP = abs(lumaEndP) >= gradientScaled;\n"
" if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;\n"
" if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;\n"
" doneNP = (!doneN) || (!doneP);\n"
" if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;\n"
" if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;\n"
"/*--------------------------------------------------------------------------*/\n"
" #if (FXAA_QUALITY_PS > 11)\n"
" if(doneNP) {\n"
" if(!doneN) lumaEndN = FxaaTexTop(tex, posN.xy).w;\n"
" if(!doneP) lumaEndP = FxaaTexTop(tex, posP.xy).w;\n"
" if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n"
" if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n"
" doneN = abs(lumaEndN) >= gradientScaled;\n"
" doneP = abs(lumaEndP) >= gradientScaled;\n"
" if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;\n"
" if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;\n"
" doneNP = (!doneN) || (!doneP);\n"
" if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;\n"
" if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;\n"
"/*--------------------------------------------------------------------------*/\n"
" #if (FXAA_QUALITY_PS > 12)\n"
" if(doneNP) {\n"
" if(!doneN) lumaEndN = FxaaTexTop(tex, posN.xy).w;\n"
" if(!doneP) lumaEndP = FxaaTexTop(tex, posP.xy).w;\n"
" if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\n"
" if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\n"
" doneN = abs(lumaEndN) >= gradientScaled;\n"
" doneP = abs(lumaEndP) >= gradientScaled;\n"
" if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;\n"
" if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;\n"
" doneNP = (!doneN) || (!doneP);\n"
" if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;\n"
" if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;\n"
"/*--------------------------------------------------------------------------*/\n"
" }\n"
" #endif\n"
"/*--------------------------------------------------------------------------*/\n"
" }\n"
" #endif\n"
"/*--------------------------------------------------------------------------*/\n"
" }\n"
" #endif\n"
"/*--------------------------------------------------------------------------*/\n"
" }\n"
" #endif\n"
"/*--------------------------------------------------------------------------*/\n"
" }\n"
" #endif\n"
"/*--------------------------------------------------------------------------*/\n"
" }\n"
" #endif\n"
"/*--------------------------------------------------------------------------*/\n"
" }\n"
" #endif\n"
"/*--------------------------------------------------------------------------*/\n"
" }\n"
" #endif\n"
"/*--------------------------------------------------------------------------*/\n"
" }\n"
" #endif\n"
"/*--------------------------------------------------------------------------*/\n"
" }\n"
" #endif\n"
"/*--------------------------------------------------------------------------*/\n"
" }\n"
"/*--------------------------------------------------------------------------*/\n"
" float dstN = posM.x - posN.x;\n"
" float dstP = posP.x - posM.x;\n"
" if(!horzSpan) dstN = posM.y - posN.y;\n"
" if(!horzSpan) dstP = posP.y - posM.y;\n"
"/*--------------------------------------------------------------------------*/\n"
" bool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\n"
" float spanLength = (dstP + dstN);\n"
" bool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\n"
" float spanLengthRcp = 1.0/spanLength;\n"
"/*--------------------------------------------------------------------------*/\n"
" bool directionN = dstN < dstP;\n"
" float dst = min(dstN, dstP);\n"
" bool goodSpan = directionN ? goodSpanN : goodSpanP;\n"
" float subpixG = subpixF * subpixF;\n"
" float pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\n"
" float subpixH = subpixG * FXAA_QUALITY_SUBPIX;\n"
"/*--------------------------------------------------------------------------*/\n"
" float pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\n"
" float pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\n"
" if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\n"
" if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\n"
" #if (FXAA_DISCARD == 1)\n"
" return FxaaTexTop(tex, posM);\n"
" #else\n"
" return float4(FxaaTexTop(tex, posM).xyz, lumaM);\n"
" #endif\n"
"}\n"
"/*==========================================================================*/\n"
"#endif\n"
"\n"
"#ifdef SHADER_MODEL\n"
"PS_OUTPUT ps_main(PS_INPUT input)\n"
"{\n"
" PS_OUTPUT output;\n"
"\n"
" float2 pos = input.t;\n"
" float4 posPos = (float4)0;\n"
"\n"
" FxaaTex tex;\n"
"\n"
" #if SHADER_MODEL >= 0x400\n"
"\n"
" tex.tex = Texture;\n"
" tex.smpl = TextureSampler;\n"
"\n"
" #else\n"
"\n"
" tex = Texture;\n"
"\n"
" #endif\n"
"\n"
" output.c = FxaaPixelShader(pos, posPos, tex, _rcpFrame.xy, _rcpFrameOpt);\n"
"\n"
" return output;\n"
"}\n"
"#endif\n"
"\n"
"#if (FXAA_GLSL_130 == 1)\n"
"void ps_main()\n"
"{\n"
" vec2 pos = PSin_t;\n"
" vec4 posPos = vec4(0.0, 0.0, 0.0, 0.0);\n"
"\n"
" SV_Target0 = FxaaPixelShader(pos, posPos, TextureSampler, _rcpFrame.xy, _rcpFrameOpt);\n"
"}\n"
"#endif\n"
"\n"
"#endif\n"
;