Created
February 15, 2012 22:05
-
-
Save steeve/1839327 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*------------------------------------------------------------------------------ | |
FXAA SHADER | |
------------------------------------------------------------------------------*/ | |
#define FXAA_PC 1 | |
#define FXAA_HLSL_4 1 | |
#define FXAA_QUALITY__PRESET 39 | |
#include "injFX_Settings.h" | |
#include "injFX_Shaders\Fxaa3_11.h" | |
Texture2D gScreenTexture : register(t0); | |
Texture2D gLumaTexture : register(t1); | |
SamplerState screenSampler : register(s0); | |
//Difinitions: BUFFER_WIDTH, BUFFER_HEIGHT, BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT | |
struct PS_INPUT | |
{ | |
float2 vTexcoord : TEXCOORD0; | |
}; | |
struct VS_Output | |
{ | |
float4 Pos : SV_POSITION; | |
float2 Tex : TEXCOORD0; | |
}; | |
struct VS_Input | |
{ | |
float4 Pos : POSITION; | |
float2 Tex : TEXCOORD0; | |
}; | |
VS_Output VSMain( VS_Input Input ) | |
{ | |
VS_Output Output; | |
Output.Pos = Input.Pos; | |
Output.Tex = Input.Tex; | |
return Output; | |
} | |
#include "injFX_Shaders\Post.h" | |
float4 LumaShader( VS_Output Input ) : SV_TARGET | |
{ | |
float4 c0 = main(Input.Tex); | |
c0.w = dot(c0.xyz,float3(0.299, 0.587, 0.114)); //store luma in alpha | |
//c0.w = sqrt(dot(c0.xyz,float3(0.299, 0.587, 0.114))); //store luma in alpha | |
return c0; | |
} | |
float4 MyShader( VS_Output Input ) : SV_TARGET | |
{ | |
#ifdef USE_ANTI_ALIASING | |
FxaaTex t = { screenSampler, gLumaTexture }; | |
float4 c0 = FxaaPixelShader( | |
Input.Tex, //pos | |
0, //fxaaConsolePosPos (?) | |
t, //tex | |
t, //fxaaConsole360TexExpBiasNegOne | |
t, //fxaaConsole360TexExpBiasNegTwo | |
float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT), //fxaaQualityRcpFrame | |
float4(-0.5*BUFFER_RCP_WIDTH,-0.5*BUFFER_RCP_HEIGHT,0.5*BUFFER_RCP_WIDTH,0.5*BUFFER_RCP_HEIGHT), //fxaaConsoleRcpFrameOpt | |
float4(-2.0*BUFFER_RCP_WIDTH,-2.0*BUFFER_RCP_HEIGHT,2.0*BUFFER_RCP_WIDTH,2.0*BUFFER_RCP_HEIGHT), //fxaaConsoleRcpFrameOpt2 | |
float4(8.0*BUFFER_RCP_WIDTH,8.0*BUFFER_RCP_HEIGHT,-4.0*BUFFER_RCP_WIDTH,-4.0*BUFFER_RCP_HEIGHT), //fxaaConsole360RcpFrameOpt2 | |
fxaaQualitySubpix, | |
fxaaQualityEdgeThreshold, | |
fxaaQualityEdgeThresholdMin, | |
0, //fxaaConsoleEdgeSharpness | |
0, //fxaaConsoleEdgeThreshold | |
0, //fxaaConsoleEdgeThresholdMin | |
0 //fxaaConsole360ConstDir | |
); | |
c0.w = 1; | |
#else | |
float4 c0 = myTex2D(screenSampler,Input.Tex); | |
#endif | |
return c0; | |
} | |
float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0 | |
{ | |
float4 c0 = main(Tex); | |
c0.w = 1; | |
return saturate(c0); | |
} | |
technique PostProcess1 | |
{ | |
pass p1 | |
{ | |
SetPixelShader(CompileShader(ps_5_0, VSMain())); | |
} | |
} | |
technique PostProcess2 | |
{ | |
pass p1 | |
{ | |
SetPixelShader(CompileShader(ps_5_0, VSMain())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment