Professional Documents
Culture Documents
//---------------------------------------------------------------------------------
-----
// Defines
//---------------------------------------------------------------------------------
-----
//#define AA_MODE_0
//#define AA_MODE_1
#define AA_MODE_2
//---------------------------------------------------------------------------------
-----
// Vectors, floats and etc.
//---------------------------------------------------------------------------------
-----
//---------------------------------------------------------------------------------
-----
// Textures
//---------------------------------------------------------------------------------
-----
texture2D texColor;
//---------------------------------------------------------------------------------
-----
// Functions
//---------------------------------------------------------------------------------
-----
//---------------------------------------------------------------------------------
-----
// Sampler Inputs
//---------------------------------------------------------------------------------
-----
struct VS_OUTPUT_POST
{
float4 vpos : POSITION;
float2 txcoord : TEXCOORD0;
};
struct VS_INPUT_POST
{
float3 pos : POSITION;
float2 txcoord : TEXCOORD0;
};
struct VS_OUTPUT_POST_SSAA
{
float4 vpos : POSITION;
float2 uv[5] : TEXCOORD0;
};
struct VS_OUTPUT_POST_NFAA
{
float4 vpos : POSITION;
float2 uv[8] : TEXCOORD0;
};
//---------------------------------------------------------------------------------
-----
// Functions
//---------------------------------------------------------------------------------
-----
//---------------------------------------------------------------------------------
-----
// Vertex Shader Input
//---------------------------------------------------------------------------------
-----
float4 pos=float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);
OUT.vpos=pos;
OUT.txcoord.xy=IN.txcoord.xy;
return OUT;
}
o.vpos=pos;
float2 uv = IN.txcoord.xy;
float w = 1.75;
o.uv[0].xy = uv - up;
o.uv[1].xy = uv - right;
o.uv[2].xy = uv + right;
o.uv[3].xy = uv + up;
o.uv[4].xy = uv;
return o;
}
float2 uv = IN.txcoord.xy;
o.uv[0].xy = uv + up;
o.uv[1].xy = uv - up;
o.uv[2].xy = uv + right;
o.uv[3].xy = uv - right;
o.uv[4].xy = uv - right + up;
o.uv[5].xy = uv - right -up;
o.uv[6].xy = uv + right + up;
o.uv[7].xy = uv + right -up;
return o;
}
//---------------------------------------------------------------------------------
-----
// Pixel Shader Effects
//---------------------------------------------------------------------------------
-----
//---------------------------------------------------------------------------------
-----
//AntiAliasing
//---------------------------------------------------------------------------------
-----
float2 n = float2( -( t - b ), r - l );
float nl = length( n );
return outColor;
}
// 2 triangle subtractions
float sum0 = dot(float3(1,1,1), float3(rightTopL,bottomL,leftTopL));
float sum1 = dot(float3(1,1,1), float3(leftBottomL,topL,rightBottomL));
float sum2 = dot(float3(1,1,1), float3(leftTopL,rightL,leftBottomL));
float sum3 = dot(float3(1,1,1), float3(rightBottomL,leftL,rightTopL));
// reconstruct normal uv
float2 uv_ = (i.uv[0] + i.uv[1]) * 0.5;
struct VS_OUTPUT_POST_FXAA {
float4 vpos : SV_POSITION;
float2 uv : TEXCOORD0;
float4 interpolatorA : TEXCOORD1;
float4 interpolatorB : TEXCOORD2;
float4 interpolatorC : TEXCOORD3;
};
o.uv = v.txcoord.xy;
float4 extents;
float2 offset = ( texel.xy ) * 0.5f;
extents.xy = v.txcoord.xy - offset;
extents.zw = v.txcoord.xy + offset;
float4 rcpSize;
rcpSize.xy = -texel.xy * 0.5f;
rcpSize.zw = texel.xy * 0.5f;
o.interpolatorA = extents;
o.interpolatorB = rcpSize;
o.interpolatorC = rcpSize;
o.interpolatorC.xy *= 4.0;
o.interpolatorC.zw *= 4.0;
return o;
}
float2 dir;
dir.x = dirSWMinusNE + dirSEMinusNW;
dir.y = dirSWMinusNE - dirSEMinusNW;
dir = normalize(dir);
float3 col1 = FxaaTexTop(InputSampler, pos.xy - dir * rcpSize.zw).rgb;
float3 col2 = FxaaTexTop(InputSampler, pos.xy + dir * rcpSize.zw).rgb;
//---------------------------------------------------------------------------------
-----
// Compiler 1
//---------------------------------------------------------------------------------
-----
technique PostProcess
{
pass P0
{
#ifdef AA_MODE_0
VertexShader = compile vs_3_0 VS_PostProcessSSAA();
PixelShader = compile ps_3_0 SSAA();
#endif
#ifdef AA_MODE_1
VertexShader = compile vs_3_0 VS_PostProcessNFAA();
PixelShader = compile ps_3_0 NFAA();
#endif
#ifdef AA_MODE_2
VertexShader = compile vs_3_0 VS_PostProcessFXAA();
PixelShader = compile ps_3_0 FXAA();
#endif
}
}